How can we do passing session variables to a service portal and get those values auto populate to catalog item variables via catalog client script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 07:22 PM
Hi,
I have a requirement to auto populate session variables such as customer details (name, phone number etc) from a case to a catalog item variable in the service catalog portal.
We have tried below actions on the same.
There is a UI action, which will redirect the page to the service portal where agent can create a request by selecting the required catalog items. So we collected the session variables in the UI action and passed it.
Used session.putClientData() to do this.
From a catalog client script, we used g_user.getClientData() method to retrieve the session data and tried to print it.
This is working well and good in the Service Catalog UI and but not working in Service portal.
Any ideas on how we can do it...
Much appreciated for the responses.
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2018 09:56 PM
Hello,
Can you try to pass the parameters in URL and see if it works on portal? Append your parameters at the end of URL eg: Portal URL?sysparm_user=12345555
On the catalog item, add an on Load client script and fetch its value
function onLoad() {
var user = getParameterValue('sysparm_user');
if (user) {
g_form.setValue('requested_for', user);
}
function getParameterValue(name) {
var url = document.URL.parseQuery();
if (url[name]) {
return decodeURI(url[name]);
} else {
return;
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 07:42 PM
Hi Alikutty,
Thanks for your response.
Currently, we are trying to pass the id in the URL, however, from the home page, when we click on the Service catalog item, URL is changing and the id also getting removed from the URL.
To consider your suggestion, mostly I may need to customise the widget and try to pass the id again to the new page.
Just wondering that is there an alternate way to get the g_user glidesession object in catalog client script so that it will work from the service portal.
Thanks,
Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2018 09:17 PM
Hi,
Go through below link, this may help you.
UI Action to pass reference field to record producer
You may apply the same logic to the service portal.
Mark Correct/Helpful, if this helps you.
Regards,
Devyani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-16-2018 03:40 AM
Hi Devyani,
Thanks for your response.
We have tried similar code already. However, it worked well in the service catalog UI but not in portal.
Also we dont want to pass the variables in the URL.
Hence we are trying with session clientdata.
However we are having some difficulty in this one as well. Because the client data is showing as undefined in the portal client script.
please refer my comments on the below link.
https://community.servicenow.com/community?id=community_blog&sys_id=18ac2225dbd0dbc01dcaf3231f9619e3
Thanks,
Raj