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.

create multiple RITM

Sneha39
Mega Guru

How can i create multple ritm ( simple way) from workflow .

 

 

8 REPLIES 8

Vishal Khandve
Kilo Sage

Hi Sneha,

From workflow run script activity you can create mulitple RITM like parent-child RITM.

I tried to create second RITM from first RITMs Worflow.

run script code:

var secure_area = 'd901fec4dbee4cd4f6e1dd30cf9619c3'; //sys_id for the 2nd catalog item(RITM)


//create a new item in the request
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, secure_area, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);

//find the item and update itsvariables
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item',secure_area);
grReqItem.addQuery('parent','');
grReqItem.query();
if(grReqItem.next()) {

grReqItem.variables.company = 'Test';
grReqItem.variables.mobile = '12345';
grReqItem.parent = current.sys_id;
grReqItem.update();

}

 

Thanks,

Vishal Khandve

Hi,

I want to create two RITM from one catalog item only ( through workflow) and i want to set different location ( for RITM1 = ISM, FOR RITM2 = KRT)

how can i achieve this. 

try this one sneha. Set location variable to ISM from 1st catalog item and in the script set location to other.

 

var secure_area = 'd901fec4dbee4cd4f6e1dd30cf9619c3'; //sys_id for the same catalog item


//create a new item in the request
var reqHelper = new GlideappCalculationHelper();
reqHelper.addItemToExistingRequest(current.request, secure_area, 1); // 1 is the qty
reqHelper.rebalanceRequest(current.request);

//find the item and update itsvariables
var grReqItem = new GlideRecord('sc_req_item');
grReqItem.addQuery('request', current.request);
grReqItem.addQuery('cat_item',secure_area);
grReqItem.addQuery('parent','');
grReqItem.query();
if(grReqItem.next()) {

grReqItem.variables.location= 'KRT';
grReqItem.parent = current.sys_id;
grReqItem.update();

}

 

Thanks,

Vishal Khandve