Hello,
I am building a connector using the Connector SDK and have run into an issue where the call()
ruby method is not available within the input_fields
section of an action.
Methods Definition for set_required_fields
methods: {
set_required_fields: lambda do |object_definition, property_names|
property_names.each do |name|
obj = object_definition.find{ |o| oo"name"] == name }
objj"optional"] = false
end
object_definition
end
},
This method takes an object_definition and a list of properties names and updates their optional field to be false (or required) for a specific action.
Calling Method from input_field
and execute
blocks:
actions: {
class_create: {
title: "Create A Class",
subtitle: "Create A Class",
input_fields: lambda do |object_definitions|
classObj = object_definitionsn"class"]
classObj = call('set_required_fields', classObj, ,"name", "lab", "sku"])
end,
output_fields: lambda do |object_definitions|
...
end,
execute: lambda do |connection, input_fields, input_schema, output_schema|
classObj = call('set_required_fields', input_schema, ,"name", "lab", "sku"])
puts classObj
...
end,
},
}
In both scenarios, I use the call() method and pass in either the object_definition or input_schema.
Result for input_field:
The following error occurs when testing my Create A Class method when attempting to use call() to invoke my method, which points to the line where call() is being invoked:
classObj = call('set_required_fields', classObj, ,"name", "lab", "sku"])
Something went wrong
undefined method `call' for #<CustomAdapter::KlassFactory::DescriptorEvalContext:0x00007f9bc1fd1ad8> at line: 197
Result for execute:
I don’t receive an error here and I see the expected output from the puts classObj
command in the console when testing my method.
Takeaway
It appears the call() method is available in the execute block, but not for the input_fields block. Can anyone confirm if that is true? And if so, is there any way I could invoke my method from the input_fields block? I’m aiming to use this method to allow a helper method for easily changing which input fields are required for a shared object_definition based on the action being taken against it.
Thanks!