How to pass variables from a UI Action to a UI Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 11:41 AM
Hello Everyone,
I have a UI Action button that opens a UI Page in a GlideDialogWindow. I need to pass some variable values from the UI Action to the UI Page to use in the client script, but have been unable to achieve this. Below is my UI Action code for the GlideDialogWindow:
var gdw = new GlideDialogWindow('x_admis_floorplan_Room Picker');
gdw.setTitle('Room Picker');
gdw.setSize(900,900);
gdw.setPreference('table_name', g_form.getTableName());
gdw.setPreference("user_sys_id", g_form.getUniqueValue());
gdw.setPreference('floorid', floorid);
gdw.render();
How can I access the value of floorid in my UI Page? I have tried g_dialog.getParameters();, GlideDialogWindow.getPreference('floorid');, and even g_scratchpad, but nothing seems to work. Any help would be greatly appreciated.
Thanks,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 11:44 AM - edited 08-21-2023 11:47 AM
Hello @Andrew158
You need to use g_scratchpad for this :-
UI Action:
var sys_id=1234; var table='Table Name'; var floor_id = 'abc1234567; var opsGenieOnCallInfo = { sys_id: sysID, table: tableName, floor_id: floorID }; g_scratchpad.opsOnCallInfo = opsGenieOnCallInfo;
UI Page:
var passedData; if (g_scratchpad.opsOnCallInfo){ passedData = g_scratchpad.opsOnCallInfo; }
Plz Mark my Solution as Accept and Give me thumbs up, if you find it helpful.
Regards,
Samaksh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 12:41 PM
As mentioned in my post, I have already tried using g_scratchpad to no avail. With this exact code (Plus adding the missing quote for var floor_id), g_scratchpad.opsOnCallInfo always returns undefined. However if this solution does work for anyone, please give credit to the original poster kdurg on the thread this code was taken from here.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:00 PM
Hello @Andrew158,
One solution is to use the g_form object in your UI Page client script to access the values of the preferences that you set in your UI Action. The g_form object is a global object that represents the current form or list and provides methods to manipulate it. You can use the g_form.getParameter(name) method to get the value of a preference by its name. For example, to get the value of floorid, you can use this code in your UI Page client script:
var floorid = g_form.getParameter("floorid");
Another solution is to use the window object in your UI Page client script to access the values of the preferences that you set in your UI Action. The window object is a global object that represents the browser window and provides properties and methods to interact with it. You can use the window.dialogArguments property to get an object that contains the preferences that you set in your UI Action. For example, to get the value of floorid, you can use this code in your UI Page client script:
var floorid = window.dialogArguments.floorid;
Hope this helps.
Kind Regards,
Swarnadeep Nandy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2023 01:11 PM
Thanks for the reply,
Unfortunetly, using
var floorid = g_form.getParameter("floorid");
returns blank for floorid. I should mention that for testing, I updated the floorid preference to pass the static string 'abc' so I can ensure the issue is not with the UI Action getting that value.
With your second option:
var floorid = window.dialogArguments.floorid;
floorid is undefined, causing an error in the console.
For both solutions, I added the line of code to my UI Page client script, then tried to console.log('floorid');
Is there something I am missing here? Have these solutions worked for you in the past?