Set value of read only field

sigmachiuta
Kilo Guru

I am running a client script that will set the value of a read only field (by ACL).   I am needing to update this field in a client script but since it is read only I am not able to update the field.   How can I set the field in a client script with it being read only.   It works if I try with my admin account (the acl only allows admins to update the field)

I have tried with g_form.setReadOnly but that didnt work.

var answer = confirm('This incident will be marked Resolved?');

if (answer == true){

g_form.setReadOnly('u_resolved','false');

g_form.setValue('u_resolved','true');

                                                                                             

}

else g_form.setValue('u_resolved','false');

                                                              }

}

8 REPLIES 8

Here is the design, I am more than willing to change but with the requirements I am not sure what to do.


The user opens a ticket, they have 5-6 checks to be considered a 'First time Resolved'   If all of these conditions are met there is an onChange client script that runs if the incident changes to the resolved state.


Problem 1.   They can select resolved from the dropdown as well as the UI Action so I cant set this in the OOB UI action of 'resolve Incident' because the user would bypass this by selecting from the drop down.   When the on change script runs (the state field to 'resolved') a confirmation box pops up asking if they resolved the incident on the first go-around.   If they select 'Yes' then the checkbox on the field is true.   The only way i can see around this is make the checkbox acl to make the ITIL users able to write to this field and hide the box, but the users would not have an indication this field is checked.   Any ideas?


If it was me, I'd make the "First Time Resolved" field writeable by ITIL users in your ACL and then add a UI policy to make the field read-only.   At that point you should be able to add an onChange client script to update the field (you should be able to change the display value of a read-only field) and it should save.  


This is also a good way to solve the problem.


If you can't trust your ITIL users to not change things surreptitiously, who can you trust?


Hi sigmachiuta,



So the field you are concerned with is the "First Time Resolved" field?


What are the conditions under which the incident is considered "First Time Resolved"?



I agree with Jamie Girouard- this is probably best solved by a Business Rule.



If the incident is *opened and resolved* in the same step- if the ITIL user is the one creating the incident, filling it out, and resolving it all int he same step- then you can easily do your checks in a "before insert" Business Rule, and set the value of the field if your conditions pass.



If the ITIL user wont be the one doing the initial insert of the record, then you can use a similar rule, and trigger it on something like "state changesFrom New" and "state changesTo Resolved". Again, you can key off the same criteria you are using client-side, and set the field automatically.



Does that make sense?