Questions for Confluence license has expired.

Please purchase a new license to continue using Questions for Confluence.

Error when configuring status mapping

 
1
0
-1
I have a problem configuring the following requirement: Set the status of the remote project to Accepted Example: GIVEN Local project AND Status = NEW THEN sync to remote project AND set status in remote project to ACCEPTED using the transition "Accepted as a bug" I've read the documentation on https://docs.idalko.com/exalate/display/ED/Status+synchronization+on+Jira+Server#StatussynchronizationonJiraServer-statusSyncExternal and followed the instruction 'transition applied to your local issue' that results in the incoming sync of the remote project: if (issue.status.name == "New" && replica.status.name == "Open") { workflowHelper.transition(issue, "Accepted as a bug") When trying to sync, I get an error message “Script error details: Cannot get property 'name' on null object. Error line: Script349.groovy: 8 " What am I doing wrong? Thanks! Berry.
  1. Berry Kersten

    Hi Francis Martens (Exalate), yes, but I also tried to execute the logic  after the firstSync and I got the same error.

    For completeness, the configuration:


    Outgoing sync (source):

    replica.key = issue.key
    replica.type = issue.type
    replica.assignee = issue.assignee
    replica.reporter = issue.reporter
    replica.summary = issue.summary
    replica.description = issue.description
    replica.labels = issue.labels
    replica.comments = issue.comments
    replica.resolution = issue.resolution
    replica.status = issue.status
    replica.parentId = issue.parentId
    replica.priority = issue.priority
    replica.attachments = issue.attachments
    replica.project = issue.project
    replica.environment = issue.environment
    replica.customFields."Product" = issue.customFields."Product"


    Incoming sync (remote side)

    def projectMap = ["Technical DLM/licensing":"DLM","Uniface Anywhere Issue":"UA","Uniface Issue":"UNI"]
    if (firstSync) {


    // look up project key using the issuetype.name and if not found default to DLM
    issue.projectKey = projectMap[replica.type.name] ?: "DLM"


    }

    issue.summary = replica.summary
    issue.description = replica.description
    issue.comments = commentHelper.mergeComments(issue, replica)
    issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
    issue.environment = replica.environment
    issue.customFields."Workaround".value = replica.customFields."Product".value?.value
    issue.typeName = "Bug"


    //if the local issue status is 'New' and the remote issue status is 'Open' use 'Accepted as a bug' transition
    if (issue.status.name == "New" && replica.status.name == "Open") {
    workflowHelper.transition(issue, "Accepted as a bug")
    }

  2. Francis Martens (Exalate)

    The statement 'if (issue.status ...) is also executed during the first sync.
    What you can do is 



    if ((issue.status == null || issue.status?.name == "New") && 
        replica.status.name == "Open")


    Note the '?'

    This is a groovy operator allowing to test for null - avoiding a nullpointer exception

    Meaning - 


    issue.status = null
    assertNull(issue.status?.name)
  3. Berry Kersten

    I've changed the incoming sync to

    def projectMap = ["Technical DLM/licensing":"DLM","Uniface Anywhere Issue":"UA","Uniface Issue":"UNI"]
    if (firstSync) {
    
    // look up project key using the issuetype.name and if not found default to DLM
    issue.projectKey = projectMap[replica.type.name] ?: "DLM"
    
    // old code workflowHelper.transition(issue,"Accepted") ?: "Backlog"
    }
    issue.summary = replica.summary
    issue.description = replica.description
    issue.comments = commentHelper.mergeComments(issue, replica)
    issue.attachments = attachmentHelper.mergeAttachments(issue, replica)
    issue.environment = replica.environment
    issue.customFields."Workaround".value = replica.customFields."Product".value?.value
    issue.typeName = "Bug"
    
    //if the local issue status is 'New' and the remote issue status is 'Open' use 'Accepted as a bug' transition
    if ((issue.status == null || issue.status?.name == "New") && 
    replica.status.name == "Open") {
    workflowHelper.transition(issue, "Accepted as a bug")
    }

    and the error is gone!


    However, when syncing the issue is not transitioned with "Accepted as a bug" to status ACCEPTED

    I also tried to move

    if ((issue.status == null || issue.status?.name == "New") && 
    replica.status.name == "Open") {
    workflowHelper.transition(issue, "Accepted as a bug")

    to the firstsync section, but still no transition.


    I'm not sure how to proceed further.




  4. Francis Martens (Exalate)

    Hi Berry Kersten


    Are you sure about the transition name?

    (In case the transition doesn't exist or if the proxy user is not permitted the transition, no error will be generated)


    I quickly tested a simple script


    if(firstSync){
       // If it's the first sync for an issue (local issue does not exist yet)
       // Set project key from source issue, if not found set a default
       issue.projectKey   = "NAM"
       // Set type name from source issue, if not found set a default
       issue.typeName     = "Task"
    }
    issue.summary      = replica.summary
    issue.description  = replica.description
    issue.comments     = commentHelper.mergeComments(issue, replica)
    issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)
    
    workflowHelper.transition(issue,"In Progress")


    And this work fine.


    An alternative is to enable debug logging and inspect the log files.



  5. Berry Kersten

    Hi Francis Martens (Exalate)Thanks. It's working now.

    Main problem: case sensitivity...

  6. Francis Martens (Exalate)

    Ah yes. 

    Thanks for confirming.

CommentAdd your comment...

1 answer

  1.  
    1
    0
    -1

    Hello Berry Kersten


    Is the logic executed during the first sync? 
    If this is the case, issue.status might be null (as the issue is not yet created) 


      CommentAdd your comment...