how to write script into flow design

BanuMahalakshmi
Tera Contributor

Hi, My requirements are if request type is A, assign it to admin assignment group. if it is B, then the assignment group export group. how to write this script into Flow design. Thanks.

5 REPLIES 5

j0unss
Tera Expert

You don't need to write a script in Flow Designer for that, just use if - then.

j0unss_0-1720594488447.png



-j0unss

Mark Manders
Mega Patron

It really depends on how your flow is setup, but if it's without any logic/variables and a simple 'set assignment group', you could do it like this (but also check out on AWA/assignment rules).

var assGrp = '';
var reqType = fd_data.trigger.current.your_field; // find the request type field on your trigger or other step
if(reqType = 'A'){ // check if you need to set values or sys id's or anything else, depending on how your variable reqType is set
    assGrp = 'sys_id_of_your_group';
} else if (reqType = 'B'){
    assGrp = 'sys_id_of_your_other_group';
}
return assGrp;

 

 


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

Sandeep Rajput
Tera Patron
Tera Patron

@BanuMahalakshmi If this is just about the request assignment on the basis of the request type then you can do it via the Assignment rule https://docs.servicenow.com/bundle/washingtondc-platform-administration/page/administer/task-table/c...

 

If you still wish to do it via the flow designer then you can use the if block in the flow designer to check the request type and use the update record action to update the assignment group.

Sanjana8
Kilo Guru

Hi @BanuMahalakshmi 

 

You can simply create a action in flow designer

  1. Create a input variable

Sanjana8_0-1720599814239.png

Then clicking on that  blue plus icon you can add script functionality

Sanjana8_2-1720599977680.png

 

Sanjana8_3-1720599991325.png

Then just drag the input variable in the script and write a simple if else script as per the requirement.

Sanjana8_4-1720600144515.png

At the end create a output variable which should be passed (optional)

And add that action to a flow.

 

Please mark helpful if you accept the solution.

 

Thanks

Sanjana Adsul