Copy field from Initiative to Epic using smart values

Daniel Oriold July 29, 2021

I would like to copy the Labels from an Initiative to its child Epics.

I get the key of the parent Initiative through {{issue.Parent Link.data.key}}, which gives e.g. ABC-123. But how do I access the Initiative's labels?

Neither {{issue.Parent Link.data.key.labels }} nor {{ABC-123.labels}} is working

3 answers

1 accepted

1 vote
Answer accepted
Daniel Oriold July 29, 2021

{{triggerIssue.Labels}} gives the labels of the Epic, but not from the Initiative, and I would like the rule to run when the Epic is assigned to a new Parent Link (Initiative)

Capture.PNG

Bill Sheboy
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.
July 30, 2021

Thanks for the rule image and explanation, Daniel.

To do what you ask, you need to copy the parent's labels to the child epic, as @Melo noted.  Here is the step-by-step:

  • Select the edit issue action
  • Select the labels field
  • Select the ... at the right of the field
  • Select Copy From >>> this will default to copy from Current Issue
  • Select the value Copy Labels from Current Issue
  • Change the Issue to Copy Value From to Parent
  • Select Close
  • Select Save

Then please try your rule again.  You should not need the Additional Fields, JSON edit for this one.

Like Melo likes this
Daniel Oriold July 30, 2021

Yeah, I had tried this, but this rule only works for Sub-Tasks, with their parent being a Task or Story (it even says it in the screenshot), but not for Epics and Initiatives:

SnipImage.JPG

When I run the rule the audit log says "Can't find issue to copy from labels" 

Bill Sheboy
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.
July 30, 2021

In that case, one work-around is to use a created variable and a branch to save the Initiative's labels and then make the edit.

  • trigger: issue updated, parent link changes
  • condition: parent link is not empty
  • condition: issue type equals epic
  • action: create variable, such as named varParentLabels, initialized to null
  • branch: on JQL where key = {{triggerIssue.parent}}
    • action: create the same variable again, such as named varParentLabels, setting it to {{issue.labels}}
  • condition: {{varParentLabels}} does not equal null  (see note below)
  • action: edit issue to set the labels to the created variable, {{varParentLabels}}  To do this, you will need to type in the value, and then select it.

Please note: if you want empty Initiative Labels to replace the value for the Epic, you'll need to update this rule to handle it, using an if/else condition.

Like Daniel Oriold likes this
Daniel Oriold July 30, 2021

Awesome, thank you, this works when the Initiative has only a single label. When it has multiple it says that the label cant contain spaces, but that is a separate issue.

Capture.PNG

1 vote
Melo
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 29, 2021

Hi Daniel,

I'm not sure how the rest of your rule is configured, but can't you use the UI for this one? or maybe {{triggerIssue.label}}Screen Shot 2021-07-29 at 5.23.42 PM.png

Cheers,

Melo

Bill Sheboy
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.
July 29, 2021

Hi @Daniel Oriold 

Yes, and...to what @Melo describes...

Please consider posting an image of your entire rule, including the trigger you are using and describe the issue you expect to trigger it, the initiative or one of the child epics.  That will provide the community context to offer suggestions.  Thanks!

Best regards,
Bill

Like Melo likes this
0 votes
Bill Sheboy
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.
July 30, 2021

Hi @Daniel Oriold 

Regarding multiple labels in the parent Initiative, that is a bit more complicated, and requires pre-building the labels and using the advanced field edit.  For example:

  • ... your trigger and conditions up to the point of the parent branch
  • branch on the parent
    • action: create a variable to capture the parent labels, perhaps named varParentLabels, using a list iterator to pre-build the comma-separated values string, with quotation marks around each label entry
{{#issue.labels}}"{{.}}"{{^last}},{{/}}{{/}}
  • action to edit the trigger issue with advanced edit.  Remember to not select labels in the drop-down list; only use Additional Fields.
{
"fields": {
"labels": [{{varParentLabels}}]
}
}

 

Best regards,
Bill

Sudipto_Roy August 5, 2021

Hi @Bill Sheboy ,

 

Many thanks for your suggestion, I was able to follow the suggested changes but the only final piece of the puzzle is that existing labels of the EPIC are lost in this aspect and all labels of the Initiative do get copied.

Any suggestion to prevent that?

Thanks,

Sudipto Roy

Bill Sheboy
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.
August 5, 2021

Hi @Sudipto_Roy 

You will need to prefix (or concatenate) the existing labels from the epic onto that created variable, and then you can save them all.

Best regards,
Bill

Sudipto_Roy August 6, 2021

Yes, followed almost the same approach and got it to work.

Thanks for your suggestion and time.

Regards,

Sudipto Roy

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer