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

UI Action VS Declarative Action

VernYerem
Tera Expert

Hello! 
We have a need to add a feature to incident records. The feature is a button that produces a pop up, which displays two reference fields "old asset" and "new asset". When the popup is submitted, trigger a flow to make some updates to those assets.

 

My current solution is a UI Policy, which calls a UI Page with the two fields mentioned. The UI Page has a processing script that triggers a script include to generate an event, and I have a flow triggered by the event to update the required fields. This works great in the Classic UI.

 

We utilize Service Operations Workspace, so this is where I start to get confused in the method. The UI Action has a "Workspace" section, I enable it and it shows on the record in SOW but doesn't do anything. This is where I got stuck, so I start looking into it further and find guidance on using Declarative actions/Payloads/Modals rather than the UI Action/UI Page/Script include that I've used in classic UI.

 

I'd prefer to use the UI Action if possible, to keep the configuration in one place. Since the UI Page works as expected, can I just use that as the popup in the SOW?

1 ACCEPTED SOLUTION

DrewW
Mega Sage

This is how I opened a new record form in workspace in a modal popup.  I added it to the "Workspace Client Script" field on the UI Action form.  You can try using the same thing to open the UI Page in workspace.

 

function onClick(g_form) {
	var url = "/member_table.do?sysparm_view=workspace&sys_id=-1&sysparm_form_only=true&sysparm_titleless=true&sysparm_link_less=true&sysparm_workspace=true";
	var x = g_modal.showFrame({
		title: "New Member",
		url: url,
		size: 'lg'
	});
	
}

 

Also did you try checking the box "Format for Configurable Workspace"?

View solution in original post

3 REPLIES 3

DrewW
Mega Sage

This is how I opened a new record form in workspace in a modal popup.  I added it to the "Workspace Client Script" field on the UI Action form.  You can try using the same thing to open the UI Page in workspace.

 

function onClick(g_form) {
	var url = "/member_table.do?sysparm_view=workspace&sys_id=-1&sysparm_form_only=true&sysparm_titleless=true&sysparm_link_less=true&sysparm_workspace=true";
	var x = g_modal.showFrame({
		title: "New Member",
		url: url,
		size: 'lg'
	});
	
}

 

Also did you try checking the box "Format for Configurable Workspace"?

Ah, now it's popping up as expected! Now, I'm curious as to your method of closing the popup.
I'm currently using GlideDialogWindow.get().destroy(); which seems to error on the workspace side. Is there a better method that works on both the workspace and Classic UI?

At the time that I coded that finding documentation was not easy.  But once you submitted the new record the dialog closed on its own.  So I did not have to worry about destroying the window or anything to get it to closed.

 

Also as far as making the platform and workspace work using the same code, I'm not sure you are going to have much luck doing that.  If you do I would like to know what you did.

 

There is documentation for it now so that may help.

https://developer.servicenow.com/dev.do#!/reference/api/yokohama/client/g_modalClientAPI#g_modal_sho...