How to create multiple requested item(sc_req_item) inside single request(sc_request).

praveen1231
Tera Contributor

 

Hi,

I have a requirement, where I have to create multiple requested item(sc_req_item) inside single request(sc_request) using workflow editor in ServiceNow. Please give me your suggestions for how to fix it.

5 REPLIES 5

Community Alums
Not applicable

Hello @praveen1231 

 

Please refer the below solution:

https://www.servicenow.com/community/itsm-forum/how-to-create-multiple-ritm-s-in-single-request/td-p...

 

Please Mark My Response as Correct/Helpful based on Impact

Hi,

My requirement is to work on workflow. Please share me your suggestions for how to fix it.

Community Alums
Not applicable

Take the reference from the below code, rewrite and add that code in workflow run script activity.

var aa = current.variables.check_box;
var bb = current.variables.check_box1;
var cc = current.variables.check_box2;

var mandatoryVars = [aa,bb,cc];

var numTrue = 0;

for (var x = 0; x < mandatoryVars.length; x++) {

	if (mandatoryVars[x] == 'true') {
		numTrue ++;			
	}
}


for(var i = 0 ; i< numTrue ; i ++){
	var gr = new GlideRecord('sc_req_item');
	gr.initialize();
	gr.cat_item = current.cat_item;
	gr.request= current.request;
	gr.insert();
}

 

If my answer helped you, kindly mark it as correct and helpful.