Flow Designer - How to create a run Script inside of flow

Wendy Peterson
Giga Guru

Currently in our workflows we have the following type of script

current.configuration_item = getCI();
current.u_security_role = getCI();
current.u_application = current.cat_item.u_application;

function getCI()
{
var ci = new GlideRecord('u_cmdb_ci_appl_sec_roles');
ci.addQuery('name',current.variables.role);
ci.query();
if(ci.next())
{
return ci.sys_id;
}
} 

 - This gets the "CI" based on a Role Variable and update the CI field on the RITM. We use the field for approvals etc. I for the life of me can't figure out how to replicate this process in Flow Designer. I have the AD groups hard coded on that CI record and right now we have 2k CI's with AD fields. So i want to be able to use those. Any ideas? TIA

2 REPLIES 2

ricker
Tera Guru

Wendy,

Are you sure that script does what you want it to do?  It sets both the configuration_item and u_security_role fields to the same value, the sys_id of the last (pretty sure last) record the query finds.

 

Not sure what that script is supposed to do but I think you want to do a record lookup then use data from that record for something?  No need to run a script for that you can use the Lookup Record or Lookup Records actions and access the record values from data pills.

 

@Uncle Rob aka The Duke has a series of YouTube videos on Flow Designer you should definitely check out.

Abhit
Tera Guru

Hello @Wendy Peterson 

 

Do a lookup record on the "u_cmdb_ci_appl_sec_roles" and use an update record action to update the configuration it and roles.

See the screenshots 

Abhit_0-1673074355104.png

In the below step select the catalog item and select the variables which you will using in the flow

Abhit_1-1673074429991.png

 Next: DO a lookup on the table and build the condition

Abhit_2-1673074467654.png

Next: Update the lookup records by making use of add fields 

Abhit_3-1673074512170.png

 



Let me know if you need some more details.

 

Abhit