Virtual Agent Context Variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 04:06 AM
Hi there,
I'm trying to determine the current portal URL by using a context variable, however, the variable always return undefined and I cannot seem to figure out why. Any help would be greatly appreciated!
Context Variable (I have removed answer and tried, remove 'getSession' and tried but no luck) is the attachment.
Condition script on virtual agent topic:
gs.log("Context plswork: " + vaContext.portalCheck, "BenTest");
if(vaContext.plsWork.includes("locker"))
return false;
else
return true;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 04:45 AM
Hi there,
This article should help you:
Virtual Agent - Available topics depending on different Service Portals
In this article exact info on vaContext usage is explained.
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 05:46 AM
Thanks for the reply, I've seen that article however, it requires you to change the url. Unfortunately this isn't an option for me...

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 05:53 AM
Ah oke.
Can you provide an example URL?
For example, in your script I see vaContext.portalCheck and vaContext.plsWork. Does your url contain sysparm_portalCheck and sysparm_plsWork?
So what exactly are you trying to fetch from the URL?
If my answer helped you in any way, please then mark it as helpful.
Kind regards,
Mark
---
LinkedIn
Community article list
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-15-2020 05:58 AM
This is the format of all our URLs:
https://byea.service-now.com/tech
https://byea.service-now.com/hr
So I'm trying to identify when its either /tech or /hr.
Aye sorry, the 'plsWork' should be 'portalCheck' (Was testing and forgot to revert before photo)
if(vaContext.plsWork.includes("locker"))
Thanks,
Ben