onChange Client Script not working on Form.

jasonjones
Giga Contributor

Creating a form with an independent Application and I'm getting the following error.find_real_file.png

I have the following onChange client script.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

//Type appropriate comment here, and begin script below...
var gr = new GlideRecord('sys_user');

if (gr.get(newValue)) {
g_form.setValue('u_email_address', gr.email);
// g_form.setValue('u_sec_email_address', gr.u_email);
}
}

I have also gone and created under the sys_properties.list  a new 

find_real_file.png

What am I missing?  Obviously, I have other forms that work when the application is Global.  I have also toggled the "Isolate script" without success. 

find_real_file.png

Thanks.

Jason

1 ACCEPTED SOLUTION

Try this

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var requestedfor = g_form.getReference('caller_id', getDetails); //Callback

function getDetails(requestedfor) {
if (requestedfor)
g_form.setValue('u_email_address', requestedfor.email);
g_form.setValue('u_x_ucid', requestedfor.u_ucid);
}



//Type appropriate comment here, and begin script below...
//var gr = new GlideRecord('sys_user');

//if (gr.get(newValue)) {
// g_form.setValue('u_email_address', gr.email);
// g_form.setValue('u_sec_email_address', gr.u_email);

}

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

View solution in original post

17 REPLIES 17

Sorry. It didn't pull any fields back. 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var requestedfor = g_form.getReference('caller_id', getDetails); //Callback

function getDetails(requestedfor) {
if (requestedfor)
g_form.setValue('u_email_address', requestedfor.email);
g_form.setValue('u_x_ucid', requestedfor.u_ucid);
}



//Type appropriate comment here, and begin script below...
//var gr = new GlideRecord('sys_user');

//if (gr.get(newValue)) {
// g_form.setValue('u_email_address', gr.email);
// g_form.setValue('u_sec_email_address', gr.u_email);

}

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}

var callerid = g_form.getReference('caller_id', getDetails); //Callback

function getDetails(callerid) {
//if (callerid)
g_form.setValue('u_email_address', callerid.email);
g_form.setValue('u_x_ucid', callerid.u_ucid);
}

}

Please mark my response as correct and helpful if it helped solved your question.
-Thanks

Prateek,

Thanks for the help.  That didn't work either.  I wonder if the top area looks correct.

find_real_file.png

I see the filed name as Contact.

Is that the same caller_id you are using in the script??


Please mark my response as correct and helpful if it helped solved your question.
-Thanks

As far as the form goes, it is u_contact.