
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 03:02 AM
Good morning all,
We are building a new starter catalogue request and need to populate a contact email variable based on the location of the user. Within a variable set, we have a reference field, starter_location, which is filtered to show just 4 specific locations, say north, south, east and west. If the new starters location is north, we want to automatically populate a single line text field, starter_email, with a defined email address. Note this email is not part of the user record, otherwise we could have referenced it from the sys_user table.
I have the following on change client script, but its not working. Is there anything obvious wrong with this approach please:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('starter_email,"");
}
var loc = g_form.getValue('starter_location');
if(loc =='North'){
g_from.setValue('starter_email',"north@xyz.com");
}
else if(loc =='South'){
g_from.setValue('starter_email',"south@xyz.com");
}
else if(loc =='East'){
g_from.setValue('starter_email',"east@xyz.com");
}
else if(loc =='West'){
g_from.setValue('starter_email',"west@xyz.com");
}
return;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 06:56 AM
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var val=g_form.getDisplayBox('cmdb_ci').value;
if(val=='All')
{
alert('inside');
g_form.setValue('specific_transaction','1232131231');
}
//Type appropriate comment here, and begin script below
}
I wrote this and it was able to set the value in the specific_transaction field. Can you check if the field in which you are setting the value has the correct data type.
Regards,
Gundeep Singh

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 05:12 AM
Ajay,
No joy, removing the line doesnt make a difference. I have double checked the field and it is definately on change of Lcation Field. Unable to provide actual screenshots due to nature of data we deal with

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 05:22 AM
If it's personal dev instance then you can provide me the credentials on ghadmodeajay@gmail.com.
I will try to resolve issue issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 05:33 AM
Thanks for the offer Ajay but unfortunately this is in an operational instance. It seems to be recognizing the location display name, in that the current code below will pop up with the selected location, but for whatever reason its no able to match this display value with the specified value in the client script. I have tried double quote (if Loc =="North") but that doesnt seem to work either.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == ''){
g_form.setValue('starters_mailbox',"");
var loc = g_form.getDisplayBox('starters_location').value;
if(loc =='North'){
g_from.setValue('starters_mailbox',"north@xyz.com");
}
else if(loc =='South'){
g_from.setValue('starters_mailbox',"south@xyz.com");
}
else if(loc =='East'){
g_from.setValue('starters_mailbox',"east@xyz.com");
}
else if(loc =='West'){
g_from.setValue('starters_mailbox',"west@xyz.com");
}
return;
}
alert(g_form.getDisplayBox('starters_location').value);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 05:53 AM
Usually when I see something like this and can't explain why it's not working, it turns out that the thing I thought would be a string is actually being returned as an object. So just for laughs, try adding this in for diagnostic purposes:
alert(g_form.getDisplayBox('starters_location').value+' type: '+typeof(g_form.getDisplayBox('starters_location').value));
But before you go to that much trouble, make sure the problem isn't that you've used "g_from" where you meant "g_form". Because if you copied and pasted this directly from your script, that's going to cause you trouble here:
if(loc =='North'){
g_from.setValue('starters_mailbox',"north@xyz.com");
}
else if(loc =='South'){
g_from.setValue('starters_mailbox',"south@xyz.com");
}
else if(loc =='East'){
g_from.setValue('starters_mailbox',"east@xyz.com");
}
else if(loc =='West'){
g_from.setValue('starters_mailbox',"west@xyz.com");
}
return;
Take it from a typlexic who does stuff like that all the time. I get burned by this kind of thing a lot.