2 answers
- 210
Francis Martens (Exalate) I´ve managed to make it work. I replace equals() with == operator and after that conditions become true or false depending on current is equals or not to previous.
From what I research, It seems there it is already known that Groovy´s x.equal().y not always returns TRUE ifs x == y
The working code looks like that (I have to add some lines to consider the first sync:
if (replica.customFields."Steps to Reproduce") { if(!firstSync){ previousSteps = previous?.customFields."Steps to Reproduce"?.value currentSteps = replica.customFields."Steps to Reproduce"?.value if (previousSteps != currentSteps){ String stepsToReproduce = replica.customFields."Steps to Reproduce".value issue.comments = commentHelper.addComment(stepsToReproduce, issue.comments) } else { // do nothing } } else { String stepsToReproduce = replica.customFields."Steps to Reproduce".value issue.comments = commentHelper.addComment(stepsToReproduce, issue.comments) } }
Thank you very much for your help.
- Francis Martens (Exalate)
Nice! good find.
Add your comment... - 10-1
Try to compare the values
if (!replica.customFields."Steps to Reproduce"?.value?.equals(previous?."Steps to Reproduce".value)
- Daniel
Francis Martens (Exalate) thanks for your answer. I tested using values but unfortunately I get the same results.
It looks as the comparison:
replica.customFields."Steps to Reproduce"?.value?.equals(previous?."Steps to Reproduce".value
is always false
I think this is because the previous value of the custom field is not stored or something like that.
I need to find a condition detecting when the value of the custom field (test) was updated.
The custom field only exist in one side, in the other side, I just need to post a comment every time the field is updated.
- Francis Martens (Exalate)
The previous will only be available after the first sync.
Can you check what the values are by addingdebug.error("current = '${replica.customFields."Steps to Reproduce"?.value}', previous = ${previous?.customFields."Steps to Reproduce"?.value})
When a new incoming message is processed, an error will be generated containing the details allowing you to understand what is going on
Add your comment...
Is it there a way to generate a local comment containing the value of a custom field every time this custom field is updated and do nothing when the custom field value was the same, in order to prevent to generate a duplicated comment every time any other field if synched.
I tried the following code, but it doesnt work, I got the duplicated comment in all syncs.