Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Does g_modal only work in Workspaces?

jglez1
Mega Guru

I've used g_modal before in a Workspace when I had to create an authentication feature for work, and now I have to create a new modal but in what I believe is called classic or native UI (an example being when viewing an Incident ticket but outside of a Workspace)

 

I'm starting out basic and trying to use g_modal.showFields() to render some basic input fields but the modal isn't rendering at all. Is this API only accessible in Workspaces? If so, is there a counterpart for the native / classic UI?

 

Thanks

1 ACCEPTED SOLUTION

Robbie
Kilo Patron

Hi @jglez1,

 

Take a look at the GlideModal API for use in the native back-end UI. It replaces the now deprecated GlideWindow and GlideDialogWindow API's.

 

Here's the official SN Docs site and info with an example: https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/G...

 

And a big shout out to Dave Mac and a useful page I've used in the past re Glide Modals: https://davidmac.pro/posts/2022-02-08-glidemodal/

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie

 

View solution in original post

4 REPLIES 4

Chris D
Mega Sage

Good question... I'm struggling to find any formal documentation on g_modal to begin with - which I figure would answer this question easily 😕

I can't remember if I ever found out if g_modal works in the native UI view, but I know I got a custom modal working via a UI Action + UI Page and using the GlideModal object.

 

Say you want a custom modal on the Incident table in the form view. You can create a UI Action and in the Onclick field, define the name of your function like "renderModal()"

 

Then, in the Script section, inside your Onclick function definition, define a GlideModal instance, passing in the name of your UI Page like "OutageNotificationModal". Then, do setTitle() and render() and that's it.

function renderModal() {
	g_scratchpad.incidentNumber = g_form.getValue("number");
	var modal = new GlideModal("OutageNotificationModal");
	modal.setTitle("Send Customer Comms");
	modal.render();
}

 

Peter Bodelier
Giga Sage

Hi @jglez1,

 

Correct g_modal is only available in workspace.

@Chris D This is still the best documentation around it:

How to use UI Actions in Workspaces - ServiceNow Community

 

Glide Modal is the variant for the classic UI:
GlideModal | ServiceNow Developers


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Robbie
Kilo Patron

Hi @jglez1,

 

Take a look at the GlideModal API for use in the native back-end UI. It replaces the now deprecated GlideWindow and GlideDialogWindow API's.

 

Here's the official SN Docs site and info with an example: https://docs.servicenow.com/bundle/vancouver-api-reference/page/app-store/dev_portal/API_reference/G...

 

And a big shout out to Dave Mac and a useful page I've used in the past re Glide Modals: https://davidmac.pro/posts/2022-02-08-glidemodal/

 

To help others (or for me to help you more directly), please mark this response correct by clicking on Accept as Solution and/or Helpful.

 

Thanks, Robbie