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.

How to write Script Action in Flow Designer

Rohan04
Tera Contributor

I got the script for to create multiple RITM from single request based on MRVS and for that they have written Run script in workflow. I have an requirement of to write the script in flow designer. I am attaching the script which is written in workflow.

Your help will we Appriciated!!!

 

 

 
//get  row count for each MRVS row
var rowCount = current.variables.offboarding_user_list.getRowCount(); //This includes the internal name of the multi row variable set which is "offboarding_user_list"
for (var i = 0; i < rowCount; i++) {
 
//Define variables that will be the same on each RITM.  Add more as required
var req = current.request;
var reqBy = current.variables.requested_by;
 
//Grab each row of variables that will be different on each RITM
var row = current.variables.offboarding_user_list.getRow(i);
var user = row.user;
var nam = row.full_name;
var num = row.employee_number;
var mgr = row.manager;
 
//Crete a RITM for each row
var rec = new GlideRecord ('sc_req_item');
rec.cat_item = 'f06761511b582010e8addd3bdc4bcbfe';//catalog item for offboarding line item  NOTE:  This is REQUIRED to kick off the individual workflow created by each MRVS line item
rec.request = req;
rec.request.requested_for = reqBy;
rec.approval = 'approved';
rec.state = 1;
rec.stage = 'request_approved';
rec.assignment_group = 'ea42046613059200a01f3ea32244b0a0'; //sys_id of the Human Resources group
rec.short_description = "Off-boarding for user "+nam;
rec.description = "Off-board this user: \n - Name: "+nam+"\n - Employee Number: "+num+"\n - Manager: "+mgr;
 
rec.insert();
}
6 REPLIES 6

Rohan04
Tera Contributor

Hello @Sandeep Rajput I have provided the script. could you please help me out of this?

Hey Rohan, I am facing the same issue. 
What did you do to get rid of this error?

Also, did you define variables in Input section or directly in Script?