Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-23814

Unexpected behaviour with IssueInputParameters.setComment()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Low Low
    • None
    • 4.2, 5.2.5, 6.3.15
    • Java API
    • Linux standalone

      Summary

      IssueInputParameters doesn't create a comment during transition or adds a duplicate comment when the transition has a screen

      Steps to Reproduce

      Try to add a comment to an issue programatically using IssueInputParameters.setComment() during a transition having no transition screen. For example, I've created a Groovy script that I run via ScriptRunner. This script runs in a post function. In the script, I'm setting a transition comment. Here is the relevant section of the code I'm executing:

       
      
      final String SYSTEM_USER = "system";
      User systemUser = ComponentManager.getInstance().getUserUtil().getUser(SYSTEM_USER);
      ...
                  IssueInputParameters issueInputParameters = new IssueInputParametersImpl();
                  // comment not showing up
                  issueInputParameters.setComment("All issues depended on are either resolved or closed.");
      
                  TransitionValidationResult transitionValidationResult = issueService.validateTransition(systemUser,
                     linkedIssue.getId(), ALL_WAITING_ISSUES_RESOLVED_ACTION_ID, issueInputParameters);
      
                  if (transitionValidationResult.isValid())
                     {
                     IssueResult transitionResult = issueService.transition(systemUser, transitionValidationResult);
      
                     if (transitionResult.isValid())
                        {
                        log.debug("Issue " + linkedIssue + " successfully transitioned out of WAITING ISSUE status");
      
                        // See above, comment submitted with transition is not showing up, so we add one ourselves.
                        linkedIssue = issueManager.getIssueObject(linkedIssue.getKey());
                        commentManager.create(linkedIssue, SYSTEM_USER, "All issues depended on are either resolved or closed.", true);
                        }
                     else
                        {
                        log.debug("Issue " + linkedIssue + " transitionResult not valid");
                        }
                     }
                  else
                     {
                     log.debug("Issue " + linkedIssue + " transitionValidationResult not valid");
                     }
                  }
      
      
      

      Expected results

      Comment is added to issue along with other fields.

      Actual results

      1. Comment is not getting added to the issue for transitions that have no screen. I then separately add the comment using the same user account, and that is successfully added to the issue.
      2. When there is actually a transition screen and skipScreenCheck is set to true on the IssueInputParameters, duplicate comments get added.

            Unassigned Unassigned
            90cbfe708f74 Guy Rouillier
            Votes:
            20 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated: