2
1
0

My customer have custom field named "Sprint" with values 1 , 2 , 3 , 4.


We have custom field named "Test Sprint" with values Test1, Test2, Test3, Test4.


Customer is the Master, My "Test Sprint" field needs to updated based on Custom field "Sprint".


1 - Test1

2 - Test2

3 - Test3

4 - Test4


Could you please suggest Outgoing and Incoming sync accordingly, Thanks.


    CommentAdd your comment...

    1 answer

    1.  
      1
      0
      -1

      Hi Madhu,


      Yes this should be possible with the following script, make sure you add this as an additional script to your Visual connection and make sure the part that says "executionInstanceName == "MyJira" " is changed to the name of the side where you want to set the Test Sprint custom field. 


      Script:

      if (executionInstanceName == "MyJira") {
      	def sprintMap = ["1":"Test1", "2":"Test2", "3":"Test3", "4":"Test4"]
      	def remoteSprintValue = replica.customFields."Sprint".value
      	issue.customFields."Test Sprint".value = sprintMap[remoteSprintValue]
      }


      Let me know how this goes!


      Thanks,


      André

      1. André Leroy-Beaulieu Castro

        Hey Madhu,


        Ok, then it would be like this:


        Outgoing Sync (Sending Side):


        replica.customFields."Sprint" = issue.customFields."Sprint"




        Incoming Sync (Receiving side):

        def sprintMap = ["1":"Test1", "2":"Test2", "3":"Test3", "4":"Test4"]
        def remoteSprintValue = replica.customFields."Sprint".value
        issue.customFields."Test Sprint".value = sprintMap[remoteSprintValue]


        Thanks,



        André


      2. André Leroy-Beaulieu Castro

        Hi Madhu,


        Outgoing Sync:

        replica.customFields."Dev Sprint" = issue.customFields."Dev Sprint"
        replica.customFields."Environment" = issue.customFields."Environment"


        Incoming Sync:

        def sprintMap = ...
        def remoteSprintValue = ...
        issue.customFields."SIT Sprint"?.value = nodeHelper.getOption(issue, "SIT Sprint", sprintMap[remoteSprintValue])
        
        def environmentMap = ...
        def remoteEnvironmentValue = ...
        issue.customFields."Phase"?.value = nodeHelper.getOption(issue, "Phase", environmentMap[remoteEnvironmentValue])


        The "..." just means you don't have to change anything there (wink)


        Let me know how this goes!


        Thanks,


        André

      3. André Leroy-Beaulieu Castro

        Hey Madhu,


        Well, I'm not completely clear on how your use case is, but the idea is that in the outgoing sync, the "issue.customFields."Sprint" / "Dev Sprint" needs to match the name of the field that you are sending, so if the on the sending side the field is called "Sprint" then the line should be:


        replica.customFields."Dev Sprint" = issue.customFields."Dev Sprint"


        but if the field in the sending side is called "Sprint", then the line should be:

        replica.customFields."Sprint" = issue.customFields."Sprint"

        and the same thing for the incoming sync, if the field in the incoming side is called "Dev Sprint", then the line should be:

        issue.customFields."Dev Sprint".value = ...


        etc.


        Thanks,


        André

      4. Madhu

        Hi Andre, 


        We have 2 custom fields with different Lov's and different field names, We want to map those fields. 

        Outgoing Sync will be same and I don't have any queries for that. 


        "Dev Sprint" with values 1 , 2 , 3 , 4 .

        "Test Sprint" with values Test1, Test2, Test3, Test4.

        Mapping comes as follows,

        1 - Test1

        2 - Test2

        3 - Test3

        4 - Test4


        Outgoing sync 

        replica.customFields."Dev Sprint" = issue.customFields."Dev Sprint"


        Please suggest the incoming sync for this as we have different field names and different Lov's. 


        We have to Ignore field values if there is no mapped value. 


        Thanks

        Madhu

      5. André Leroy-Beaulieu Castro

        Hey Madhu


        It would be:


        def sprintMap = ["1":"Test1","2":"Test2", "3":"Test3", "4":"Test4"]
        def remoteSprintValue = replica.customFields."Dev Sprint"?.value
        issue.customFields."Test Sprint"?.value = nodeHelper.getOption(issue, "Test Sprint", sprintMap[remoteSprintValue])


        Thanks,


        André

      6. André Leroy-Beaulieu Castro

        Hi Madhu,


        If you know the names of the fields then just send the corresponding one on the sending side and and receive the corresponding one on the receiving side. I'm not answering more to this request as it's clear enough with the answers above. 


        Thanks,


        André

      CommentAdd your comment...