
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2022 02:59 PM
Hello, I'm trying to display a topic on the topic list ONLY if the user is a manager OR if the user if from Human Resources.
I have a javascript code that I've been using on other topics inside the conversation flow to go thru different conversation paths in the topic depending on the user (manager /HR or non-HR) and it works when the code is inside the conversation flow. But if try to use the same code placing it on the Script condition (properties tab) of the topic, nothing happens. Wondering if anyone has done something similar that has worked.
Thank you.
var manager_and_HR = new sn_hr_core.hr_Criteria().evaluateById("a8df765e1bca3300167b759d1e4bcbdd", gs.getUserID());
var isManager = vaInputs.search_user.u_ismanager;
if (isManager)
return true;
if (manager_and_HR)
return true;
if (!isManager && !manager_and_HR)
return false;
Solved! Go to Solution.
- Labels:
-
Virtual Agent

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 10:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-20-2022 10:05 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2022 02:49 PM
Thank you sbritt! It's working nicely

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2022 07:30 AM
See how sbritt's solution works for you - seems good to me.
To add something else, your code is using a vaInputs variable in it - I'm pretty confident vaInput variables aren't even initialized before the topic is started but even if they were, they'd still have no values when the topic availability is being checked. That seems to be your issue.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2022 02:54 PM
Thank you for catching that Chris. I ended up removing that line from the script. Sbritt's script is working perfectly.
Had a developer look into it and came up with a simplified version
{
var manager_and_HR = new sn_hr_core.hr_Criteria().evaluateById("a8df765e1bca3300167b759d1e4bcbdd", gs.getUserID());
gs.info('YM - manager_and_HR = ' + manager_and_HR);
if (manager_and_HR)
return true;
}
Both scripts (scbritt's and this one) are working good.
Thank you all!