Populate Requested For from the Variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 05:38 AM
Hello Experts,
I have a requirement to populate the "Requested for" field on the shopping cart page from the catalog item "Requester" Variable.
OOB Requested For populates the value of login user but on checkout page I want to populate this value from the requester variable of the catalog item.
In the attached screenshot I am requesting for a catalog Item "Document Creation" which has a variable Requester and value is XYZ, so I want to populate same value in the Requested For field on this shopping cart page.
Any Suggestions ?
Regards,
Uzzawal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-13-2017 11:07 AM
Sure create an onchange script on the item <or better yet in a standard variable set> that is triggered when the requested_for changes... then include this script..
function onChange(control, oldValue, newValue, isLoading)
{
if (newValue)
{
// Update Cart with requested_for
var gr = new GlideRecord('sc_cart');
gr.addQuery('user', g_user.userID);
gr.query();
gr.next();
gr.requested_for = newValue;
gr.update();
}
}