How to create a popup dialog box on a UI Action and populate a field

mkader
Kilo Guru

Hello,

I have a "Reject" UI Action that I need to display a pop-up for with a comment box. They need to write the reason for the rejection. After they click ok, the rejected comment populates a reason field on the form. 

How can I set this up.

I am struggling to follow the example provided by SN Guru:

https://www.servicenowguru.com/system-ui/glidedialogwindow-advanced-popups-ui-pages/

Thanks!

1 ACCEPTED SOLUTION

Kieran Anson
Kilo Patron

Hi,

You can pretty much duplicate the Cancel Change UI Action form the change_request table.

var rejectconfirmDialog;

function loadConfirmDialog() {
	var dialogClass = window.GlideModal ? GlideModal : GlideDialogWindow;
	rejectconfirmDialog = new dialogClass("change_confirm_cancel", false, 648, 250);
	rejectconfirmDialog.setTitle(new GwtMessage().getMessage("Reject Task")); //Modify title to display on popup
	rejectconfirmDialog.render();
}

function moveToCancel(notes) {
//g_form.setValue("state",1) Possible to set the state here.
		g_form.setValue("work_notes", notes); //Pass reason worknotes to a field
		rejectconfirmDialog.destroy();
		gsftSubmit(null, g_form.getFormElement(), "UI action name"); // Call UI action to run server script
	
}

if (typeof window == 'undefined')
   setRedirect();

function setRedirect() {
    current.update();
    action.setRedirectURL(current);
}

 

View solution in original post

20 REPLIES 20

asifnoor
Kilo Patron

Hi,

Refer to this article where i have shown code with an example.

https://community.servicenow.com/community?id=community_article&sys_id=bb0e039fdb9b1054b1b102d5ca961...

Mark the comment as helpful/correct if this solves your problem.

I will test this now

sachin_namjoshi
Kilo Patron
Kilo Patron

Use GlideModal API to open popup and populate a field.

 

https://developer.servicenow.com/dev.do#!/reference/api/orlando/client/c_GlideModalClientSideV3API

 

Regardsm

Sachin

 

 

@sachin.namjoshi - I tried referencing this document earlier, but setting up what they had was redirecting me back to my last screen when setting up the UI Action

var gm = new GlideModal('UI_dialog_name');
        //Sets the dialog title
        gm.setTitle('Show title'); 
        gm.setPreference('name', 'value'); 			      	
        gm.setWidth(550);
        //Opens the dialog
        gm.render();