- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 12:21 AM
Hi All,
We have an Order guide with several catalog items, we need to pass the Order(At this position) set in Rule base to RITM order field. We use this to control sorting.
Please help me with the BR script needed. Thank you in advance!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 12:41 AM
Hi,
You can use an before insert business rule with a condition to only run when the order guide field is not empty. This BR runs on the sc_req_item table.
(function executeRule(current, previous /*null when async*/) {
//Perform a lookup on rule base table
var ruleBaseGr = new GlideRecord('sc_cat_item_guide_items');
ruleBaseGr.addQuery('guide' , current.getValue('order_guide'));
ruleBaseGr.addQuery('item' , current.getValue('cat_item'));
ruleBaseGr.setLimit(1);
ruleBaseGr.query();
if(ruleBaseGr.next()){
current.setValue('order' , ruleBaseGr.getValue('order'));
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 12:37 AM
Hi
There is a really nice sncguru solution that allows you to pretty easily populate the order guide id on the request table.
http://www.servicenowguru.com/system-definition/populate-order-guide-request-ticket/
Use this as a reference and try to call the "Order" value.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 12:41 AM
Hi,
You can use an before insert business rule with a condition to only run when the order guide field is not empty. This BR runs on the sc_req_item table.
(function executeRule(current, previous /*null when async*/) {
//Perform a lookup on rule base table
var ruleBaseGr = new GlideRecord('sc_cat_item_guide_items');
ruleBaseGr.addQuery('guide' , current.getValue('order_guide'));
ruleBaseGr.addQuery('item' , current.getValue('cat_item'));
ruleBaseGr.setLimit(1);
ruleBaseGr.query();
if(ruleBaseGr.next()){
current.setValue('order' , ruleBaseGr.getValue('order'));
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 01:41 AM
Thank you, Kieran. This is exactly what I need!