Populate sc_request Description from Order Guide

Brian Hofmeiste
Kilo Guru

I searched the forums and found quite a few people asking this question but I couldn't get an answer that worked.    We are using an order guide for employee onboarding so I want to see the description of the REQ populated with "Onboarding: John Doe". 

 

Since the request is created after the order guide is submitted I can't do this with a client script.  I guess I could create a business rule or embed this in the sc_request default workflow but how would I know if that particular request originated from an order guide?  And how would I get the new employees information from the order guide? 

 

Thanks all,

Brian

5 REPLIES 5

Saurabh Gupta
Kilo Patron
Kilo Patron

Hi,
You can write an onAfter Business Rule on RITM table as below -

 

(function executeRule(current, previous /*null when async*/) {
	//Add your code here
	var req = new GlideRecord('sc_request');
	req.addQuery('sys_id',current.request);
	req.query();
	if (req.next()){
		// standalone catalaog item
		if (current.order_guide.nil()){
			req.short_description = current.cat_item.name;
			req.description = current.cat_item.short_description;	
		}
		else {
			// Order Guide
			req.short_description = current.order_guide.name;
			req.description = current.order_guide.short_description;
		}
		req.setWorkflow(false);
		req.update();
	}
})(current, previous);

 

 


Thanks and Regards,

Saurabh Gupta

Hi Saurabh,

 

Thank you for your response.  The problem with this methodology is that it will run for all the requested items in the order guide and each requested item will try to overwrite that same description in their parent request.  Our order guide generates 7 different request items.  Is there a way to make this run only once per request?

 

Brian

Hi @Brian Hofmeiste ,

 

In the condition builder put a condition that request.short_description is EMPTY.

 

 


Thanks and Regards,

Saurabh Gupta

2.png1.png3.pngI'm having trouble getting a simple business rule to work - I have to be missing something simple.  Before adding your suggested code I am doing a simple setup and the RITM is not receiving the test information.  Am I missing something simple here?  Here are screenshots.