Jira spoke goes into a feedback loop

klefevre
Tera Contributor

We recently installed version 4.4.1 of the plug-in Jira Spoke onto our Vancouver instance.  We're using it as follows:

 

  • When a ServiceNow incident is created, the spoke is used to created a corresponding Jira issue.
  • When an existing ServiceNow incident is updated, the spoke is used to update the companion issue.
  • When the Jira issue is updated, the changes made are taken back to the companion incident.

The first two use cases were working perfectly and the parts of the third scenario that made sense were also working.  Then, the requester insisted that comments entered on the Jira card be taken back to the ServiceNow incident.  The comment was found in the spoke's payload and the comment isolated.  Management of this situation is handled in a flow action.  Since we didn't want to add another custom column to the incident table, the Jira key was placed in the description of the parent incident.

 

Here's the relevant code for the action:

 

if (workNotes && workNotes != '')  {
    // Get Jira issue key
    var jiraIssueKey = parsedJSON.issue.key;
    outputs.found = 'jira_issue_key: ' + jiraIssueKey + '\n';

    var qry = 'active=true^descriptionLIKE' + jiraIssueKey;
    outputs.found += 'qry: ' + qry + '\n';
    var wn = new GlideRecord('incident');
    wn.addEncodedQuery(qry);
    wn.query();
    outputs.found += 'count: ' + wn.getRowCount() + '\n';

    if (wn.next()) {
//        wn['work_notes'] = workNotes;
      wn.work_notes = workNotes;
        outputs.found += 'Update work notes by adding the following: ' + workNotes + '\n';  
        wn.update();
    }  
}

Based on what I found on-line, I made certain that the window with the incident in it was closed while I added the comment to the Jira issue. I added the following comment:


Another Jira note from 6:58.

 

The comment was added to the incident's work notes window. Then, the update to the incident fired off an update to the issue, which fired off an update to the incident.


This feedback went on for over an hour. On top of the comment entered on Jira, the following line appeared:
2024-09-05 06:59:08 - Guest (Work notes) - Then, above this line, the following appeared:
2024-09-05 06:59:35 - Guest (Work notes)
2024-09-05 06:59:31 - Guest (Work notes)
2024-09-05 06:59:26 - Guest (Work notes)
2024-09-05 06:59:20 - Guest (Work notes)
2024-09-05 06:59:15 - Guest (Work notes) - etc.

 

This went on for over an hour. As if this weren't bad enough, the comment blocks were copied back and forth. In the end, I had four blocks of 776 lines entered into the comment section of the Jira window. I had the same thing happen on the ServiceNow side.

 

In an attempt to find a solution, I rewrote the line wn.update() as wn.insert(). This fixed the comment/work note problem, but, instead, for each comment I entered on Jira, a new Jira issue was created.

 

After about 3 hours of searching on-line, I was unable to find a solution that caused this to work properly without either the feedback loop or the duplicate Jira issues.


I did see mention of using the gs.isInteractive() statement in business rules. There weren't any good examples of how to use it, so I wasn't able to figure out how to use gs.isInteractive() in the flow action. Also, it looked like using isInteractive() in an if ... else statement would cause ALL updates to be skipped in the case where
isInteractive() returned true. I don't want to completely disable cross-communication, I just don't want it to go into an uncontrolled loop.

 

Thanks in advance for your help.

0 REPLIES 0