How to make name value pair data type field read only?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2018 04:21 AM
Hi,
Please let me know how to make the name value pair field read only. Tried creating UI Policy, Client script and mentioning Read only in dictionary. its not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2021 04:30 AM
Hi Mark,
I am trying the achieve this functionality, but unfortunately this is not working for me.
The Try Catch error is '$ is not a function', and the execution stops at this line
var el = $('element.' + g_form.tableName + '.' + fieldName);
Currently in Quebec Release.
Appreciate your help here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2018 06:48 AM
Hi Mark,
Tried as you mentioned, still not working. can you please check once whether I missed anything.
function onLoad() {
setTimeout(readOnlyNameValue, 1000);
}
function readOnlyNameValue() {
try {
// Make the 'u_name_value' field read only
var fieldName = 'u_inf_sri_service_characteristics';
var el = $('element.' + g_form.u_inf_sri_customer_facing_service + '.' + fieldName);
// Disable inputs
el.select('input').each(function(elmt) {
elmt.disabled = true;
});
// Disable buttons
el.select('button').each(function(elmt) {
elmt.disabled = true;
});
} catch(e) {}
}
Thanks
Mani

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-09-2018 06:57 AM
It looks fine as long as that's really your field name. What version is your ServiceNow instance running on? Can you run it with some alerts like this and let me know what you see?
function onLoad() {
setTimeout(readOnlyNameValue, 1000);
}
function readOnlyNameValue() {
try {
// Make the 'u_inf_sri_service_characteristics' field read only
var fieldName = 'u_inf_sri_service_characteristics';
var el = $('element.' + g_form.tableName + '.' + fieldName);
alert('Element: ' + el);
// Disable inputs
el.select('input').each(function(elmt) {
alert('Disabling');
elmt.disabled = true;
});
// Disable buttons
el.select('button').each(function(elmt) {
elmt.disabled = true;
});
} catch(e) {}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2019 06:52 AM
It is actually working, but recently Client Script had a change in behaviour. Hope that helps.
"New client-scripts are run in strict mode, with direct DOM access disabled. Access to jQuery, prototype and the window object are likewise disabled. To disable this on a per-script basis, configure this form and add the "Isolate script" field. To disable this feature for all new globally-scoped client-side scripts set the system property "glide.script.block.client.globals" to false."