How to make name value pair data type field read only?

Manimozhi1
Kilo Contributor

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

8 REPLIES 8

Andrew Barnes -
ServiceNow Employee
ServiceNow Employee

Greetings Manimozhi,

 I seem to have the same issue - so was able to replicate this issue. Might need to raise issue with HI.

-Andrew Barnes
Flow Designer London Learning Module: http://bit.ly/2ypjKUX

Mileu
Kilo Contributor

Mmm, which version are you working on?

 

I think you should try with this:

find_real_file.png

In London it works for all types I tested on. 

This solution will not work for Name Value, this is a bug in the snow, for other fields your solution will work.

 

Mark Stanger
Giga Sage

Seeing the same thing here.  I'd say it's a bug; ServiceNow would probably say it's just not supported yet :).  Either way, you can work around the issue with a client script.  It uses DOM manipulation, which I know is frowned upon, but this should be a great workaround until SN fixes or supports this for this field type.  Just change 'u_name_value' to the name of your field.  You could also change the 'elmt.disabled' line to 'elmt.hide()' if you just wanted to remove the +/- buttons instead of disabling them.

function onLoad() {
	setTimeout(readOnlyNameValue, 1000);
}

function readOnlyNameValue() {
	try {
		// Make the 'u_name_value' field read only
		var fieldName = 'u_name_value';
		var el = $('element.' + g_form.tableName + '.' + 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) {}	
}