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

Anirban Roy
Mega Guru

Hi,

You can add a condition for 'order guide' field.

find_real_file.png

 

Please mark the answer helpful/ correct, if it helped.

 

Regards,

Anirban

Anirban Roy
Mega Guru

Hi @Cory Hitchings ,

Let me know, if using the condition worked.

Please mark the response as helpful and correct answer, if it helped.

 

Regards,

Anirban

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

Thank you very much for the help, this did the trick, all other Requests are working properly now, and the Off-boarding Order Guide is labeling the Short Description properly as well.  Thanks again!