
- 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 03:26 AM
Hi Cirrus,
If the values for North, South, East, West location are being stored in some table then you can pass sys_ids instead of lables for the location while setting.
For instance,
var loc = g_form.getValue('starter_location');
if(loc =='North'){
g_from.setValue('starter_email',"north@xyz.com");
}
would be
var loc = g_form.getValue('starter_location');
if(loc =='North'){
g_from.setValue('starter_email',"sys_id_of_north");
}
Thanks,
Jaspal Singh
Hit Helpful or Correct on the impact of response.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 03:47 AM
Jaspal,
the values for N,S,E,W are in the locations table. However, I am not sure what you are saying here. Surely your code would just set the value to "North" rather than north@xyz.com (note the email is not defined in any table/field, it is just defined in the script)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 03:44 AM
Hi,
Try below code,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
g_form.setValue('starter_email,"");
}
var loc = g_form.getDisplayBox('starter_location').value;
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;
}
Mark If Correct/Helpful.
Regards,
Ajay.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 03:52 AM
Ajay,
This results in the locations table popup constantly refreshing on selection!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2019 04:12 AM
Hi Cirrus,
Cross check on change of which field you are writing onChange client script.
Also, try removing/commenting the g_form.setValue('starter_email',"");
Can you provide screenshots..?
Regards,
Ajay