Create request item from multi row variable set

Sowmya20
Tera Contributor

Hi,

I've got a requirement to created as many RITMs as there are rows in the multi-row variable set. 

I'm doing this using workflow.

find_real_file.png

User can request mulitiple as in one request.

It should create multiple RITM for each row and each RITM goes for approval

Can anyone help me on this.

Thanks,

Sowmya

 

6 REPLIES 6

@sowmya 

Hope you are doing good.

Did my reply answer your question?

If my response helped you please mark it correct to close the question so that it benefits future readers as well.

Regards
Ankur

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

Sowmya20
Tera Contributor

I'm refering this article https://community.servicenow.com/community?id=community_article&sys_id=ba4d5295db18a810fa192183ca9619a7

I'm adding two row but it's creating 3 RITM 

Can anyone suggest on this.

below is the script:

var rowCount = current.variables.authorization_limit1.getRowCount(); //This includes the internal name of the multi row variable set which is "authorization_limit1"
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.authorization_limit1.getRow(i);
var user = row.emp_name;
var id = row.emp_id;
var ledg = row.ledg_name;
var code = row.cur_code;
var lmt=row.authn_limit;

//Crete a RITM for each row
var rec = new GlideRecord ('sc_req_item');
rec.cat_item = 'd1f06caf1b1b9c14419998ac0a4bcbdd';//catalog item for gl authorization 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 = 'requested';
rec.state = 1;
rec.stage = 'requested';
//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();
}