g_user.getClientData defined in catalog client script is not working in Service portal

Viswanatha Red3
Mega Expert

My requirement is

  1. End user identifies the Configuration item.
  2. Navigated Service catalog from my CI form.
  3. From the catalog choose the item, to place the request. (All catalog items has CI as variable)
  4. pre-populate the CI from which he has navigated.

I have set the session variables using putClientData at server-side (during step2). And trying to accesss them in the onLoad catalog client script using the script g_user.getClientData(..). 

This is perfectly working in Native UI and CMS portal.

However, the same onLoad catalog script is not working in Service portal. I am receiving the undefined.

Would any let me know the alternate approach.

Regards

Viswa

 

5 REPLIES 5

Omkar Mone
Mega Sage

Hi 

Is the UI Type of you client script set to "All"?

Let me know.

 

Regards,

Omkar Mone.

www.dxsherpa.com

Yes omkar.

Type is set as "All". That is how I found out that, 'undefined" value is returned by the same statement. (I used alert to populate the value)


Regards

viswa

Alikutty A
Tera Sage

Hello,

I believe the session data functions (get & put) are not accessible on service portal. 

You can try to pass the parameters in URL and see if it works for you on the portal? Append your parameters at the end of URL eg:  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;
}
}

Hi Alikutty,

 

thanks for your reply.

With your suggestion, I can pass the URL. But it only works, if I am redirecting him to catalog item directly.

But, as I mentioned in the step3 and 4, User navigates to service catalog first, he can search by category and then comes to catalog item.

User navigates below pages ( All are OOTB)

./sp?id=sc_category&sys_id=<category item> --> Under this category there can be many sub categories

./sp?id=sc_cat_item&sys_id=<sys_id of item>&sysparm_category=<cate_item>

 

Kindly let me know, how to pass the URL parameters across these pages, to make use of your script.

 

Regards

Viswa