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

GlideFather
Tera Patron

@Lisa Goldman it is nothing to lose, please try to change the UI Type from Desktop to All and retry...

 

and eventually "Applies on Catalog Item view" to true.

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hi @GlideFather ,

I had already tried changing the UI Type to "All" before reaching out to the community for help, but unfortunately, it's still not working after the change.  Thank you

@Lisa Goldman And also the catalog view to true?

 

you can try the alert on the first line:

alert(“script triggered ok”);

 

to see if it is not blocked by your browser as a pop-up.

 

or use g_form.addInfoMessage(“test”);

 

sorry i am on my mobile phone so the quotes might not be correct…

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Chaitanya ILCR
Kilo Patron

Hi @Lisa Goldman ,

is business_application a reference field?

 

getDisplayValue doesn't work in this case (it returns the current record's displayValue)

you have to use 

g_form.getDisplayBox('business_application').value

 

or GlideAjax or getReference or GlideRecord

I would say go with GlideAjax to check the value (the other 3 getDisplayBox and getReference and GlideRecord API won't work in the portal)

 

 

 

if not against name you can compare with sysId (of Maximo) in the if condition

 

 

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') {
        alert(applicationName);
    }

}

 

also set the UI to ALL

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya