How to get approval within Flow from dynamic approvers (within multiple records)

Ahmet Damli
Tera Contributor

Hi,

i want to create a subflow (with flow Designer) for approval of Service Requests. The approvers need to be looked up in another table (in this example from submitters of change models). I can lookup for the records. But afterwards i can not access the submitter-Field from this records to get them as approvers for the service request. How could i solve this?Its it not possible to get the submitters from the change model records.

8 REPLIES 8

rahulyamgar
Tera Guru

Did you try scripting on "Approval Field" ?

 

find_real_file.png

Ahmet Damli
Tera Contributor

no, i do not really have much experience with sripting especially in the flow designer... Maybe you can help me with some sample code?  

I need to grab users from a table based on specific criteria and then once I have them send all of the users the approval request.  so far in the flow designer I am only able to get an approval for a single user.

Jacqui
ServiceNow Employee
ServiceNow Employee

Soooo, I didn't test it, but something like this might work.

/*
**Access Flow/Action data using the fd_data object. Script must return a value.
**example: var shortDesc = fd_data.trigger.current.short_description;
**return shortDesc;
*/

fd_data._1_1__look_up_records.forEach(getApproverString);
var sys_ids = [];

function getApproverString(record) {
sys_ids.push(record.user.sys_id);
}
sys_ids_string = sys_ids.join(',');

return 'ApprovesAnyU[' + sys_ids_string + ']';

Jacqui
ServiceNow Employee
ServiceNow Employee

I looked at the code again from my last reply, and I think I used the foreach for an Array and not an object.

 

So, the answer for an object might look like this

 

var obj1 = {first: 'a928734hy23', second: '23948h2394h23'}; //replace this with your object

var sys_ids = [];

Object.keys(obj1).forEach(function (key) {

    sys_ids.push(obj1[key]);

});

sys_id_string = sys_ids.join(',');

return 'ApprovesAnyU[' + sys_id_string + ']';