The CreatorCon Call for Content is officially open! Get started here.

Virtual Agent Context Variables

benm3
Mega Guru

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;

 

 

12 REPLIES 12

Ah oke. Then vaContext will for sure not work.

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

LinkedIn

Ahhh... Do you know of anyway that could work this out? Tried doing below as well as a range of different combinations but no luck...

if(gs.getSession().getUrlOnStack('xxxx'))
return true

 

anindya_11
Giga Contributor

Hello benm,

 

Were you able get the url parameter in the Virtual agent script ? Facing the same issue.

 

Regards,

Anindya

Hi anindya_11,

 

Unfortunately not. We also raised a HI ticket but was met with little luck..

 

Thanks,

Ben

 
 

 

Jason67
Kilo Contributor

I found this article on the community that might help answer this question. 

Provides the Portal suffix. This Context variables only works instantly when using Service Portal Agent Chat Configuration. If using legacy methods (like embedding the Service Portal widget to the header or footer), this would only work when adding sysparm_portal to the URL.
Example output: "sp" 

50+ (Un)documented Virtual Agent variables (vaInputs, vaVars, vaContext, vaSystem) - Virtual Agent, ...