Questions for Confluence license has expired.

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

Cannot get property 'name' on null object. Error line: Script427.groovy:14

 
2
1
0
We get an error at the second iteration of the sync process. Incoming rules look as follows: 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 = "LNOC" // Set type name from source issue, if not found set a default issue.typeName = "Incident" } issue.summary = replica.summary issue.description = replica.description issue.comments = commentHelper.mergeComments(issue, replica) issue.attachments = attachmentHelper.mergeAttachments(issue, replica) issue.reporter = nodeHelper.getUser(replica.reporter?.key) //issue.reporter = nodeHelper.getUserByEmail(replica.reporter?.email) if (replica.status.name == "Escalated - Infra" && issue.status.name == "Waiting for customer" ) { workflowHelper.transition(issue, "Respond to support") } As I understand the error relates to the issue object and its status property, because when I remove it and keep only replica.status.name it starts working again. Please, advise how to fix this issue.
    CommentAdd your comment...

    2 answers

    1.  
      2
      1
      0

      Hi Viacheslav,


      As you discovered, this error only occurs when the issue hasn't been created, the workaround would be to use the following config in your script instead:


      if (issue.status) {
      * * 
          if (replica.status.name == "Escalated - Infra" && issue.status.name == "Waiting for customer") {    
      
           workflowHelper.transition(issue, "Respond to support")
      
          }
      }


      Thanks,


      André

        CommentAdd your comment...
      1.  
        1
        0
        -1

        To avoid the nullpointer, you can use the groovy safe navigation operator 

          CommentAdd your comment...