- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 11:14 AM
Hi,
We need to make a variable on a record producer read only. It will be editable after incident is submitted, but should be read only for incident is closed. Please assist.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 01:55 PM
When the form is saved, it reloads, so you also need a similar onLoad Client Script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 12:21 PM
You could use a Client Script like this on the incident table:
function onLoad() {
if (g_form.getValue('state') == 7) { //Closed
g_form.setReadOnly('var_name', true); //your variable name
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 12:47 PM
Hi @Brad Bowman
The above script is not working. The variable that needs to be read only is part of record producer and it will be displayed under variables tab in an incident.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 01:39 PM
I have that mocked up in my PDI and the script works for me. Is the value of the State field on the incident you are looking at 7 for Closed or do you have something else in your instance? The script I suggested is onLoad, so it won't happen when the State value changes before the form is saved. Use an onChange script in addition if you want that to happen.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-04-2024 01:49 PM
Hi @Brad Bowman
Here's the script I have used:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
if (g_form.getValue('state') == 6) { //Resolved
g_form.setReadOnly('variables.type', true);
}
}
We need to make the field read only if state is resolved. When the state is set to resolved, it's being set to read only, but becomes editable once i save the form. I believe something else is interfering with this field, but this is the newly created field