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.

Getting error vaVars not defined in VA Script

Community Alums
Not applicable

Hi All, 
I am writing this script,

(function execute() {

    // Fix as part of STRY0077174

    if (gs.nil(vaContext.liveagent_application)) {

        // Split user criteria string to get array output

        var userCriteria = gs.getProperty('va.hr.user_criteria').split(',');

        // returns true if at least one user criteria matches to the current logged in user

        var userMatches = sn_uc.UserCriteriaLoader.userMatches(gs.getUserID(), userCriteria);

 

        if ((userMatches) && (vaVars.LiveAgent_BusinessService != 'impact'))

            return true;

    }

    else if ((vaContext.liveagent_application == 'hr')&& (vaVars.LiveAgent_BusinessService != 'impact'))

        return true;

})()

And when the topic is running in the logs I can see the Error as: vaVars is not defined, but in topic in variables I can see the LiveAgent_BusinessService.
Please assist.
Thanks

 

 

3 REPLIES 3

Victor Guzman
Tera Contributor

Hello @Community Alums , did you find any solution for this situation or a Workaround? 

I am facing the same. situation. Additionally, when I print it in a text field in the topic flow, the vaVars variable has data, it looks the problem is when we try to use it in the conditions of the topic.

Kavita_Bhojane
Tera Guru

Hi @Community Alums,

 

Have you added your variable under Script Variables? If not please add the same.

Let me know what happens.


If this post helps you in any way, please mark it helpful 👍 and accept the solution.

 

Thanks,

Kavita Bhojane

 

Amit Gujarathi
Giga Sage
Giga Sage

HI @Community Alums ,
I trust you are doing great.
As a safeguard, you can assign a default value to vaVars if it's not defined. For example:

var vaVars = vaVars || {}; // This sets vaVars to an empty object if it's not already defined

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi