Scripting Approval Rule is throwing error and not working. The Logs are correct ( comma seprated sys ids as expected) but approvals are not triggered. Please help me here.

Archit Agnihotr
Tera Contributor

Hi Guys,

Need to Help to trigger approvals from "Approval Rules" scripting of  "Ask for Approval" block of the Flow.

find_real_file.png

Till Line number 10 ,everything is correct and we are able fetch list of sys_id's which is expected.

find_real_file.png

No Approvals are seen in RITM's approval sections. Please help where I am missing the script.

Thanks

6 REPLIES 6

jcmings
Mega Sage

Not entirely tracking your question, are you trying to manually set the approval state/request status? If so, you need to either do ritm.approval = 'state' or ritm.state = # (with 'state' or # corresponding to the approval values in your approval/state tables).

Hi jc,

No they are not approval values , they are custom user approvals using script in "Approval rule" section of "Ask for Approval" block in Flow.

Kieran Anson
Kilo Patron

Based on your script, it shouldn't be necessary and instead you should be using a look up record action. But to correct your script it should look like the following

var ritm=new GlideRecord('sc_req_item');
ritm.get(fd_data.subflow_inputs.requested_item);

var user_of_manager= ritm.variables.array of_sysid;

return gs.getMessage("ApprovesAnyU[{0}]OrRejectsAnyU[{0}]" , [user_of_manager]);

p.s if you're posting a script on the community, do both the screenshot and the text so it can be easily copied and pasted

I am getting this error while no approvals generated on RITM approval secttions.