Advanced criteria in Custom greetings and Setup
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2023 09:29 PM - edited 11-30-2023 09:32 PM
Hi All,
I'm configuring a custom greeting for a Retail customer that wants to shows different setup topics based on their user's location type (Store/Corporate/Warehouse). I'm trying to use the Advanced Condition mode and I have written the following script.
(function executeCondition(/* glide record */ current) {
// customize condition logic here, return true or false
var gr = new GlideRecord('cmn_location');
gr.addQuery('sys_id',gs.getUser().getRecord().getValue('location'));
gr.query();
if(gr.next()){
if(gr.cmn_location_type.getDisplayValue() == "Store"){
return true;
}
else
return false;
}
})(current);
Testing this using the Test button does not seem to work as it is still going to the default greeting. Can someone tell me what I'm doing wrong and how to fix it ?
P.S: I have added gs.debug() to the script above as well, but it does not seem to log anything to the virtual agent testing log window.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 12:16 AM
try this once
(function executeCondition(/* glide record */ current) {
// customize condition logic here, return true or false
var userRec = new GlideRecord('sys_user');
userRec.addQuery('sys_id', gs.getUserID());
userRec.query();
if(userRec.next()){
if(userRec.location.cmn_location_type.getDisplayValue() == "Store")
return true;
else
return false;
}
})(current);
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2023 04:48 AM
Hi Ankur,
Thank you very much for the response. But, it looks like the Advanced criteria is not working as expected. I used your script in the 3 different Custom Greeting & setup I have created for the 3 location types (Store/Corporate/Warehouse) by updating their respective values. But when I test it through service portal by impersonating end users from different locations, I'm not getting the promoted topics according to the setup. Is there a way I can enable logs and check which custom greeting is getting tagged to the user or if the advanced script is working as intended?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-22-2025 05:09 AM
Hi @Sathya10
Is it possible to control the entire virtual agent to be enabled based on locations from the Advanced script.
Thanks!
Ramkumar