Copy value from Custom field 1 to Custom Field 2 with Automation

Anuj B April 10, 2019

Hi - 

Could someone give me the json format to to copy value from customFieldId=10060 & set it to customFieldId=10014 inside the same issue that I could use in Automation for JIRA for JIRA cloud.

Unfortunately, it does not populate the source custom field in the [Copy From] dropdown to copy to customFieldId=10014 in the UI, so I think I'll need the json to set that, attachment added for reference.

Thanks in advance!

Screen Shot 2019-04-10 at 12.52.46 PM.png

8 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
Internal Systems May 11, 2021

I used the above code and it did not work, I did have to modify it a bit

 

{
"fields": {
"customfield_10014": "{{issue.customfield_10060}}"
}
}

Adding quotes around the copy from custom field if anyone else runs into the issue. 

Deleted user August 20, 2021

It works for me!
Thanks! 

Pratik Gaad December 21, 2021

What is the logic for adding the quotes ?

Rob Peterson December 22, 2021

just the formatting for JSON

"objectname" : "objectvalue"

Like Pratik Gaad likes this
3 votes
Rob Peterson October 19, 2021

If anyone comes across this, I wasn't having trouble with a straight text field or numeric field to text field or numeric field.  I was having trouble when the copy value was to be populating a dropdown.  

As such, I had to use the JSON format to post the field by name and then the value I was trying to pass.  

Example:

{
  "fields": {
        "Billing Type": {
            "value": "{{issue.parent.fields.customfield_12127.value}}"
         }
    }
}

The "Billing Type" name was sourced by viewing the REST-API version of an issue (although, it's most likely the same as what you see in the UI).  You can view the REST-API version to also assist on finding the path for what you are looking for as the value and/or enumerations.  You can use this link:
https://<your_instance>.atlassian.net/rest/api/2/issue/<your_issue_id>?expand=names

1 vote
Sara Watson October 29, 2020

@Nick Menere how should I update the above code so that the custom field from the epic is copied to the user story? The custom field is "customfield_10001" so I tried the following and it is not working: 

{
"fields": {
"customfield_10001": {{issue.parent.epic.customfield_10001}}
}
}

Shaun Newman May 26, 2021

I am struggling with this exact same issue. I keep getting 'Invalid JSON Errors' but as far as I can tell I've formatted exactly as others suggested but completely unable to find a way to copy the field from the parent. 

Shaun Newman May 27, 2021

Looks like I had a rogue space in my json so I fixed the invalid json error. I also found out that the correct way to get the parent if you are working with a child of an Epic is {{issue.epic.customfield_10001.id}} apparently parent is for sub-tasks ¯\_(ツ)_/¯

 

I was able to get this to work a few of times but it suddenly just stopped updating the field no errors, all my log outputs show all the same good values from when it worked but I'm back to the automation telling me it succeeded and nothing actually changing.

 

I have an instance from my successful runs in my log where the automation tells me it succeeded, the log output says it set my custom field to null but it had actually updated correctly in the UI. :/

1 vote
Nick Menere
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 15, 2019

Hi Anuj,

 

This will come down to what kind of field the 2 fields are. You should be able to copy between number and test fields.

Basically it should be something like:

{
"fields": {
"customfield_10014": {{issue.customfield_10060}}
}
}

But as I said, depends on the type of fields.

Cheers,

Nick

Anuj B April 16, 2019

@Nick Menere - thanks, I'm going to try that & let you know.

Anuj B April 16, 2019

@Nick Menere - it worked like mint, thanks a lot!

Abdelwahed SAMRI June 20, 2020

Hello @Anuj B @Nick Menere 

I'm running into the same problem ! 

I'm trying to copy one value from a custom field to another one on the same issue.

It doesn't work for issue created trigger rule, but it works perfectly for field value changed trigger rule !

I tried Json format as suggested above, it doesn't work. I also tried using the UI automation wizard (when, if, then) but no use !

Both custom fields are of type Select List (single choice) with the same values and None as a default value

Rob Peterson October 19, 2021

@Abdelwahed SAMRI see my post below; you may be running into the same issue I was in relation to the dropdown (i.e. list).

0 votes
krzysztofzarebski July 9, 2021

Does anyone know some alternative for copy any fields with automation option?

0 votes
Shaun Newman June 2, 2021

I have been able to get this working but only as a manual trigger on an issue after it's been created and saved. Is there some delay in the custom fields being available during the issue creation?

 

Edit: after playing around a little more I think I have this working, kinda.

I use this in the additional fields edit box:

{
"fields": {
"customfield_10001" : "{{issue.epic.customfield_10001.id}}"
}
}

 

I run the automation on a trigger when the issue is created and have logging to check the {{issue.epic.customfield_10001.id}} has a value during the run. This is always coming back with a value.

I also log the new issues value for customfield_10001 this is always coming back as null despite the log telling me the field was successfully updated right before this entry.

When I create my child item in JIRA it is saved with a blank in the custom field but when I refresh the browser the field value I expected is then populated.

I've added a retrieve issue step in my automation routine, which seems to do nothing at all and I can't trigger a refresh browser so may have to live with this glitch.

0 votes
Sam Neilson October 8, 2020

@Nick MenereIs it possible to copy Date field? I am trying to copy Due Date(Standard field) to a custom field.

Please help!

Dayong Wang June 1, 2021

Not sure whether it may follow the REST API format? https://community.atlassian.com/t5/Jira-questions/Error-creating-issue-via-REST-API-could-not-find-valid-id/qaq-p/370628

I encountered a similar issue. 

0 votes
Mamta Kalwani September 8, 2020

Hi, 
I tried using the above query for copying components into a project picker field:

{
"fields": {
"{{issue.components.name}}":  {{issue.customfield_12700}}
}
}

I want to copy the component into the Project picker field (field number used here) but it doesn't work?


Could you please help?

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events