Issue with Accessing Variable Value in Variable Set
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 08:48 AM
Hello,
I need help retrieving the value from a Variable Set.
Here's what I’ve tried so far, but it’s not triggering the alert. Thank you
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var applicationName = g_form.getDisplayValue('business_application');
if (applicationName === 'Maximo') {
alert(applicationName);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 10:50 AM
do you see any error in the browser console?
or any error like this?
you can do this
open the variable and set lookup value field to Name
and update the script as
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
// return;
}
alert(newValue);
if (newValue == 'Maximo') {
alert(newValue);
//add logic to hide
//g_form.setDisplay('YourvariableNamehere',false)
}
}
and submit a new request and check
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 11:43 AM
After changing the look up value to name, it is displaying the sys_id instead on the application name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 11:55 AM
Hi @Lisa Goldman ,
Existing records will be shown like that
Create new ones and try to alert the value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 10:24 AM
Hi @Lisa Goldman ,
If I got your question correct, you can use below code snippet,
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
var applicationName = g_form.getValue('business_application');
alert(applicationName);
if (applicationName === 'Maximo') {
g_form.setDisplay('variable_name', false); //replae variable_name with variable which you want to hide.
}
}
Thanks,
Bhimashankar H
-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful'. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2025 10:57 AM
The issue is that it’s retrieving the sys_id instead of the application's display name. However, since the current code is functioning as intended, we’ll go ahead and proceed with it.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return; // Prevents script from running during form load or if no value is selected
}
alert(newValue);
if (newValue === 'bc29e258db2f9c1005fddbd4ce96195b') { //Maximo
g_form.setDisplay('service_type', false);
} else {
g_form.setDisplay('service_type', true);
}
}