I cannot set reference field modal window to read-only in Employee Center
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
My team and I are developing some catalog items in our instance and we have noticed that the information icon in reference fields on the employee center opens an editable modal window as seen in the images (first one opens the second):
We would like this icon to appear and to show the information, but we would also like it to be read-only. How can we do this?
Thanks for everything!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Hi @jordimsant
May you try via UI policy or catalog script to set read-only
g_form.setReadOnly(<field_name>, true)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11 hours ago
Do you mean that for the catalog item, we set all the fields from the referred table to be read only? Wouldn't this force us to repeat this client script for every reference field in every catalog item?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
@jordimsant
it's depends... if you have many catalogs with different variables that you need set read-only, yes, will be necessary create one by one
Now, if the variables are the same but different catalogs, is possible create a script include
setReadOnlyVariables: function(g_form, varList) {
if (!varList || varList.length === 0)
return;
for (var i = 0; i < varList.length; i++) {
g_form.setReadOnly(varList[i], true);
}
}
},
in or catalago client script > onLoad
function onLoad() {
var variables = ['opt1', 'opt2', 'opt3']; // variables name
var utils = new CatalogUtils();
utils.setReadOnlyVariables(g_form, variables);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10 hours ago
are you checking with admin or non-admin?
If non-admin then did you check if that user has write access to that table?
if yes then it will allow user to edit
If you want to make it readonly for all then this link has solution
Make record preview readonly in Service Portal (all records)
Another way to make entire form readonly when somebody clicks Preview is
1) create onLoad client script on that table being referred and use this logic
function onLoad() {
//Type appropriate comment here, and begin script below
if(top.location.href.indexOf('sc_cat_item') > -1){
g_form.getFieldNames().forEach(function(field){
//g_form.setMandatory(field , false);
g_form.setReadOnly(field, true);
});
}
}
I just did this and it worked, this is another approach, it does show Save button but none of the fields are editable
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader