Create multiple RITMs based on list collector variable

AnilM99
Tera Expert

Hi Team,

I have a requirement for create multiple RITMS using List Collector variable, the variables should copy with in the RITM.

 

Help me on the same.

10 REPLIES 10

Hi Sumanth,

Add run script activity need to be placed on Request workflow?

Sindhu Nalluri

Ankur Bawiskar
Tera Patron
Tera Patron

Hi Anil,

update as this and it would set requested_for on RITM with each of the respective user

var opt = current.variables.select_user.toString().split(',');
for (i=0; i < opt.length; i++) {
    createRequest(opt[i]); // pass the value here
}

function createRequest(user) {

    var cartId = GlideGuid.generate(null);
    var cart = new Cart(cartId);
    var item = cart.addItem('060f3afa3731300054b6a3549dbe5d3e', 1);

    cart.setVariable(item, 'employee_type', current.variables.employee_type);
    cart.setVariable(item, 'slt_number', current.variables.slt_number);
    cart.setVariable(item, 'sales_force', current.variables.sales_force);
    cart.setVariable(item, 'requestor', current.variables.requestor);
    cart.setVariable(item, 'email', current.variables.email);
    cart.setVariable(item, 'location', current.variables.location);
    cart.setVariable(item, 'select_computer', current.variables.select_computer);

    var rc = cart.placeOrder();

    var ritm = new GlideRecord('sc_req_item');
    if(ritm.get('request', rc.sys_id)){
        ritm.requested_for = user;
        ritm.update();
    }

}

 

Regards
Ankur

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

@Anil 

Hope you are doing good.

Did my reply answer your question?

If my response helped please close the thread by marking appropriate response as correct so that it benefits future readers.

Regards
Ankur

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

@Anil 

Thank you for marking my response as helpful.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards
Ankur

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

Hi Ankur,

 

This is working in my personal instance but not in office instance,

The problem is I selected 2 users in list collector but 20+ RITMS created 

Please help me on the same,