How to Hide UI Action using client script.

Pavan Vasudeva
Tera Contributor

Hello Experts,

 

I have a requirement to Hide some OOB UI actions from workspace View in Both Classic UI and CSM Configurable Workspace UI. 

I Know i could do that using 'UI action Visibility' by Excluding the UI action from Workspace View or Add a 'condition' in that particular UI Action But the thing is Client doesn't want to touch the UI actions and wants the UI actions to be hidden using client script, The reason they are giving is since they are OOB UI actions and if we make any changes there then they will not be upgraded in future upgrades. 

 

I tried the below code in the On load Client script to hide the UI actions but that is working only for Classic UI and That too only for Form buttons and not the context menu and not working for CSM Configurable Workspace UI.  Kindly let me know how that can be done.

function onLoad() {
    var view = g_form.getViewName();       //Called this function to get the view
    if (view == 'workspace') {
    $$('BUTTON').each(function(item) {   // This is the code i found somewhere and tried it
           var uiActionList = g_scratchpad.uiActionProperty;  // Created a sys Property and added the list of UI actions which need to hidden 
          var uiActionListArray = uiActionList.toString().split(','); // To split the UI actions by comma in sys property 
          for (var i = 0; i < uiActionListArray.length; i++) {
              if (item.innerHTML.indexOf(uiActionListArray[i]) > -1) {
                  item.hide();
              }
          }
      });
  }

}
 
Kindly help me to hide the UI actions from both Classic UI(Form button and Context menu) and CSM Configurable Workspace.
 
Thank you,
Pavan

 

2 REPLIES 2

Amit Gujarathi
Giga Sage
Giga Sage

HI @Pavan Vasudeva ,
I trust you are doing great.

You mentioned that you tried using the provided code in the OnLoad client script, which successfully hides the UI actions in the Classic UI for form buttons but not for the context menu, and it doesn't work in the CSM Configurable Workspace UI. I will guide you on how to achieve this functionality for both interfaces.

To hide the UI actions in both Classic UI and CSM Configurable Workspace UI, you can modify the existing code as follows:

function onLoad() {
    var view = g_form.getViewName();

    if (view == 'workspace') {
        // Hide form buttons
        $$('BUTTON').each(function(item) {
            var uiActionList = g_scratchpad.uiActionProperty;
            var uiActionListArray = uiActionList.toString().split(',');
            
            for (var i = 0; i < uiActionListArray.length; i++) {
                if (item.innerHTML.indexOf(uiActionListArray[i]) > -1) {
                    item.hide();
                }
            }
        });

        // Hide context menu items
        $$('CONTEXT_ITEM').each(function(item) {
            var uiActionList = g_scratchpad.uiActionProperty;
            var uiActionListArray = uiActionList.toString().split(',');
            
            for (var i = 0; i < uiActionListArray.length; i++) {
                if (item.innerHTML.indexOf(uiActionListArray[i]) > -1) {
                    item.hide();
                }
            }
        });
    }
}

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi



Dear Amit, Thank you for the response. I have modified your code and tried but no luck :(. It did not work for both context menu and the UI actions in CSM Workspace UI