Questions for Confluence license has expired.

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

Unable to sync (via script connection) custom field in Jira to custom field in DevOps

 
2
1
0

I have a two-way sync enabled via the "Script" between Jira Server & Azure DevOps, and I am unable to sync a custom field from Jira to a custom field in DevOps.


On Jira side I have put in Outgoing Sync:


replica.customFields."Jira PBI Reference" = issue.customFields."MainPBINum"


On DevOps side I have put in Incoming Sync:


workItem.customFields."Jira PBI Reference" = replica.customFields."MainPBINum"


Also the Jira Assignee & Status Fields are not being passed to DevOps (using standard script with no modifications for these fields on both Incoming & Outgoing sides) all other fields are OK:


replica.assignee = workItem.assignee


replica.assignee = issue.assignee


It is probably something simple I am missing?


Thanks in advance for your help,

Rosie

    CommentAdd your comment...

    3 answers

    1.  
      2
      1
      0

      Hi Rosie,


      To sync the custom fields you can do: 

      Jira Outgoing Script:

      replica.customFields."Jira PBI Reference" = workItem.customKeys."MainPBINum"

      Azure Incoming:

      workItem.customKeys."MainPBINum"?.value = replica.customFields."Jira PBI Reference"?.value

      For assignee you can use the following method:

      issue.assignee = nodeHelper.getUser(replica.assignee.key)

      This helps to set the local issue assignee based on the remote issue assignee using the method. 

      For the method to work on Azure DevOps, make sure that the user is part of the team that has access to the Azure DevOps project.

      To sync statuses on Azure DevOps you can check this out:

      https://docs.idalko.com/exalate/x/kgF1Aw

      Let me know if this works for you,


      Kind regards,

      Ariel



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

        I believe this error will result when Assignee hasn't yet been picked. Is there a way around this? 


        1. Ariel Aguilar

          Hi Rosie,


          Could you please give it a try and change it to:

          issue.assignee = nodeHelper.getUserByEmail(replica.assignee?.email)

          Kind regards,

          Ariel

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

        Hi Ariel,

        I changed the above custom field in Jira Outgoing script to teh below and it seems to work (smile):

        Jira Outgoing Sync: replica.customFields."Jira PBI Reference" = issue.customKeys."MainPBINum"


        However the Assignee does not work (sad) as you wrote above, I get the following error message: 

        Assignee line: issue.assignee = nodeHelper.getUser(replica.assignee.key)

        Error message: Cannot get property 'key' on null object

        1. Daniel Carvajal

          Hi Rosie Dias 

          Can you change that line to:

          issue.assignee = nodeHelper.getUser(replica.assignee?.key)

          The ?. works to avoid throwing errors when receiving null values.

          Hope this is helpful.

        CommentAdd your comment...