- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 01:06 AM
Hi all,
When you have a form in Service Portal with a reference variable, whenever you click the (i) icon next to the field, you get a preview of the record. I don't want anyone to be able to edit what appears in the record preview, not even admin.
How can I accomplish this? I have been looking at two different solutions so far, neither of them have done anything for me:
https://www.servicenow.com/community/developer-forum/make-preview-page-in-csm-portal-reference-field...(This one is about CSM Portal so maybe that's why it doesn't work)
https://www.servicenow.com/community/developer-forum/make-records-read-only-in-service-portal-copy-o...(This one looked promising but does nothing)
To complicate matters, I want this to apply to all records. So either I need a global ACL (but only for Service Portal) or client script or UI policy that sets readonly for all of these different records. For the first solution above, I tried applying a readonly UI policy to the table item_option_new, but I'm not even sure that is the correct one.
All help much appreciated!
Kim
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-13-2024 03:22 AM
Hey,
If you don't fancy messing around with AngularJS you can add a global onLoad client script with the UI Type set to 'service portal' with the below script.
function onLoad() {
if(typeof g_modal == 'undefined')
return;
if(typeof this.jQuery == 'undefined')
return;
if(!this.jQuery('#widget-form'))
return;
var pModal = this.jQuery('#widget-form').parents('.modal');
if(!(pModal instanceof this.jQuery) || pModal.length == 0)
return;
g_form.getFieldNames().forEach(function(field){
//g_form.setMandatory(field , false);
g_form.setReadOnly(field, true);
});
}
Note: g_form.setReadOnly is only a visual deterrent, a user could be savvy enough to modify a field to allow editing and save to the db
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2024 04:49 AM
You are right, don't know why it was only reference fields at first. All fields on all tables are locked down now when opened in SP popup view.
Marking your initial reply as solution. Thanks a lot!
