virtual agent topics should be restricted based on user criteria

dande Anusha
Tera Contributor

Hi 

 

Few Virtual agent topics should be restricted based on user criteria. we do have already some script include as well to validate this. I have added the same script in virtual agent topic script under properties to make it visible based on the criteria but it is not working as expected. 

Can anyone please go through below script and suggest if anything wrongs

 

var gpid = vaInputs.user;

var check = new global.testUtils().checkCatalogAccess(gs.getProperty('propertyname'), gpid);

if(check == true)

return true;

else

return false;

 

 

The code in the checkCatalogAccess is :

checkCatalogAccess: function(catalog, gpid) {

var userCriterias = [];
var grcheck = new GlideRecord('sc_cat_item_user_criteria_mtom');
grcheck.addEncodedQuery('sc_cat_item.sys_id=' + catalog);
grcheck.query();
while (grcheck.next()) {
userCriterias.push(grcheck.user_criteria.toString());
}

var userMatches = sn_uc.UserCriteriaLoader.userMatches(gpid, userCriterias);
return userMatches;
},

 

Thanks,

Anusha

2 REPLIES 2

Community Alums
Not applicable

Hi @dande Anusha  ,

Navigate to the Properties tab of the conversation, selected 'Script' next to the Condition label and clicked the Add Script box.

SandeepDutta_1-1671545376668.png

 

In the box that pops up I added the following script (updating the <insertSysID> with the sys_id from the [user_criteria] table.

(function execute() {
var UCSysid = '<insertSysID>'; //sysid of the user criteria required

//Get all user criteria sys_ids
var userCriteria = SNC.UserCriteriaLoader.getAllUserCriteria();

//If user is added to UCSysid variable User Criteria, set to true
if (userCriteria.indexOf(UCSysid) > -1) {
return true;
}
else{
return false;
}
})()

 

Hi @Community Alums 

 

Here, we need to check for the record producers visibility based on user criteria. So, we need to check the catalog item/record producer and need to push the users based on user criteria. I used below script for this but it is not working

 

var userCriterias = [];
var grcheck = new GlideRecord('sc_cat_item_user_criteria_mtom');
grcheck.addEncodedQuery('sc_cat_item.sys_id=' + catalog);
grcheck.query();
while (grcheck.next()) {
userCriterias.push(grcheck.user_criteria.toString());
}

var userMatches = sn_uc.UserCriteriaLoader.userMatches(gpid, userCriterias);
if(userMatches == true)

return true;

else

return false
},

 

But It is not visible based on the user criteria