Make one value in Choice list "read only".

andersn
Giga Contributor

Hi,

Is it possible to make one value in State "read only". What im trying to accomplish is to make State "New" read only for incident, so that this state isn't possible to set manually, only by rules..

Anyone tried anything similar?

1 ACCEPTED SOLUTION

Chuck Tomasi
Tera Patron

Sorry Anders. It's a function of most browsers that choice lists (aka select lists) display the values they have. You could use an onLoad client script to remove the option.



g_form.removeOption('state', 'New'); //Adjust New to the proper state VALUE, e.g. 1)



Reference:


GlideForm (g form) - ServiceNow Wiki


View solution in original post

11 REPLIES 11

Chuck Tomasi
Tera Patron

Sorry Anders. It's a function of most browsers that choice lists (aka select lists) display the values they have. You could use an onLoad client script to remove the option.



g_form.removeOption('state', 'New'); //Adjust New to the proper state VALUE, e.g. 1)



Reference:


GlideForm (g form) - ServiceNow Wiki


But this will remove the option? When State = New i want users to see this, but that it shouldn't be able to choose this state after it's moved to another State (assigned)


andersn
Giga Contributor

I have disccused it with the customer now. I think i can use this solution. Just have a condition that says if state != New, remove the option


ramireddy
Mega Guru

You can create a new client script for "Incident" table with "onload" event. Then you can disable that option using below 2 lines.



var statefield = g_form.getElement("state");


statefield.options[0].setAttribute("disabled","true");



Assumption is "New" option will be first option, which is usually. If not, you need to iterate through and find.