State should move to in progress if reopen intent is choose
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2025 10:58 AM
Hi All,
Objective:
When an incident is created, its initial state is New. It is then assigned to an Assignment Group and a specific User, which changes the state to In Progress.
Once the developer works on it, the incident is moved to the Resolved state.
If the Caller (Requested by) adds a comment containing reopen keywords, the incident should transition back to In Progress.
If the caller adds gratitude keywords like "thank you", "solved", etc., the incident should remain in the Resolved state.
The current implementation behaves as expected during the first cycle of the workflow. Here's the test scenario:
First Cycle:
- Incident created → State: New
- Assigned to group and user → State: In Progress
- Developer resolved the incident → State: Resolved
- Caller added comment:
- Gratitude keyword → State remains Resolved ✅
- Random text → State remains Resolved ✅
- Reopen keyword → State changes to In Progress ✅
Everything works fine in this cycle.
Second Cycle (After Reopen):
- Developer worked again and moved it to Resolved
- Caller added another comment:
- Gratitude keyword → State changes to In Progress ❌ (Should remain Resolved)
- Random text → State changes to In Progress ❌ (Should remain Resolved)
- Reopen keyword → State changes to In Progress ✅
Issue:
The logic works correctly during the first cycle, but in the second cycle, even non-reopen comments are incorrectly triggering a transition to In Progress.
Let me know if you'd like help reviewing or updating the code logic to fix this behavior.
code:
BR : After update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2025 05:01 PM
I suspect what is happening is that the var comment is not grabbing just the last comment but ones prior to that as well. Try logging the comment variable out to see what is in it. The info message might not be showing all, of it.
Also you might want to stick your gratitude and reopen keywords into a property rather than keeping the long lists in the script itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-09-2025 12:26 PM
You should create Before business rule on Incident table runs on update.
The business rule should run when Incident state is Resolved and Additional Comments changes.
(function executeRule(current, previous /*null when async*/) {
// Get the journal entry (comments/work notes)
var journal = current.comments.getJournalEntry ( 1 ) ;
// Check if journal exists and is not empty
if (!journal || journal == '') {
return;
}
// Check if the comment contains "reopen" (case insensitive)
if (journal.toLowerCase().indexOf('reopen') > - 1 ) {
// Verify the comment was added by the caller
var userId = gs.getUserID();
var callerId = current.caller_id.toString();
if (userId == callerId) {
// Change state to In Progress (state = 2)
current.state = 2;
// Optional: Add a work note to track the automatic state change
current.work_notes = 'Incident automatically reopened due to caller comment containing "reopen"';
gs.addInfoMessage('Incident has been reopened and set to In Progress');
}
}
})(current, previous);
