Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

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

Did you also catch the error with an 's' missing in business_application in the getReference line? Good chance if you didn't its evaluating the if statement as false since ref will be null.

Sorry for the mistakes I was getting a phone call as I was writing that response and was rushed.

@John Gilmore 

No need to apologize. Thank you for continuing to provide assistance. I did correct the misspelling on the business application, but it still hasn't triggered.

Lisa Goldman
Kilo Sage

We sincerely thank everyone for their help and input. At this point, we’ll proceed with hardcoding the sys_id to ensure the functionality works, as we have a project deadline to meet.

@Lisa Goldman 
Understandable.

TIP: if you want to avoid hard-coding, call a property in your catalog client script (gs.getProperty() is not supported for client side so a GlideAjax call is needed) but then you could update the condition by changing the property's value without touching the code in the future...

_____
This reply is 100 % GlideFather and 0 % AI