How to query Order guide Order and Pass to RITM Order

Ljone
Giga Contributor

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!

 

find_real_file.png

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

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);

View solution in original post

3 REPLIES 3

Community Alums
Not applicable

Hi @Ljone ,

 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

Kieran Anson
Kilo Patron

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);

Thank you, Kieran. This is exactly what I need!