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.

Document Preview: restrict edit button on the HR agent Workspace configurable

AnkitS954229730
Tera Contributor

I want to hide the EDIT button on the Preview Document pop up in the HR agent Workspace [configurable]. 

 

 

 

 

AnkitS954229730_11-1729144241173.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

4 REPLIES 4

Shubham_Jain
Mega Sage
Mega Sage

@AnkitS954229730 

 

Hide the Button Using CSS (in Client Script or Style):

  • If you find the EDIT button, you can either remove it directly from the markup or apply CSS to hide it.
  • Use the CSS class or ID assigned to the EDIT button and apply a display: none; style to it.

Example:

 

.edit-button-class {  /* Replace with the actual class or ID */
    display: none;
}

 

If the button doesn’t have a class, you can inspect the DOM to find an element identifier or manually add one to hide it.

Use a Client Script for Conditional Display: You can also use client scripts to hide the button programmatically. For example, if the button is part of a form or page in the workspace, you can hide it conditionally:

 

document.querySelector('.edit-button-class').style.display = 'none';  // Replace with actual selector

 

This script can be added within the Workspace Page Definition to control when and where the button is hidden.

 

✔️ If this solves your issue, please mark it as Correct.


✔️ If you found it helpful, please mark it as Helpful.



Shubham Jain


Rajender1
Mega Sage
Mega Sage

Hi @AnkitS954229730 ,

This is the functionality available in Preview Document Ui action which is having ui pages.

You need to go to Ui pages then search for 'preview_html_document_dialog'.

now open and in HTML code check for  'edit_button' in line no 139 then replace that line of code with below one:

<button id="edit_button" class="btn btn-primary" onClick="return clickEdit();" >

and save then you can see edit button.

 

Thank you Rajender, This was very helpful.

Rajender1
Mega Sage
Mega Sage

@AnkitS954229730  did you able to solve this?