will a record insert in sc_cart

Deepthi13
Tera Expert

hi Team,

i have a order guide in mobile view. when ever I request a new thing in order guide will it insert a record in sc_cart every time? 

1 ACCEPTED SOLUTION

sc_cart will be only a single entry and it just stores the owner name of the cart ie the requester. Every time you add an item to cart, a new entry is added in the sc_cart_item. Once you order or submit the cart, the entry added in the cart is removed from the sc_cart_item table and is converted to a request and sc_req_item entries. So sc_cart always remains the same but requests get added or removed from the sc_cart_item table.

 

View solution in original post

38 REPLIES 38

sc_cart will be only a single entry and it just stores the owner name of the cart ie the requester. Every time you add an item to cart, a new entry is added in the sc_cart_item. Once you order or submit the cart, the entry added in the cart is removed from the sc_cart_item table and is converted to a request and sc_req_item entries. So sc_cart always remains the same but requests get added or removed from the sc_cart_item table.

 

So if that is the case. i am writting a bR to populate order guide name on request table.

But the filed is not updating. I am getting result in back ground script but in BR its not getting updated.

(function executeRule(current, previous /*null when async*/) {

// Add your code here
var gr = new GlideRecord("sc_cart");
gr.addQuery("user", gs.getUserID());
gr.query();
while(gr.next()){
gs.log("@@@$$$"+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.getDisplayValue();
gs.log("@@@$$$"+grcart.order_guide);
}
}
}
}})(current, previous);

Is this a before business rule? What is the field type of u_order_guide?

it is reference field to order guide table.. (i can make it string also its not a problem).

this br is on request table before insert/update. 

i am doing in my demo dev only can u see there once dev68174

admin

Admin@123

 

Sure checking