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

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

this should be the complete one; if you wish to show table

var gdw = new GlideModal('show_list');
gdw.setTitle("My Table");
gdw.setSize(750);
gdw.setPreference('table', 'incident_list'); // your table name here with _list
gdw.setPreference('sysparm_view', 'viewName'); // your view name here
gdw.render();

Regards
Ankur

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

Hi Ankur.
Thanks to this code, I was able to display the resolveModalView.

However, the records are shown as newly created.
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.

 

@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

Thank you Ankur.
I was able to view what I was looking for.

Two questions, what is the difference between GlideModalForm and GlideDialogForm?

Is there an article that explains GlideDialogForm?

 

Best regard.

senon.