Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
Level
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Copy two cascading field values from Parent to Sub-task

Hello I have two cascading fields, where I want to copy the value from parent to sub-task. I'm using advanced edit option to update using JSON function. I have used following lines, 

{
"update": {
"customfield_1234": [
{
"set": {
"value": "{{triggerIssue.fields.customfield_1234.value}}",
"child": {
"value": "{{triggerIssue.fields.customfield_1234.child.value}}"
}
}
}
]
"update": {
"customfield_5678": [
{
"set": {
"value": "{{triggerIssue.fields.customfield_5678.value}}",
"child": {
"value": "{{triggerIssue.fields.customfield_5678.child.value}}"
}
}
}
]
}  

but I was getting error, "json" cannot be parsed. 

Any appreciate will be helpful. Thanks.

2 answers

2 accepted

2 votes
Answer accepted

Hi @Sarath 

In your sample JSON, the curly brackets are not all matched:

  • there is a missing close } for the first update
  • there is a missing close } for the overall expression

Please add those and see what happens.  Thanks!

Best regards,

Bill

Thank you @Bill Sheboy, identified that "}" are not updated correctly and using only 1 update field worked as well. 

Darryl Lee Community Leader Mar 08, 2021

JSON validators like https://jsonlint.com/ or a JSON-aware text editor like Vim have proven invaluable to me for checking my JSON.

Like # people like this

Thanks for the recommendation @Darryl Lee I'll check them out.

1 vote
Answer accepted

Hi @Sarath , this is because you have duplicated the "update" field in the JSON. Each custom field should be a separate key inside the "update" field as in the below example:

{
"update": {
"customfield_1234": [ ... ],
"customfield_5678": [ ... ]
}
}

@Gareth Cantrell - thank you Gareth. Using only one update function worked along with correcting number of curly brackets.

Darryl Lee Community Leader Mar 09, 2021

I was curious what would happen if you do have two updates in the same JSON (properly formatted). Turns out that Automation Rules does complain that the JSON is invalid, but it only acts on the second one, presumably because it reads/loads the JSON in order and the first update gets overwritten before executing.

So with this block, only the Description got updated:

{
"update":{
"summary":[
{
"set":"This is a new Summary to replace."
}
]
},
"update":{
"description":[
{
"set":"This is a new Description to replace."
}
]
}
}

(I know my indenting is not-good. I blame the Community text editor stripping the spaces. :-/)

@Darryl Lee a JSON object is represented as a hash table internally, so while it is not an error to have the same key appear multiple times, the properties of a hash table mean that the value of the earlier key will be overwritten if the same key is encountered later during the parsing of the JSON. 

Like Darryl Lee likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Automation

Announcing the Jira automation template library!

Hi all,  After many months of work, I am delighted to announce the launch of the Jira Automation Template Library!  The Template Library is a new website dedicated to all things Jira au...

994 views 17 25
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you