Populate Requested For from the Variable

uzzawal
Tera Contributor

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

10 REPLIES 10

randrews
Tera Guru

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();


    }


}