Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Trying to hide UI Action button from GlideModalForm UI Action

LRhodes
Tera Guru

Hi,

We have this UI Action for when an Incident is put on hold where a new window pops up for the user to fill in some mandatory fields. I have also created a UI Action button which is appearing in this pop up window but I don't want it to display in there;

find_real_file.png

I'm not sure where to approach this - should I exclude it from the GlideModalForm UI Action or the button UI Action?

Here's the script that pops the window up when the button is clicked;

function showMyForm(){
    //Get the table name and sys_id of the record
    var tableName = g_form.getTableName();
    var sysID = g_form.getUniqueValue();

    //Create and open the dialog form
    var dialog = new GlideModalForm('Place '+g_form.getValue('number')+' On Hold', tableName); //Provide 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_details'); //Specify a form view
    dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
	
	//setOnloadCallback will set the function to be carried out as the form loads
	dialog.setOnloadCallback(function() {
    // The below identifies the modal version of the form that is loaded in the frame	
	var dialogFrame = window.frames["dialog_frame"];
		
		// This applies the On Hold state to the modal version of the form when it is loaded
    dialogFrame.g_form.setValue('state', 3);
    dialogFrame = null;
    });
	
	//setCompletionCallback will set the function to be carried out when the form is successfully submittied
	dialog.setCompletionCallback(function() {
		// Reloads the parent form once the modal form has been submitted and saves any changes that were made prior to clicking On Hold
    g_form.submit();
    });
	
    dialog.render(); //Open the dialog
}

The script for the button is nothing fancy but here that is too;

current.work_notes = "A request has been made for an update on this ticket.";
current.u_chase_count += 1;

current.update();
action.setRedirectURL(current);
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can hide that UI action for this view "on_hold_details" using UI action visibility

Also ensure in UI action condition you check whether it's form view or not

Add this as condition in UI action

gs.action.getGlideURI().toString().indexOf('incident.do?sys_id')

Note: I have not tested this part

Regards
Ankur

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

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

you can hide that UI action for this view "on_hold_details" using UI action visibility

Also ensure in UI action condition you check whether it's form view or not

Add this as condition in UI action

gs.action.getGlideURI().toString().indexOf('incident.do?sys_id')

Note: I have not tested this part

Regards
Ankur

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

Thank you Ankur, adjusting the UI action visibility has done the trick.

Hi Ankur Bawiskar,

Can you please help on this,

For Agent Workspace case table - hide the following UI actions:
1. Create Work Order
2. Create Standard Change
 
Using Scripting

@Balaji Munusamy 

Can you post a new question and tag me there as this is older thread?

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