- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2021 06:59 PM
Hi All,
Hope all is well.
We have a requirement to disable the copy and paste functionality in one of our variable field in Service Catalog.
Type: Multi line Text
The below code works in ITIL/ native view but not in Service Now Portal.
Is there any way to make this work in Service Now Portal?
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2021 07:36 PM
You can do this in the Service Portal, but only by using jQuery. Something like this seems to work.
Create an onload client-script, UI Type of all and make sure that Isolate Script is set to false (unchecked) - if it's not visible on the script form, you can add it to the list view and make the change there.
Quick edit, this does not work in the UI, so actually you want to make the UI Type Mobile / Service Portal
In my example I had a field name textfield. You need to update the selector in the jQuery to match your field name.
function onLoad() {
//replace #textfield with #yourfieldname
setTimeout(function() {
this.jQuery("#textfield").bind('copy paste cut', function(e) {
e.preventDefault();
});
}, 500);
}
I don't usually recommend DOM manipulation that changes functionality but, in this instance, as long as this is a somewhat isolated use-case, this is an acceptable use - just be sure to document what it does in the script!
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2021 07:20 PM
Hi,
Unfortunately, g_form use of getControl() is not supported on the service portal.
Please see this link for more information: https://snprotips.com/service-portal-dom-access-mandatory-attachments
Please mark reply as Helpful/Correct, if applicable. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2021 07:36 PM
You can do this in the Service Portal, but only by using jQuery. Something like this seems to work.
Create an onload client-script, UI Type of all and make sure that Isolate Script is set to false (unchecked) - if it's not visible on the script form, you can add it to the list view and make the change there.
Quick edit, this does not work in the UI, so actually you want to make the UI Type Mobile / Service Portal
In my example I had a field name textfield. You need to update the selector in the jQuery to match your field name.
function onLoad() {
//replace #textfield with #yourfieldname
setTimeout(function() {
this.jQuery("#textfield").bind('copy paste cut', function(e) {
e.preventDefault();
});
}, 500);
}
I don't usually recommend DOM manipulation that changes functionality but, in this instance, as long as this is a somewhat isolated use-case, this is an acceptable use - just be sure to document what it does in the script!
I hope this helps!
If this was helpful or correct, please be kind and remember to click appropriately!
Michael Jones - Proud member of the CloudPires team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-26-2021 06:30 PM
Thank you so much Michael! This works for us.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2023 07:30 PM
The above client script not working in incident module. I have a requirement in which user should not copy paste the sentence in the field. I tried the above onload client script but its not working. Please suggest.