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.

Any way to prevent right-click on table forms?

Aki18
Tera Contributor

I would like to prevent users' right-click on table forms, but is there any way? I think it depends on web browser, though.

 

Best Regards,

Aki

13 REPLIES 13

Ankur Bawiskar
Tera Patron
Tera Patron

@Aki18 

you can't disable Right Click on Form/Record.

You can use UI script and DOM manipulation may be to hide some of the options when user right clicks but that's not recommended.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

Hi @Ankur Bawiskar ,

I created the following onLoad Client Script for Incident table with "Isolate script" = "false" and it successfully blocked the browser's right-click on the Incident form.
However, it didn't work when I created the script for custom table in the custom app. Does anyone know why it doesn't work?

 

 

function onLoad() {
  document.addEventListener('contextmenu', event => event.preventDefault());
}

 

 

 

@Aki18 

you should allow DOM in your scope by creating this system property

example: sn_customerservice.glide.script.block.client.globals would be the property name used for Customer Service application

Create similar for your scope an set it with false

Client scripts 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Aki18 

yes the above script disables right click on form but users can still inspect the page using developer tools (shortcut from chrome or other browsers)

AnkurBawiskar_0-1762438538822.png

 

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