Creating Multiple RITM from one catalog

Abhit
Tera Guru

Hi

I have a requirement, where I have to create multiple request items under a single request using one catalog form.

If the User has selected check-boxes then request item has be created, if does not check any of check-boxes then one RITM has be created.

Requirement is something similar to the Order Guide - New Hire

 

 

find_real_file.png

Thanks,

Kumar

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

you have to first identify here the number of check box have been checked and based on that using for loop you can create the extra RITM on your request. 

 

Adding Sample code here. use the below code on your workflow run script activity,  Give a try. 

 


var dd = current.variables.check_box;
var dd1 = current.variables.check_box1;
var dd2 = current.variables.check_box2;

var mandatoryVars = [dd,dd1,dd2];

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.

View solution in original post

10 REPLIES 10

Harsh Vardhan
Giga Patron

you have to first identify here the number of check box have been checked and based on that using for loop you can create the extra RITM on your request. 

 

Adding Sample code here. use the below code on your workflow run script activity,  Give a try. 

 


var dd = current.variables.check_box;
var dd1 = current.variables.check_box1;
var dd2 = current.variables.check_box2;

var mandatoryVars = [dd,dd1,dd2];

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.

Thank you Harshvardhan šŸ™‚

Hi Harshavardan,

I'm having same requirement but here there is one error i'm facing, that is when i click on two checkbox then also it's creating three RITM's , but it should create two ritm's and workflow not getting attached.

how this can rectify.

 

thanks, 

JRY

Hi @JRY

Did u found a way to solve the creation of 3 ritms?