- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:01 AM
Hi
While creating Incident, I need State and Assigned to fields become read-only, after incident creation those two fields become editable, please help me how to achieve this?
Thanks,
Shiva
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:06 AM
Please use an onLoad Client Script to achieve your requirement.
function onLoad() {
if(g_form.isNewRecord() ) {
g_form.setReadOnly("state", true);
g_form.setReadOnly("assigned_to", true);
}
}
Please hit like/accept as solution if it works for you.
Thanks,
Harish Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:06 AM
Please use an onLoad Client Script to achieve your requirement.
function onLoad() {
if(g_form.isNewRecord() ) {
g_form.setReadOnly("state", true);
g_form.setReadOnly("assigned_to", true);
}
}
Please hit like/accept as solution if it works for you.
Thanks,
Harish Kota
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:57 AM
Thank you Harish for the script, It works me.
Thank you all for your responses, I have accepted Harish solution as he has given first reply.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:10 AM
Write a onload client script on incident table with below script:
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 05:23 AM
There are two ways to do achieve this requirement. Approach shared below:
The client script will check if the incident is new and, if it is, it will set the State and Assigned To fields to read-only.
Code snippet
function onLoad() {
if(g_form.isNewRecord() ) {
g_form.setReadOnly("state", true);
g_form.setReadOnly("assigned_to", true);
}
}
ACL
The ACL will restrict users from editing the State and Assigned To fields, except for when the incident is new.
rule incident_state_readonly {
when {
// The incident is new.
incident.getState() == 'New'
}
then {
// Allow users to edit the incident state and assigned to fields.
allow update incident.state;
allow update incident.assigned_to;
}
}
Once you have added the client script/ACL, the State and Assigned To fields will be read-only when you create a new incident. After the incident has been created, the fields will be editable.
Please let me know if my feedback was helpful and resolved your issue. If it was, please click the "Helpful" button below.
I appreciate your feedback! It helps me to improve my responses and better serve you in the future.