Set Request short description for Order Guide

Cory Hitchings
Giga Guru

Hi all, 

Was wondering if anyone could help me get the Short Description set on a Request when placing an order from an Order Guide.  Currently, when submitted, it shows all Catalog Items on the Short Description which doesn't do well for reporting.  What I did was set a Business Rule on the sc_request table, however it over rides all Requests.  

Here is the code I am using, and hoping there is a way to isolate this Business Rule to only run if it's the Order Guide being used. 

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

var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.query();

if (gr.next()) {
       current.short_description = 'Termination' + ' - ' + gr.variables.person_leaving.getDisplayValue() + ' - ' + gr.variables.end_date.getDisplayValue();
	   current.requested_for = gr.variables.requested_for;
	   current.description = 'Please refer to the Termination Checklist Knolwedge Article: ;
}
	
})(current, previous);

Anyone out there have any ideas?  As always, I appreciate your help! 

Thank you

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

there is this field Order Guide on RITM which would help you identify whether this RITM got created from order guide or not

you can use that column

please find updated script below for your BR

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

var gr = new GlideRecord('sc_req_item');
gr.addQuery('request', current.sys_id);
gr.addQuery('order_guide', '!=', ''); // if order guide is not empty check
gr.query();

if (gr.next()) {
       current.short_description = 'Termination' + ' - ' + gr.variables.person_leaving.getDisplayValue() + ' - ' + gr.variables.end_date.getDisplayValue();
       current.requested_for = gr.variables.requested_for;
       current.description = 'Please refer to the Termination Checklist Knolwedge Article: ;
}
    
})(current, previous);

find_real_file.png

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

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

View solution in original post

7 REPLIES 7

You are welcome

Regards
Ankur

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

Megha Padale
Giga Guru

Hi,

There is a feature that automatically captures the order guide and writes it to a field called Order guide on the requested item without the customer having to configure anything. 

In filter put the condition as order guide is not empty and copy the query to business rule.

gr.addQuery('order_guideISNOTEMPTY')// check order guide is not empty.

If my answer helped you in any way, mark answer as helpful and correct.

Thanks and regards,

Megha.

 

Ankur Bawiskar
Tera Patron
Tera Patron

@Cory Hitchings 

Hope you are doing good.

Any update on this thread? Do let us know if you are stuck.

Regards
Ankur

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