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

How to call a view in Ui action

Roshini
Giga Guru

Hi Team,

I am trying to call a particular view from a ui action.
scenario :-
when I click on "On hold" ui action in incident table, i need a specific view "on_hold_dialog_view" to get displayed as a popup.
Can I know how i can call this view in Ui action

1 ACCEPTED SOLUTION

Voona Rohila
Mega Patron
Mega Patron

Hi @Roshini 

 

UI Action Client checkbox should be true and onClick use openPopup() method.

 

I did similar requirement long back, Adding code below. Modify according to your requirement.

 

function openPopup() {
    var tableName = ''; //table name here
    var sysid = g_form.getUniqueValue();
    //Create and open the dialog form

    var dialog = new GlideDialogForm('Title', tableName); //Provide dialog title and table name
    dialog.setSysID(sysid); //Pass in sys_id to edit existing record, -1 to create new record
    dialog.addParm('sysparm_view', 'Reasons'); //Add view of the form
  
    dialog.setLoadCallback(function(iframeDoc) {
        // To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
        var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
        dialogFrame.g_form.setValue('u_number', g_form.getValue('u_number'));
		dialogFrame.g_form.setValue('u_state', 'Completed');
		dialogFrame.g_form.setMandatory('u_justification', true);
		dialogFrame.g_form.setReadOnly('u_select_user', true);
		dialogFrame.g_form.setReadOnly('u_hiring_manager', true);

        dialogFrame = null;
		
    });
    dialog.render(); //Open the dialog
	
	
}

 

Refer Below article 

https://servicenowguru.com/system-ui/glidedialogwindow-quickforms/

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

5 REPLIES 5

Voona Rohila
Mega Patron
Mega Patron

Hi @Roshini 

 

UI Action Client checkbox should be true and onClick use openPopup() method.

 

I did similar requirement long back, Adding code below. Modify according to your requirement.

 

function openPopup() {
    var tableName = ''; //table name here
    var sysid = g_form.getUniqueValue();
    //Create and open the dialog form

    var dialog = new GlideDialogForm('Title', tableName); //Provide dialog title and table name
    dialog.setSysID(sysid); //Pass in sys_id to edit existing record, -1 to create new record
    dialog.addParm('sysparm_view', 'Reasons'); //Add view of the form
  
    dialog.setLoadCallback(function(iframeDoc) {
        // To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
        var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
        dialogFrame.g_form.setValue('u_number', g_form.getValue('u_number'));
		dialogFrame.g_form.setValue('u_state', 'Completed');
		dialogFrame.g_form.setMandatory('u_justification', true);
		dialogFrame.g_form.setReadOnly('u_select_user', true);
		dialogFrame.g_form.setReadOnly('u_hiring_manager', true);

        dialogFrame = null;
		
    });
    dialog.render(); //Open the dialog
	
	
}

 

Refer Below article 

https://servicenowguru.com/system-ui/glidedialogwindow-quickforms/

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Am able to open the view as per your code
but it is showing all the ui actions as well, I don't want the ui actions to be visible.
Is there anything that we can do for it

Hi @Roshini,

You might need to add the below line of code:
dialog.addParm('sysparm_hideButtons', 'true'); // This hides all UI action buttons

Thanks

function onHoldAction() {

var tableName = 'incident'; //table name here
    var sysid = g_form.getUniqueValue();
    //Create and open the dialog form
    var dialog = new GlideDialogForm('ON Hold', 'incident'); //Provide dialog title and table name
    dialog.setSysID(sysid); //Pass in sys_id to edit existing record, -1 to create new record
    dialog.addParm('sysparm_view', 'on_hold_dialog_view'); //Add view of the form
  dialog.addParm('sysparm_hideButtons', 'true');
    dialog.setLoadCallback(function(iframeDoc) {

        // To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
        var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
        dialogFrame.g_form.setValue('hold_reason', g_form.getValue('hold_reason'));
        dialogFrame.g_form.setMandatory('hold_reason', true);
        dialogFrame = null;
       
    });
    dialog.render(); //Open the dialog
}
Tried this.
But still seeing the UI action