It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Duplicated comment added during transition

Arianna Fabbri Nov 09, 2014

Good morning,

I'm running the below script but I'm not understanding why the target issue is updated with duplicated comment

import [...]

log = Category.getInstance("com.onresolve.jira.groovy.CreateDependentIssue")
log.debug "Debug statements " +

def BEprojectName = issue.getProjectObject().name
def SDProjectName = BEprojectName.substring(8,BEprojectName.length())
log.debug "BEProject: " + BEprojectName
log.debug "SDProject: " + SDProjectName

// Variables definition
ComponentManager             componentManager =         ComponentManager.getInstance()
IssueManager                 issueManager =             componentManager.getIssueManager()
ProjectManager                 projectManager =         componentManager.getProjectManager()
IssueFactory                 issueFactory =             componentManager.getIssueFactory()
JiraAuthenticationContext     authContext =             componentManager.getJiraAuthenticationContext()
CustomFieldManager             customFieldManager =     componentManager.getCustomFieldManager()
IssueIndexManager            indexManager =             componentManager.getIndexManager()
JiraWorkflow                 workflow =                 componentManager.getWorkflowManager().getWorkflow(issue)
IssueLinkManager             issueLinkManager =         componentManager.getIssueLinkManager()
IssueService                 issueService =             componentManager.getIssueService()
UserManager                 userManager =             (UserManager) ComponentAccessor.getUserManager()
IssueChangeHolder             changeHolder =             new DefaultIssueChangeHolder()

def wasIndexing = ImportUtils.indexIssues
ImportUtils.indexIssues = true

boolean existingLinkedCode = false

for (IssueLink issueLink in issueLinkManager.getInwardLinks({
    if( == "Trigger"){
        existingLinkedCode = true
        SDIssue = issueLink.sourceObject  
        String SDIssueKey = SDIssue.key
        log.debug "Inward linked issue: " + SDIssue.key
log.debug ("Search result: " + existingLinkedCode)

// Transition on original issue
if(existingLinkedCode == true){

    // Workflow Transition: extract details from transition properties (ex. user comment, transitionID, assignee...)
    def wfd = workflow.getDescriptor()
    def transitionComment = transientVars["comment"]
    def actionId = transientVars["actionId"]
    log.debug "comment: " + transitionComment 
    log.debug transientVars

    log.debug("Update original issue's status")
    def com.atlassian.crowd.embedded.api.User currentUser = ComponentManager.instance.jiraAuthenticationContext.getLoggedInUser()
    // Define parameters needed during issue workflow transition
    IssueInputParameters issueInputParameters = issueService.newIssueInputParameters()
    IssueService.TransitionValidationResult transitionValidationResult = issueService.validateTransition(currentUser, SDIssue.getId(), actionId, issueInputParameters)
    if (transitionValidationResult.isValid())
        log.debug "Transition Validation VALID"
        def transitionResult = issueService.transition(currentUser, transitionValidationResult)
        if (!transitionResult.isValid())
            log.debug "Transition result INVALID"
            log.debug "Transition result VALID"            
        log.debug "Transition Validation INVALID"
    log.debug("No existing links")

In my log file:

Debug statements 17478
BEProject: Backend ZS Support
SDProject: ZS Support
Inward linked issue: ZS-17
Search Result: true
comment: Commento
update original issue's status
Transition Validation VALID
Transition result VALID

When I open the new linked issue I see comment "Commento" twice.


Why this?


Thank in advance for your help


2 answers

1 accepted

1 vote
Answer accepted
JamieA Nov 10, 2014

And regarding why you see the log statements twice, are you running this as a listener? It will run for the source issue and the issue you update, sunject to which events you are listening for, same applies to workflow functions if the target issue has the same workflow. 

1 vote
JamieA Nov 10, 2014

There is a bug in jira, it's related to skipScreenCheck. If you remove that, and you have a screen for that transition, you will only get the comment once.

Basically skipScreenCheck doesn't seem to work properly:

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar invitation: Generate custom Jira Cloud PDF reports and exports

Jira may be a staple part of your workday, but your colleagues, customers, business partners or an auditor might need information presented in a different format, that is easy to access and read. And...

65 views 0 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you