Notifications

8 views

Description

  • On catalog item view, when I set the requested for variable, my RITM's requested for shows as the user that submitted the catalog item
  • setting my custom requested for variable in catalog item view, does not change it on the RITM when request is submitted

Release or Environment

starting Istanbul

Cause

different type of carts [sc_cart]

Resolution

Usually in this type of custom setup, we have a "requested for" variable along with a catalog client script in a variable set, that is responsible for updating the requested_for field of the user's cart. Example:

            //update the cart                       
var cart = new GlideRecord('sc_cart');
cart.addQuery('user', <sys_id_of_logged_in_user>);
cart.query();
if (cart.next()) {
cart.requested_for = newValue;
cart.update();
}

The issue is that the user might have more than one cart, so a better query would be:

 

            //update the cart                       
var cart = new GlideRecord('sc_cart');
cart.addQuery('name', 'DEFAULT');
cart.addQuery('user', <sys_id_of_logged_in_user>);
cart.query();
if (cart.next()) {
cart.requested_for = newValue;
cart.update();
}

In the query above we would want to obtain the DEFAULT cart only.

Article Information

Last Updated:2019-12-26 17:04:53
Published:2019-12-27