The CreatorCon Call for Content is officially open! Get started here.

State should move to in progress if reopen intent is choose

BhanutejaRD
Kilo Contributor

 

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:

  1. Incident created → State: New
  2. Assigned to group and user → State: In Progress
  3. Developer resolved the incident → State: Resolved
  4. 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):

  1. Developer worked again and moved it to Resolved
  2. 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

(function executeRule(current, previous /*null when async*/ ) {
 
    // gs.addInfoMessage("Business Rule triggered");
 
    if (current.state != 6 || !current.comments.changes()) {
        // gs.addInfoMessage("State is not Resolved or no comment found");
        return;
    }
 
    var comment = current.comments.getJournalEntry(-1).toLowerCase();
    // var comment = current.comments.toLowerCase();
    // gs.addInfoMessage("Latest comment: " + comment);
 
    var acknowledgmentKeywords = [
        "got it", "understood", "noted", "acknowledged", "closing now", "received"
    ];
    var gratitudeKeywords = [
        "thank you", "thanks", "appreciate your help", "issue resolved", "problem is fixed",
        "no further action needed", "all good now", "confirmed working"
    ];
    var reopenKeywords = [
        "reopen", "reopened", "reopening", "issue persists", "not resolved", "problem still exists",
        "happening again", "recurring", "reoccurring", "still broken", "still facing issue",
        "didn’t fix", "no change", "failure after resolution", "workaround failed",
        "regression", "back again", "needs further investigation", "escalating again",
        "reoccurrence detected", "ongoing issue", "keeps happening", "reappeared",
        "happening once more", "no improvement", "still the same", "unsuccessful resolution",
        "solution not worked", "solution not solved", "same problem again"
    ];
 
    function containsKeyword(text, keywords) {
        for (var i = 0; i < keywords.length; i++) {
            if (text.indexOf(keywords[i]) > -1)
                return true;
        }
        return false;
    }
 
    if (containsKeyword(comment, reopenKeywords)) {
        // gs.info("Reopen keyword detected");
        current.state = 2; // In Progress
        current.update();
        // gs.info("Incident state changed to In Progress");
    }else {
        current.state =6;
        current.update();
    }
 
})(current, previous);




0 REPLIES 0