Troubles with Client Session data

jaakko_jalo
Tera Contributor

Hi,
I can't get putClientData() and getClientData() to work for me for some reason.
http://wiki.service-now.com/index.php?title=Session_Client_Data

The Script Action is fired by 'session.established'.
It simply contains:

gs.getSession().putClientData('myValueThatWontWork','test1');


and then it is read by a Client Script in incident table.

function onLoad() {
var l = g_user.getClientData('myValueThatWontWork');
jslog("testingGetSessionData: "+l);
}


What is shown in the debug window is 'testingGetSessionData: undefined'.
What I'd want to use this for is storing the logged in users locations's parent region in client session data so I do not need to make a new server query for it everytime the incident form is loaded.

Also that 'Synchronous' mentioned in the wiki article is not in the list of available fields when personalizing the form.
Is that something long ago depcrecated and do I need to worry about it?

Thanks in advance.
5 REPLIES 5

jeff_lord
Giga Contributor

Just so anyone reading this post can see a possible solution.


I was having trouble getting the putClientData and getClientData to work.


After much work I found that the session its looking for is the login session.


So logging out of an open session and logging back in will trigger the session.established event.


After that event is triggered now they will work correctly, if the rest of the things mentioned in the wiki and here are in place.


Here is my actionscript to provide the users email



sendEmailToForm();



function sendEmailToForm() {


          var ourUser = session.getUser();


          var currentUserEmail = ourUser.getEmail();


          session.putClientData('userEmail', currentUserEmail);


}



Here is my Catalog Client Script


function onLoad() {


  var currentUserEmail = g_user.getClientData('userEmail');


  alert('Email: ' + currentUserEmail);


}



I hope you find this helpful.