Copy custom field from subtast to parent

How can I copy a custom field value from subtask to parent? The field name is "Test Links". Our use case is developers are working in subtasks more than the parent issue, but all QA and stakeholders do their testing in the parent issue — so we want to copy that custom field from subtasks to parents.

Here's what I have now.

Screen Shot 2017-03-07 at 2.18.39 PM.png

1 answer

1 accepted

1 vote
Andreas Knecht Community Champion Mar 07, 2017

Hi Michael,

So you need to use a smart-value for  now with the sub-task's value.  So in your example above, simply fill the 'Test Links' field with:

{{triggerIssue.fields.Test Links}}

This will put the value of the field on the current issue (the sub-task) and update the parent with this value.

Cheers,

  Andreas

EDIT: Fixed this to 'triggerIssue'. I previously had this wrong as 'issue'.

For some reason this isn't working. I did exactly the example above and nothing came through, so I put in some characters after it to test if I had the smart-value correct and only the following characters are appearing. Screenshots showing examples are attached. The first screenshot shows what was put on the subtask, the second shows what the rule put on the parent and the third is the rule.

 

 

Screen Shot 2017-03-08 at 11.59.32 AM.pngScreen Shot 2017-03-08 at 11.59.38 AM.pngScreen Shot 2017-03-08 at 11.59.21 AM.png

Andreas Knecht Community Champion Mar 08, 2017

Hi Michael,

What type of field is this?  Is it just a text field, or is it a custom field type provided by another add-on ?

Can you provide me with outputs of:

  • https://<yourinstance>/rest/api/2/field
  • https://<yourinstance>/rest/api/2/issue/<issuekey>

The first will let me see the field ID and type of the 'Test Links' field and the second will let me check how that field is represented using the field ID.  If it's an object of some sort then you may need {{issue.fields.Test Links.value}} but I can only tell for sure if you can provide me with the output of the above.

Feel free to send those through to https://codebarrel.io/support if you're not comfortable posting this information publicly here.

Cheers,

  Andreas

It's just a text area that I made myself. Just sent everything through to your service desk. Issue id is CBS-770. Thanks for your help!

Andreas Knecht Community Champion Mar 08, 2017

Thanks!  And sorry I made a mistake in my previous reply sad.

What you need is:

{{triggerIssue.fields.Test Links}}

'issue' in the example above already refers to the parent issue since we're on the parent issue branch.  'triggerIssue' refers to the original sub-task that triggered the rule that we want to copy from.  Sorry - silly mistake on my part.

Cheers,

  Andreas

Worked perfectly. Now, in testing it I see that updates to multiple subtasks will overwrite each other.

Is there a way to retain the existing field? I'm thinking something like this on the Edit Issue component:

{{PARENTISSUE?.fields.Test Links}}
{{triggerIssue.fields.Test Links}}

That way it just takes the field that's there and adds the trigger issue values to it? Make sense? Is that possible?

Andreas Knecht Community Champion Mar 08, 2017

Hey Michael,

So what you'd have to do is introduce a 'Compare condition' in the 'Parent issue' branch just before the edit issue action to check if the field is currently empty.

So just before 'Edit issue', insert a 'Compare condition' and use 

{{issue.fields.Test Links}}

as the first value (this will be the parent's value for that field).  Then leave the second value blank, which means the compare condition will check that the value is currently 'empty'.

That means edit will only happen if it's currently empty.  If it has a value, no edit will happen.

Cheers,

  Andreas

I wound up doing this for the edit issue:

{{issue.fields.Test Links}}
{{triggerIssue.fields.Test Links}}

 

This way I can maintain what's on the parent and then add what's being put on the trigger issue.

 

Thanks for all the help!

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

356 views 0 6
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you