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

g_user.getClientData not working

andymcdonald
Kilo Guru

I had an issue in which I could not read client data that was set in a UI Action:

1. We have a requirement to make some fields read only when a change is proposed to a CI via the Proposed Change UI Action.

2. In the UI Action, I extract the sys_id of the CI, and then set a piece of client data

3. In an onLoad Client Script, I try to read the client data, and if it is set with the current sys_id, update the required fields

4. After being unable to ready client data, I opened a support case and even the SN guys struggled with this for a few days.

5. Eventually a solution was found, with the following code being added to the CS:

 

var topWindow = (top.window.g_user ? top.window : top.window[0]);
if (topWindow && topWindow.g_user.getClientData(<key>) === g_form.getUniqueValue()){
     // take the required actions
     topWindow.g_user.setClientData(<key>, "");
}

This solution is way better than the only other solution I found which was to create separate views for each CI type and launch those in the modal...that would be miserable.

-->Thanks Ashwanth Parine and Ryan Schaefer for working to find this solution.

0 REPLIES 0