Remove buttons for particular view

Bidduam
Tera Guru

I have a button added to asset forms called "Return Asset", this is done via a UI Action and on click opens a modal window that shows only the fields we want the Service Desk via a view called "returned" to fill in when an asset is returned, however I want it to only have the update button showing.

I've created a client Script to try and achieve this, however all I seem to be able to achieve is showing all buttons or no buttons. Would love some assistance please

Client script:

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

 

Bidduam_0-1665702330856.png

This is what actually displays:

Bidduam_1-1665702424590.png

When I select "isolate script" it adds (leaves) all buttons:

Bidduam_2-1665702466951.png

 

1 ACCEPTED SOLUTION

Luke Van Epen
Tera Guru

You shouldn't use DOM manipulation to accomplish this

 

In the Condition field for each UI action you want to hide, add this line:

 

RP.getViewName() != 'returned'

 

Or at the bottom of each UI Action is a UI Action Visibility related list, where you can add the specific Views that you want each UI Action to be visible on. Depends on whether you want a whitelist or blacklist approach

 

View solution in original post

2 REPLIES 2

Luke Van Epen
Tera Guru

You shouldn't use DOM manipulation to accomplish this

 

In the Condition field for each UI action you want to hide, add this line:

 

RP.getViewName() != 'returned'

 

Or at the bottom of each UI Action is a UI Action Visibility related list, where you can add the specific Views that you want each UI Action to be visible on. Depends on whether you want a whitelist or blacklist approach

 

Thank you @Luke Van Epen I tested the condition, and it works a treat, I also worked out the UI Action visibility about 2mins before I got your response and proved that also works.

Thanks again for your response, very much appreciated 😁