Custom Fields not being populated on DevOps Side

Hello, Im running my Jira to DevOps automation through a trigger in Jira. This created a DevOps ticket and populates different things to it.

I have a custom field called Jira (which is referece as Custom.JIRA ) which i try to populate and it does not work.

DevOps Incoming never find that field. I tried through FirstSync and outside first sync and the result is the same, it cant find the field.

this is my script

if (workItem.customFields[“Custom.JIRA”] != null) {
workItem.customFields[“Custom.JIRA”].value = jiraInfo
store(workItem)
}

any ideas why the custom field is not showing up, even if it leave it outside of first sync and then do an update on the jira ticket, it doesnt update that, it updates the description so i know the connection is working.

Hi @Lautaro

Can you please try to add this script at the end of the incoming sync script:

//for first sync
if(firstSync){
store()
workItem.customFields.“Remote ID”.value=issueUrl
}
workItem.customFields.“Remote ID”.value=issueUrl

Thanks,
Sonal

When i try to use that, it errors out saying

Cannot set property ‘value’ on null object

Im guessing this is due to issueUrl being empty, since its not picking it up in either side.

Hi @Lautaro

Can you please share your incoming sync script of ADO?

Thanks,
Sonal

// CODE
if (firstSync) {
workItem.projectKey = replica.customFields.“DevOpsProject”?.value?.value ?: “DEFAULT_PROJECT”
workItem.typeName = “User Story”
workItem.summary = replica.summary
syncHelper.syncBackAfterProcessing()
}

workItem.attachments  = replica.attachments

//workItem.description = replica.description
// Prepend JIRA info to description
def jiraUrl = “https://xxxxxx.atlassian.net/browse/${replica.key}
def jiraInfo = “JIRA TICKET → ${jiraUrl}” // 4 newlines after the link
//def plainDescription = nodeHelper.stripHtml(replica.description ?: “”)
workItem.description = jiraInfo + “\n\n\n” + replica.description

//replicate the link after the first sync
if (workItem.customFields[“Custom.JIRA”] != null) {
workItem.customFields[“Custom.JIRA”].value = jiraInfo
store(workItem)
}

Can you try this script?

   if (firstSync) {
        workItem.projectKey = replica.customFields.“DevOpsProject”?.value?.value ?: “DEFAULT_PROJECT”
        workItem.typeName = “User Story”
        workItem.summary = replica.summary
        syncHelper.syncBackAfterProcessing()
    }


    workItem.attachments  = replica.attachments


    def jiraUrl = “[https://xxxxxx.atlassian.net/browse/${replica.key}](https://xxxxxx.atlassian.net/browse/$%7Breplica.key%7D)”
    def jiraInfo = “JIRA TICKET → ${jiraUrl}” // 4 newlines after the link
    //def plainDescription = nodeHelper.stripHtml(replica.description ?: “”)
    workItem.description = jiraInfo + “\n\n\n” + replica.description

    if (firstSync) {
        store()
        workItem.customFields.“ Custom.JIRA”.value = issueUrl
    }
    else  {
        workItem.customFields.“Custom.JIRA”.value = issueUrl
    }

Hello Sonal!
Thanks for your reply.

Unfortunately your code is not working on my case.

The first issue comes from the

 def jiraUrl = "[https://lawsociety.atlassian.net/browse/${replica.key}](https://lawsociety.atlassian.net/browse/$%7Breplica.key%7D)"

it just errors out, doesnt like it at all.

If i swap that line with

   def jiraUrl = "https://lawsociety.atlassian.net/browse/${replica.key}"

Then it lets me proceed, however it fails later with this error :

Cannot set property ‘value’ on null object and its refering to this line

workItem.customFields.“Custom.JIRA”.value = issueUrl

So thats the issue im encountering where exalate is unable to even see the custom fields on the DevOps side (or even any devops fields that are not custom but are outside summary and description)
Thanks!

I think we fixed this issue while resolving another similar community question:

Hello!

The code that is currently working is:

Outgoing Jira
// let DevOps know which JIRA key this came from
replica.key = issue.key

// basic fields
replica.summary = issue.summary
replica.priority = issue.priority
//This line below, transforms description from Markdown to HTML to transfer over
replica.description = nodeHelper.getHtmlField(issue, “description”)

replica.attachments = issue.attachments

// custom-field mappings (make sure the names match exactly what you use in Azure incoming)
replica.customFields.“DevOpsProject” = issue.customFields.“DevOps Project”
replica.customFields.“CustomerRequestType” = issue.customFields.“Customer Request Type”

Incoming Jira

if (firstSync) {
issue.projectKey = “ITS”
issue.typeName = “CI”
}

if(!firstSync && syncRequest.remoteSyncEventNumber==1){
issue.customFields.“Remote URL”.value = issueUrl
}

Outgoing Devops

replica.key = workItem.key
replica.summary = workItem.summary

Incoming DevOps

if (firstSync) {
workItem.projectKey = replica.customFields.“DevOpsProject”?.value?.value ?: “DEFAULT_PROJECT”
workItem.typeName = “User Story”
workItem.summary = replica.summary

syncHelper.syncBackAfterProcessing()

}

workItem.description = replica.description
workItem.attachments = replica.attachments
workItem.priority = replica.priority

if (firstSync) {
store()
workItem.customFields.“JIRA”.value = issueUrl
} else {
workItem.customFields.“JIRA”.value = issueUrl
}

Thanks for the help!