Multiple RITM's for single request based on the MRVS selection

Somasekhar6
Tera Contributor

Hi friends I have a MRVS in catalog items when i submit the request under the same request for Each row i need to get one RITM how it could be possible with Business rule Instead of Record producer.

 

Thanks for your Time and support.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Somasekhar6 

you can use cart API for this

yes you can do this in after insert BR on RITM table for your catalog item

OR
you can use workflow run script for this

Sample BR script

You can enhance it as per your requirement

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

	// Add your code here
	try{
		var mrvsJson = current.variables.mrvsVariableSetName; // give here the mrvs variable set name
		var parsedData = JSON.parse(mrvsJson);
		for(var i=0;i<parsedData.length;i++){

			var cartId = GlideGuid.generate(null);
			var cart = new Cart(cartId);
			//add your requested item to the cart by sys_id of the catalog item
			var item = cart.addItem('0336c34407d0d010540bf2508c1ed096', 1);

			//fill in the variables on the request item form
			cart.setVariable(item, "asset", "00a96c0d3790200044e0bfc8bcbe5dc3");
			cart.setVariable(item, "multiple_choice", "Phoenix");
			var rc = cart.placeOrder();
			gs.info(rc.number);
		}
	}
	catch(ex){
		gs.info(ex);
	}
})(current, previous);

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

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

 

hi @Ankur Bawiskar  i tried with below code but it's not generating the  values at RITM level showing as undefined


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

    // Add your code here

        var bulk = current.variables.sharepoint_online_corp; // name of MRVS
        var sharepointbulk = JSON.parse(bulk).length;
        var cartID = GlideGuid.generate(null);
        var cart = new Cart(cartID);
        for (i = 0; i < sharepointbulk; i++) {
        
var item = cart.addItem('927659851b297d10309d21fcbc4bcb13', 1);
                    cart.setVariable(item, "requested_for", current.variables.requested_for);
                    cart.setVariable(item, "requestor_contact_number", current.variables.requestor_contact_number);
                    cart.setVariable(item, "requestor_for_location", current.variables.requestor_for_location);
                    cart.setVariable(item, "project_name", current.variables.project_name);
                    cart.setVariable(item, "project_end_date", current.variables.project_end_date);
                    cart.setVariable(item, "manager_name_id", current.variables.manager_name_id);
                    cart.setVariable(item, "raq_client_name", current.variables.raq_client_name);
                    cart.setVariable(item, "vertical_name", current.variables.vertical_name);
                    cart.setVariable(item, "single_bulk", current.variables.single_bulk1);
                    cart.setVariable(item, "spo_location", current.variables.bulk.getRow(i).spo_location1);
                    cart.setVariable(item, "tenant_url", current.variables.bulk.getRow(i).tenant_url1);
                    cart.setVariable(item, "quota_space", current.variables.bulk.getRow(i).quota_space1);
                    cart.setVariable(item, "site_collection_name", current.variables.bulk.getRow(i).site_collection_name1);
                    cart.setVariable(item, "site_templates", current.variables.bulk.getRow(i).site_template);
                    cart.setVariable(item, "template_name", current.variables.bulk.getRow(i).template_name1);
                    cart.setVariable(item, "business_unit", current.variables.bulk.getRow(i).business_unit1);
                    cart.setVariable(item, "team_dl", current.variables.bulk.getRow(i).team_dl_email);
                    cart.setVariable(item, "service_line", current.variables.bulk.getRow(i).service_line1);
                    cart.setVariable(item, "purpose", current.variables.bulk.getRow(i).purpose1);
                    cart.setVariable(item, "data_classification_classification_standard", current.variables.bulk.getRow(i).data_classification_classification_standards);
                    cart.setVariable(item, "does_the_server_hold_information_that_has_contractual_legal_confidential_restrictions", current.variables.bulk.getRow(i).does_the_server_hold_information_that_has_contractual_legal_confidential_restriction1);
                    cart.setVariable(item, "business_justification", current.variables.business_justification);
            cart.setVariable(item, "attach_cs_approval_and_the_email", attachmentsysid);
}

  var rc = cart.placeOrder();
        var reqRecord = new GlideRecord('sc_request');
        reqRecord.get(rc.getUniqueValue());
        reqRecord.requested_for = gs.getUserID();
        reqRecord.update();

})(current, previous);

correct where i went wrong

Vishal Birajdar
Giga Sage

Hi @Somasekhar6 

 

Below link might help ....!!

I have achieved this using "List collector" ..you can use same logic using "MRVS"

 

https://www.servicenow.com/community/developer-forum/create-multiple-ritm-under-single-request-depen...

 

 

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates