Flow designer script

Not applicable

HI Team , 

 

I need to write the script in the flow designer could you please help me :

If the ‘Requested by’ user is one of the owners name , then approval should not trigger; otherwise, it should trigger. How can this be implemented in Flow Designer in ServiceNow? Can you giv me code 
 
Thanks and Regards,
Chnadan 
3 REPLIES 3

Tejas Adhalrao
Mega Sage

Hi @Community Alums ,

 this char will help you 

TejasSN_LogicX_0-1765283657733.png

 

aslo refer this scripts:

// Get the 'Requested by' user from the trigger (assuming trigger is a record)
var requestedBy = fd_data.trigger.current.requested_by.sys_id.toString();

// Define owner sys_ids (can also be retrieved dynamically from a group)
var owners = [
'sys_id_of_owner1',
'sys_id_of_owner2',
'sys_id_of_owner3'
];

// Check if requestedBy is one of the owners
if (owners.includes(requestedBy)) {
// Skip approval
answer = false;
} else {
// Trigger approval
answer = true;
}

 

Mark Manders
Tera Patron

You don't have to script. Do a look up to the owner group and then a lookup to the group members where the requested by is the user. If that returns an error, you ask for approval. If not, you skip it.

Ankur Bawiskar
Tera Patron

@Community Alums 

is Requested by a variable on form?

what do you mean by Owner?

share some screenshots.