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.

HR Virtual Agent Restrict Topic Based on User Record Conditions

leahdany
Giga Guru

I have a topic that I am trying to restrict from users whose location.country is not US or those in a certain business unit. I have tried using the script in the Advanced Properties within the VA topic to no avail. I have tried using the user criteria method found here. I have also tried this solution, and writing my own script. None of it works.

 

Here's the script I used.

(function execute() {
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', gs.getUserID());
user.query();

if(user.next()){
    var country = user.location.country.toString();
    var bu = user.cost_center.u_business_unit.toString();
}
if(country == 'US') {
    return true;
}
else if(bu == '<bu sys id>'){ 
    return true;
}
    else{
    return false;
    }
})()
1 ACCEPTED SOLUTION

leahdany
Giga Guru

I got it to work with my script by logging off and back on.

View solution in original post

1 REPLY 1

leahdany
Giga Guru

I got it to work with my script by logging off and back on.