- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 04:05 AM
Hello!
I want to allow on incident state modification from list view for ITIL users but not allow to change state to resolve in case if specific mandatory fields (for example closure note) are empty.
First part seems to be easy - I can add itil role to proper ACL in which operation is list_edit.
But I don't know how to restrict this in case if user would like to resolve inc from list view when mandatory fields are empty.
Should I create some specific script condition directly on ACL? Also I would be so much grateful if you could provide some example script template for this condition.
Other my Idea is create Business rule (before insert/update) on incident form?
or maybe data policy would be good?
Thank you in advance for any help and guidence.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 05:53 AM
Hi
Allowing ITIL Users to Modify Incident State from List View:
- As you mentioned, you can add the ITIL role to the proper ACL with the list_edit operation. This will allow ITIL users to modify the incident state from the list view.
Restricting State Change to “Resolved” When Mandatory Fields Are Empty:
To achieve this, you can use a combination of UI Policies and Client Scripts. Here’s how:
UI Policy:
- Create a UI Policy that triggers when the State field changes to “Resolved.”
- In the UI Policy condition, check if the mandatory fields (such as Closure Note) are empty.
- If any mandatory field is empty, set the State field back to its previous value (e.g., “In Progress”) and display an error message.
Client Script (onChange event for the State field):
- In the client script, listen for changes to the State field.
- If the new value is “Resolved” and the mandatory fields are empty, prevent the change and display an error message.
- Example client script template:
function onChangeState(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === 'Resolved') {
// Check if mandatory fields are empty (e.g., Closure Note)
if (g_form.getValue('closure_note') === '') {
g_form.addErrorMessage('Please fill in the Closure Note before resolving the incident.');
g_form.setValue('state', oldValue); // Set back to previous state
}
}
}
Business Rule vs. UI Policy:
- You can also achieve this using a Business Rule (before insert/update) on the incident form.
- However, UI Policies are more suitable for client-side validations and interactions.
- If you prefer server-side logic, a Business Rule can work as well.
Data Policy:
- Data Policies are typically used for data integrity and data transformation.
- While you can enforce mandatory fields using Data Policies, they are not ideal for this specific use case.
I hope its useful to you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 05:53 AM
Hi
Allowing ITIL Users to Modify Incident State from List View:
- As you mentioned, you can add the ITIL role to the proper ACL with the list_edit operation. This will allow ITIL users to modify the incident state from the list view.
Restricting State Change to “Resolved” When Mandatory Fields Are Empty:
To achieve this, you can use a combination of UI Policies and Client Scripts. Here’s how:
UI Policy:
- Create a UI Policy that triggers when the State field changes to “Resolved.”
- In the UI Policy condition, check if the mandatory fields (such as Closure Note) are empty.
- If any mandatory field is empty, set the State field back to its previous value (e.g., “In Progress”) and display an error message.
Client Script (onChange event for the State field):
- In the client script, listen for changes to the State field.
- If the new value is “Resolved” and the mandatory fields are empty, prevent the change and display an error message.
- Example client script template:
function onChangeState(control, oldValue, newValue, isLoading, isTemplate) {
if (newValue === 'Resolved') {
// Check if mandatory fields are empty (e.g., Closure Note)
if (g_form.getValue('closure_note') === '') {
g_form.addErrorMessage('Please fill in the Closure Note before resolving the incident.');
g_form.setValue('state', oldValue); // Set back to previous state
}
}
}
Business Rule vs. UI Policy:
- You can also achieve this using a Business Rule (before insert/update) on the incident form.
- However, UI Policies are more suitable for client-side validations and interactions.
- If you prefer server-side logic, a Business Rule can work as well.
Data Policy:
- Data Policies are typically used for data integrity and data transformation.
- While you can enforce mandatory fields using Data Policies, they are not ideal for this specific use case.
I hope its useful to you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2024 01:44 PM
Thank you so much , client script is my favorit solution:) Thank you so much for help!