Set Order guide name on your Request table
Import
·
Dec 24, 2018
·
article
Some time requirement come up to set Order Guide name on Request [sc_request] table. So that user can see a report based on order guide to implement it we need to follow this.
When user submit request before checkout system using two table to store information.
- Shopping Cart [sc_cart]: Information about user cart.
2. Item [sc_cart_item]: Information about Items. If we open item, we will see system also have information about “Order Guide”
To implement it you need to do following
- create a custom field Order Guide (u_order_guide) on “sc_request” table.
- Write a before Insert business rule on Request (sc_request) table
Now check on Advanced option and write following code
var gr = new GlideRecord("sc_cart");
gr.get("user", gs.getUserID());
var gr = new GlideRecord("sc_cart");
gr.addQuery("user", gs.getUserID());
gr.query();
while(gr.next()){
//gs.print(gr.name);
if(gr.name == "DEFAULT"){
var grcart = new GlideRecord("sc_cart_item");
grcart.addQuery('cart',gr.sys_id);
grcart.query();
while(grcart.next()){
if(grcart.order_guide != ""){
current.u_order_guide = grcart.order_guide;
}
}
}
}
You can modify this code as per your need.
View original source
https://www.servicenow.com/community/itsm-articles/set-order-guide-name-on-your-request-table/ta-p/2316778