The CreatorCon Call for Content is officially open! Get started here.

How to create multiple TASKs for 1 RITM based on desired quantity entered

Joel KP
Tera Contributor

Hello community, 

Is it possible to create multiple TASKs from 1 RITM based on the desired quantity entered in the Catalog Item form? Or perhaps have multiple RITMS>TASKs based on quantity entered?

 

All TASKs would need to be created at the same time.

 

The quantity input would be a "Select Box" variable, but of course open to any suggestions.

 

TYIA,

Joel

2 REPLIES 2

Bert_c1
Kilo Patron

The sc_req_item table has a 'quantity' field, defined as integer. A business rule defined on that table, with logic as follows can create sc_task records

 

 

 

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var scTask = new GlideRecord('sc_task');
	for (i = 0; i < current.quantity; i++) {
		scTask.initialize();
		scTask.request_item = current.sys_id;
		scTask.short_description = "This is task " + (i+1) + " of " + current.quantity + " for " + current.number;
		// see additional sc_task fields as desired
		scTask.insert();
	}
	
})(current, previous);

 

 

 

It is possible to have multiple sc_task records associated with a sc_req_item record.

Joan9
Tera Contributor

Is there a maximum number that can be generated simultaneously?

thanks