12-23-2021 10:41 AM
Hey all, wondering if I could get some advice on using callable recipes. I've set one up where my result schema is a single object. I then have a Python script that also outputs an object (also defined in the Workato schema.) Problem is, when I try and set the result, I can't pick anything. See here:
I can't quite get my head around why it won't accept it seeing as it's all the same type. Any ideas?
Edit: I've found if I change the input schema to text, it will let me pick the data, seems to be the type causing the problem
12-23-2021 11:38 AM
Can you share the return snippet in the Python code?
12-23-2021 11:41 AM
Hi Roland, sure:
return {"data": {input["inspection_doc"]["audit_id"]: question_ref}}
question_ref is an array, input["inspection_doc"]["audit_id"] is a string so the output is soemthing like:
{"data": { "audit_123": []}}
12-23-2021 01:56 PM
Hi,
I thought I’d just play around a bit, because this is definitely something I’ll be using…..
but just a little python script won’t run….and the 2 examlpes in the Workato help also don’t work….
12-23-2021 02:37 PM
Thanks for the link. I had a look and it's because your Python script isn't taking any input. Your script needs to be in a function called main that has input as its parameter. If you change your script to this:
def main(input):
return {"parmRerurn": "Hello World!"}
It'll work fine - even though you haven't defined any inputs, it still passes it to the main function causing the error. Anything you want to get out, needs to be passed to the returned dictionary, named with whatever is in your schema. The inputs go into the input dict so you could reference those if needed.
12-23-2021 02:10 PM
hi, would you share the recipe?