- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 12:20 AM
Hi,
I am faced with a bit of an issue where an inactive ticket can have comments updated, state changes even though it remains inactive (uneditable in form view). tried playing around with BRs and not getting the desired results.
Any suggestions?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 03:01 AM
Hi @Lesiba Kgomo ,
Hope you are doing great.
To prevent the state from changing when a user responds to an inactive ticket, I would recommend Before Business Rule. This approach allows us to intervene before the state is updated and apply the necessary logic to prevent the change.
example code snippet that you can utilize in your ServiceNow instance:
(function executeRule(current, previous /*, gs*/) {
if (current.state == 4 /*Inactive*/ && current.comments.changes()) {
// Reset the changes to prevent the state from being updated
current.comments.revert();
// Optionally, you can display an error message to the user
gs.addErrorMessage("You are not allowed to update comments on an inactive ticket.");
}
})(current, previous /*, gs*/);
Regards,
Riya Verma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 01:07 AM
Hi, For example from list view it moves the ticket to active and editable and with email response from users it changes the state only and Active remains false. i need a way to prevent the state from changing when a user responds to an inactive ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-21-2023 03:01 AM
Hi @Lesiba Kgomo ,
Hope you are doing great.
To prevent the state from changing when a user responds to an inactive ticket, I would recommend Before Business Rule. This approach allows us to intervene before the state is updated and apply the necessary logic to prevent the change.
example code snippet that you can utilize in your ServiceNow instance:
(function executeRule(current, previous /*, gs*/) {
if (current.state == 4 /*Inactive*/ && current.comments.changes()) {
// Reset the changes to prevent the state from being updated
current.comments.revert();
// Optionally, you can display an error message to the user
gs.addErrorMessage("You are not allowed to update comments on an inactive ticket.");
}
})(current, previous /*, gs*/);
Regards,
Riya Verma
