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

How can I make the Modal window appear on a form with a UI action?

senon
Tera Sage
Tera Sage

Hello, experts!
I'm trying my first attempt at UI action.

It's to pop up a modal after pressing the UI action button to show a specific form view.

The goal is that when the user presses the UI action to transition the status, only the required fields will be shown and after letting the user fill them in, the status will transition.

I have found that the GlideModal/GlideModalForm APIs are effective in achieving the above goal, but the basic part is not working for me.

 

 The following script is what I wrote on my UI action. First, I wrote a minimal script to show the modal.
resolveModalView=This is the view that will show the fields that need to be filled in when setting the status to "resolved".

var d = new GlideModalForm('resolveModalView','table_name');
d.render();

 

How can I achieve my goal?
I'm looking at the following API description, but I'm not quite understanding it.

https://developer.servicenow.com/dev.do#!/reference/api/quebec/client/c_GlideModalFormV3API?navFilte...

I would like to be able to show a modal like the "Start Fix" UI action in issue management.

Best regard.

senon

1 ACCEPTED SOLUTION

@senon 

so you want to show record in the modal window?

Do this

var tableName = 'your table name here';
var sysID = ''; // sys_id of the record you want to show

//Create and open the dialog form
var dialog = new GlideDialogForm('My Table Record', tableName);
dialog.setSysID(sysID); //Pass in sys_id to edit existing record, 
dialog.addParm('sysparm_view', 'resolveModalView'); //Specify a form view
dialog.render();

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

10 REPLIES 10

@senon 

Glad to know that my script worked.

Please mark my response as correct and close the thread so that it helps future members.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@senon 

good article here

GlideDialog or GlideModal

Difference between GlideDialogForm, GlideDialogWindow, and GlideModalForm

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Mohit Kaushik
Mega Sage
Mega Sage

Hi Senon,

 

Could you please try by passing your call back function as well and try once. As shown below:

var d = new GlideModalForm('resolveModalView','table_name',callbackFunction(sysverb_save,current.sys_id, table_name, displayValue));
d.render();

 

If this helps you then please mark it helpful and correct.

 

Thanks,

Mohit Kaushik

Thanks,
Mohit Kaushik
ServiceNow MVP (2023-2025)

Hello, Mohit Kaushik.
I added the call back function and now the modal pops up. Thanks!

var modal = new GlideModalForm('TEST','x_512551_ncm_ticket',abc);
	modal.render();

function abc(action, sys_id, table, displayValue) {
	//set value on form to new sysid of update set
	g_form.setValue('u_solution_description', "test");
}

 

However, the new create form for the specified table is displayed.
This is not the process I had in mind.

I want the modal to show my specified View with the current record.
What ideas do you have?

Best regard.

senon.

 

Hi Mohit,

 

Can you give me an example on how can I use the call back function?

I am trying to do a multiple update by adding a UI action as a list choice in Incident table.

Basically like the OOB Context Menu 'Update Selected' but instead of Context menu, it will be a pop up window when a UI action is clicked.

 

Thanks!

Jamie