Pass values from a variable set using a client script

billi_lumley
ServiceNow Employee
ServiceNow Employee

I'm trying to use a variable set to capture basic contact information (requested_for, phone, email) to apply to multiple catalog items. I want to be able to pass these values onto the Requested Item that is created (at least the requested_for). I created the following catalog client script that applies to the variable set, however it is just not working.

When I open the item; the requested_for will default to the person logged in. However, if I change that value to someone else...it is not passed along onto the RITM. Any help is appreciated.

function onChange(control, oldValue, newValue, isLoading) {
if(!isLoading){
var userid = g_user.userName;
var newid = g_form.getValue('requested_for');
var cart = new GlideRecord('sc_cart');
cart.addQuery('user.user_name', userid);
cart.query();
if (cart.next()) {
cart.requested_for = newid;
cart.update();
}
}
}

6 REPLIES 6

I was just having this same problem, and sending notifications to that variable. Simple brilliant...simply brilliant!

-Dale


neetusingh
Giga Guru

I am glad that you get the things working!!!!!!!