Getting error No such property: previous for class

Originally asked by Erika Pillmeier on 18 November 2019 (original question)


I’m trying to add status changes as comments using this:

if (!replica.status.equals(previous?.status)) {
// construct the comment
String message = "${replica.key}: Status updated from '${previous?.status?.name}' to '${replica?.status?.name}'"
issue.comments = commentHelper.addComment(message, issue.comments)
}

However, I keep getting the error:

No such property: previous for class

What am I missing?


Comments:

Francis Martens (Exalate) commented on 18 November 2019

Can you provide the whole incoming sync script?

The previous replica is not available when doing the first synchronisation.

Answer by Erika Pillmeier on 19 November 2019

That makes sense. So actually it has to be:

if (!firstSync && !replica.status.equals(previous?.status)) {
  // construct the comment
  String message = "${replica.key}: Status updated from '${previous?.status?.name}' to '${replica?.status?.name}'"
  issue.comments = commentHelper.addComment(message, issue.comments)
}

Works now. Thanks so much!


Comments:

Francis Martens (Exalate) commented on 19 November 2019

We will be adding previous also in the firstSync, but keep it empty such that it doesn’t throw this horrific error.

Thanks for sharing the solution.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.