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

Check the article link I provided, Create a OnLoad client script which runs only for the view you want with below logic

 

//Remove all buttons except for the 'Update' button
var items = $$('BUTTON').each(function(item){
if(item.id != 'sysverb_update'){
item.hide();
}
});

 

Make Isolate Script to false for above client script.

 https://servicenowguru.com/system-ui/glidedialogwindow-quickforms/#:~:text=ResolveDialog%20remove%20...

 

 


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