Script to show virtual agent topic based on condition is not working

vishakha10
Tera Contributor

 We have a requirement to show a topic flow to the users in Virtual Agent bot only if the user has active HR cases.

The topic is created in HR Service Delivery Virtual Agent Conversations application. But the context script under 'Who can access this topic' is not working. However the same code works for the topic created in Global application. Below is the script written:

(function execute() {
    /* Return true or false to indicate if the topic or topic node can run
       and be discoverable (or not). Using the format vaContext.liveagent_[var_name] For example:

       var applicability = vaContext.liveagent_portal == 'csm' ? true : false;
       return applicability;
    */
    

var hrCaseCount = 0;
var hrCase = new GlideAggregate('sn_hr_core_case');
hrCase.addQuery('active', true);
hrCase.addQuery('opened_for', vaInputs.user);
hrCase.addAggregate('COUNT');
hrCase.query();
if(hrCase.next())
hrCaseCount = hrCase.getAggregate('COUNT');
vaVars.hrCase_count = hrCaseCount; 
if(hrCaseCount>=1){
    return true;
}
   else{
       return false;
   }
}
)()

    

We tried with global.GlideAggregate for the topic in scoped application but didn't worked. Is it something that these scripts work only in global application?

Kindly assist.

 

Thanks

1 REPLY 1

KaliMatha N
Tera Contributor

Hi Vishakha,

Could you please check the Application Restricted Caller access for this topic and check once?

 

Please mark this as solved if it solves your issue.

 

Thank you,

Govind Das