- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 03:58 AM
hello Experts,
I have one requirement in which I need to provide the link of catalog item in virtual agent so that when user will click on the link, it will redirect to a catalog item.
Now this catalog item has a field called description which should be automatically populated with some text - "I need access to XYZ".
Redirecting to catalog item seems fine to me. But how Can I achieve this auto population of description.
Regards
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2019 01:18 AM
Hi Nikita,
so do one thing; as part of approach we are adding extra parameter in the url which is "sysparm_virtualagent"
So use below script to know whether the url contains this string; if yes the set the value
updated script below; use UI type as ALL
function onLoad() {
//Type appropriate comment here, and begin script below
var url = top.location.href;
var index = url.indexOf("sysparm_virtualagent");
if(index >= 0)
g_form.setValue('description','I need access to XYZ');
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 09:59 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 10:04 AM
Hi Nikita,
Can you add onload client script on that catalog item and do alert to know what is coming in URL when it is redirected from virtual agent?
Share the url in your comment
function onLoad(){
var url = this.location.href;
alert(url);
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 10:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 10:23 AM
Hi Nikita,
that url doesn't seem to have any reference it is being called from virtual agent; so one thing you can do is add an extra parameter in the url so that in onload you can know it is from virtual agent
in line number 62 add this
+ sys_id + '&sysparm_virtualagent=true'
in onload you can do this
function onLoad(){
var gURL = new GlideURL();
gURL.setFromCurrent();
var urlValue = gURL.getParam("sysparm_virtualagent");
if(urlValue == 'true')
g_form.setValue('description','I need access to XYZ');
}
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2019 10:58 AM