Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Flow designer script

chandan2212
Tera Contributor

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

TejasSN_LogicX
Tera Contributor

Hi @chandan2212 ,

 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
Mega 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.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Ankur Bawiskar
Tera Patron
Tera Patron

@chandan2212 

is Requested by a variable on form?

what do you mean by Owner?

share some screenshots.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader