Monday, December 24, 2018

Set order guide name on your request


Set Order guide name on your request:

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.

1. 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

1. create a custom field Order Guide (u_order_guide) on “sc_request” table.
2. 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.

1 comment: