Issue with Accessing Variable Value in Variable Set

Lisa Goldman
Kilo Sage

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

 

LisaGoldman_0-1752767284855.png

 

 

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);
    }

}

   

28 REPLIES 28

do you see any error in the browser console?

or any error like this?

ChaitanyaILCR_0-1752774353133.png

 

 

you can do this

open the variable and set lookup value field to Name

ChaitanyaILCR_1-1752774405121.png

 

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

 

 

@Chaitanya ILCR 

 

After changing the look up value to name, it is displaying the sys_id instead on the application name.

 

LisaGoldman_0-1752777776192.png

 

Hi @Lisa Goldman ,

Existing records will be shown like that

 

Create new ones and try to alert the value

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!

@Bhimashankar H 

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);
	}
}