Copy custom field from subtast to parent

Michael Clinton March 7, 2017

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
Answer accepted
andreas
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.
March 7, 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'.

Michael Clinton March 8, 2017

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
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.
March 8, 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

Michael Clinton March 8, 2017

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
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.
March 8, 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

Michael Clinton March 8, 2017

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
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.
March 8, 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

Michael Clinton March 9, 2017

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
TAGS
AUG Leaders

Atlassian Community Events