Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Jim Coyne
Kilo Patron
Included in the Developer Toolbox Update Set available on Share (link to Share in the post).

 

We are adding quite a bit of information to the g_scratchpad object on a project I'm involved with at the moment so I decided to create a quick tool to help us see what all ends up there.   It's a simple client-side Related Link UI Action that pops up a window with the current contents:

 

find_real_file.png

 

JimCoyne_0-1691723269790.png

 

Here's the configuration for the UI Action:

Name:         Show Contents of g_scratchpad

Table:        Global

Order:        200,000

Action name:  u_fpc_show_contents_of_g_scratchpad

Active:       checked

Show insert:  checked

Show update:  checked

Client:       checked

Form link:    checked

Messages:     u_fpc_show_contents_of_g_scratchpad.modal.title

Hint:         Displays the contents of the g_scratchpad object in a popup window (FPC)

Onclick:      uFpcShowContentsOfGScratchpad()

Condition:    gs.hasRole("admin")

Script:

 

 

function uFpcShowContentsOfGScratchpad(){
	var newLine = "\n";
	var scratchPad = [];
	var items = Object.keys(g_scratchpad);
	items.sort();  //sort the item names alphabetically in case they are not already

	var numberOfItems = items.length;
	for (var i = 0; i < numberOfItems; i++) {
		scratchPad.push(items[i] + " = " + JSON.stringify(g_scratchpad[items[i]]));
	}

	//encode the string so it can be passed to the UI Page properly and then decoded there
	scratchPad = encodeURIComponent(scratchPad.join(newLine));

	//open the dialog window
	var gdw = new GlideDialogWindow("u_fpc_simple_copy_paste");
	gdw.setTitle(getMessage("u_fpc_show_contents_of_g_scratchpad.modal.title"));
	gdw.setSize(650, 500);
	gdw.setPreference("sysparm_text", scratchPad);
	gdw.render();
}

 

 

 

The UI Action requires the "Simple Copy/Paste" UI Page to actually display the information.

 

I've attached the XML files for both the UI Action and the UI Message if you want to just import them into your instance.

9 Comments