Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to trickle down SPECIFIC components from an epic to children?

mattics phi January 22, 2024

Background: I have about new 25 components that I am trying to trickle down from epic to children.  Those epics have existing components on them and will have 1 of the 25 new components added onto them.  I am trying to trickle down ONLY the new components, not all the components.

 

There's only "Copy from Trigger Issue" which copies all the components.  Is there a way to do my ask all in one rule or would I need to create a separate rule for each component?

 

Thanks in advance!!

1 answer

1 accepted

0 votes
Answer accepted
Kalyan Sattaluri
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.
January 22, 2024

If you want the latest component added, use {{fieldChange.toString}}

If you want the list of latest components added, use {{changelog.component.toString}}

At a high level, create new variable (myVar), save added component or components using either of above smart values.

Branch on children and use your created variable to update component.

But you need to take into account components removed etc so may have to do if condition to check if changelog has any values and only then branch... so modify logic around based on your use case.

Also, if you need to "add" these new components to children, instead of replace, you have to do Advanced Edit to add.

To do this, create another variable  (mySecondVar) and set it to:

[ {{#myVar.split(", ")}}{ "add" : {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ]

Then in your branch -> Edit Issue and you can use below to only add components to your stories.

{
"update": {
"components": {{mySecondVar}}
}
}

Credit to @Bill Sheboy for showing me this method previously

mattics phi January 22, 2024

Thanks for the quick reply.  I think I can manage with the first one.  How I go about accessing the field though?  What is the syntax behind it?  Here is how I am accessing it, they are all producing NULL

 

{{component/s.fieldChange.toString}}

{{components.fieldChange.toString}}

{{component.fieldChange.toString}}

{{fieldChange.toString}}

 

and my node value is "components":

 

I can only use smart values in JIRA.  The json edited is locked by the admin

Kalyan Sattaluri
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.
January 22, 2024

Create new rule, set trigger to "field value changed" and choose component/s.

next, create action -> log action and put in {{fieldChange.toString}} to reference the changed value.

Then test it out, choose a test issue and add a component, iy will trigger your rule and log the value..

Kalyan Sattaluri
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.
January 22, 2024

@mattics phi Apologies, I should have been clearer in my posts.

You cannot get access to last updated value after the fact. Rule approach I posted initially is go forward.

That is, I am assuming epics havent been updated yet and you will set up a rule to listen to any changes to component field in any epic, and once its changed, {{fieldChange.toString}} or {{changelog.component.toString}} get you the changed values.

 

So in your example, if your epics have already been updated with these new components, this approach will not work.. Hope I havent confused you and if I misunderstood something, please let meknow.

mattics phi January 23, 2024

@Kalyan Sattaluri no need to be apologize!  It's all good :)

 

What I tried earlier was what you described.  I had a logger action that had this, below.

 

"inside linked issue ({{issue.key}}) "is megaepic for", editing component. field: {{component/s.fieldChange.toString}} {{components.fieldChange.toString}} {{component.fieldChange.toString}} {{fieldChange.toString}}"

 

I then changed the component in the epic and I manually triggered the automation.  This was the log output:

 

"inside linked issue (BIZ-56729) "is megaepic for", editing component. field:"

 

Screenshot 2024-01-23 at 9.02.37 AM.png

Kalyan Sattaluri
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.
January 23, 2024

@mattics phi Instead of scheduled trigger as your first step, you need to change it to use "Field Value Changed" trigger and choose component/s as a field to watch. Then in your first log action under if.. use {{fieldChange.toString}} to capture what was changed..

As mentioned, we can only do this for go forward changes, not to those where changed already applied.

mattics phi January 23, 2024

Awesome, thank you @Kalyan Sattaluri !  I got it working now :). What was missing was the trigger.  You were right, I needed to listen to when a component value was changed.  Only then did it work!  I'm going to see what I can do about the second part of your comment since I don't want it to overwrite all existing components!


Where would I added the second condition?  After the branch?  I got an empty output I had when I tried your code

 

Screenshot 2024-01-23 at 8.51.37 PM.pngScreenshot 2024-01-23 at 8.51.59 PM.png

Kalyan Sattaluri
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.
January 24, 2024

Your last variable, Childcomponent should be:

[ {{#componentName.split(", ")}}{ "add" : {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ]

 

Then you go to -> edit issue and go down to additional fields and put in below JSON to only add and not replace.

{
"update": {
"components": {{Childcomponent }}
}
}

 

image.png

mattics phi January 26, 2024

Sorry for my tardiness, I was only able to get to this now.  And of course, this is perfect, thank you @Kalyan Sattaluri !  Works flawlessly :)

Like Kalyan Sattaluri likes this
Kalyan Sattaluri
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.
January 26, 2024

Great to hear! Random thoughts:

Current rule set up only adds component when parent is edited, if you want to say remove a component from children if Parent was edited, you may have to further modify your rule and do another if/ else statement inside of your branch where you check if componentName exists, if so remove, else add... 

Also, Another FYI, You are using {{fieldChange.toString}} in your first variable which only captures the last  component updated.

But the reason we went about creating second variable and complicated syntax for it to update children was so that we could handle a list of (more than 1) components added.. If all we were handling were 1 component, we could have done it simpler.. of course current logic also works but this is more of an FYI...

If I may suggest, just as an exercise :

Copy/Duplicate this rule and try using {{changelog.component.toString}} instead of {{fieldChange.toString}} in your first componentName variable, and verify that when more than 1 component gets added to parent, children also gets updated with them..

Like mattics phi likes this
mattics phi January 29, 2024

I did that change when I read up on this page!  I just needed a little push in the right direction and modified it a little bit to suit my needs, thank you Kalyan!  I appreciate you coming back to let me know of your random thoughts :)

 

I do have to ask though, how does the update work?  We created the first variable "componentName" but we're not using it throughout the automation.  I looked here but couldn't find an answer

 

https://support.atlassian.com/cloud-automation/docs/advanced-field-editing-using-json/

Like Kalyan Sattaluri likes this
Kalyan Sattaluri
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.
January 29, 2024

Hi @mattics phi  - You are correct, we could have written our rule simply by completely avoiding the creation of the 2 variables and by directly referencing {{triggerissue.changelog.component.toString}} in your final statement..

 

Your final update JSON would have looked something like:

{
"update": {
"components": [ {{#triggerissue.changelog.component.toString.split(", ")}}{ "add" : {"name" : "{{.}}" }}{{^last}}, {{/}}{{/}} ]
}
}

 

But I have read somewhere here in forums that sometimes end expected JSON in your update statement is not formatted correctly and we get errors so its best to have it done in variables before hand and reference it in your update statement. I maybe making things up here but creating variables as we go along does help in logging and troubleshooting so I suggested that route.

Like mattics phi likes this
mattics phi January 29, 2024

Got it.  Thank you for explaining why we did what we did.  Thank you and I hope you have a lovely day!

Suggest an answer

Log in or Sign up to answer