Questions for Confluence license has expired.

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

Update custom filed

 
1
0
-1

Hi,

I have the following code in order to sync fixVersions filed with customer "Fix in versions" filed:
issue.customFields."Fix in version".value = replica.fixVersions?.collect

{it.name}.join(",")

It works fine!
But, I want this code will run only when fixVersions filed is updated and not every time.
I tried something like:

if (replica.fixVersions.updated?){
issue.customFields."Fix in version".value = replica.fixVersions?.collect{it.name}

.join(",")
}

It doesn't work, I guess my "if" condition syntex is not right.
What do I need to put in the condition?

Thanks!
Sapir

    CommentAdd your comment...

    2 answers

    1.  
      1
      0
      -1

      you can try by comparing with previous fixVersions


      previousFixVersions = previous?.fixVersions
      currentFixVersions = replica?.fixVersions
              if (previousFixVersions != currentFixVersions){ 

      //your code here

      }


      or 


      if (!replica?.fixVersions?.equals(previous?.fixVersions){
      //your code here
      }

      Nota: there is a known issue in Groovy causing that x.equal.y sometimes is not the same as x == y. The first option always worked for me.

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

        Awesome!
        The first works like a cream, thanks a lot! (smile)

          CommentAdd your comment...