Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Celebration

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,456,381
Community Members
 
Community Events
176
Community Groups

how to delete specific issue components using automation for Jira

Hi, 

I'm currently exploring the capabilities of automation for Jira to have a hierarchy alignemnt on Components fileds of a group Epic-Story-subtask.

I'm already able to copy components from a parent. Also to add new components when the parent changes (or to replace them).

 

My current problem is about how to delete a specific component value from the list of compontents of an issue.

 

The practical example is the following one. But, currently, I'm still not able to delete a specified component.

step1) sub-tasks and stories already inherited Epic components (maybe appending to any already existing)

step2) one component is deleted from a parent issue (let's say the epic)

step3) the same component SHOULD be deleted from the childrens (let's say at lest from the stories under that epic)

 

I was trying to use smart values/advanced rules/variables to solve step3) but nothing seems to fit my needs.

Could anyone help me?

 

thank you in advance for the help.

 

2 answers

1 accepted

1 vote
Answer accepted

Hi @Michele D'Adamo 

You can remove a component using automation with custom fields and the list, string, advanced JSON edit, and create variable functions.  It is a bit messy, so if you want the details of how to try this, please let me know.

Summary of how this works: concatenate the component values into Json, remove the target value, and use the remaining Json to update the component list.

Best regards,

Bill

Hi Bill,

 

yes it is exactly what i wanted to try, but something is not totally clear to me. 

 

I should to use "additional fields" box into a "edit issue fields". But I never worked with Jsons. I mean, never programming them.

 

It will be really helpfull to read how to proceed. Could you kindly try to explain me? actually I'm trying to understand recursive concatenation with smart values.

I'm already able to extract the list of the components, separated by comma, before change and after.

 

Thanks!

Hi @Michele D'Adamo 

Here is the information for how I removed a component.  Please consider adding logging to see what is happening during the processing.

  • Ask your site admin to create a custom text field for issues, such as WorkingComponent, to hold the item to be deleted.  (Side note: automation Create Variable values cannot be used as inputs to functions, which is why this custom field is needed.)
  • Create an automation rule with your desired trigger
  • Action: Edit Issue for your custom field, WorkingComponent, with the target value you want to remove from the component lists, wrapping it in single quotation marks.  You can get this target value from another field or hard-code it.  In my example, I am removing the third component value from the 0-based array
'{{issue.components.name.split(",").get(2)}}'
  • Action: Re-fetch so the issue and custom field are re-loaded
  • Action: Create Variable (for example, named initialJson) to represent the JSON used to update the component list, initially containing all values.  The syntax substitutes single quotes initially.
{{#issue.components}}{ 'name': '{{name}}'} , {{/}}
  • Action: Create Variable (for example, named finalJson) to represent the JSON used actually update the components.
    • Replace WorkingComponent with your custom field's name
    • The first remove() deletes the target value component
    • The second remove() deletes any leftover JSON text after the first remove
    • The substringBeforeLast() removes any trailing commas
    • And the final replace() substitutes double-quotation marks for the single ones
{{firstJson.remove(issue.WorkingComponent).remove("{ 'name': } , ").substringBeforeLast(",").replace("'","\"")}}
  • Action: Edit Issue fields, advanced using your JSON
    {

    "fields": { "components" : [ {{finalJson}} ] }

    }


Here is the documentation on advanced field editing with JSON, the string functions, and the list functions I used:

https://support.atlassian.com/jira-software-cloud/docs/advanced-field-editing-json/

https://support.atlassian.com/jira-software-cloud/docs/smart-values-text-fields/

https://support.atlassian.com/jira-software-cloud/docs/smart-values-lists/

 

Best regards,

Bill

Like # people like this

Ciao Bill, 

 

Many thanks for your help. I have to say that it is working!

I'm able to move modified epic components to the children now.

 

The next step will be to manage any additional component at children level (not present into fathers) But i should have enough info to update also in this direction. Just need the time to think about :)

 

Best Regards,

Michele

Like Bill Sheboy likes this

Hello @Michele D'Adamo

Thank you for reaching out.

Indeed, Jira automation does not have a function to remove a component of a child issue (Stories, Sub-task, etc) when it gets removed in the parent issue (Epic or Parent task). We have the following feature request to get this function implemented on the rule triggers, so you would be able to use the Smart values to properly reference it in the rule actions:

Trigger rule when value is added/removed from multi-select type field 

You can keep an eye on that feature request to check any updates.

If the child issues should have the exact same components as the parent issues, a possible solution would be to completely override the components of the child issues with the ones selected/removed in the Parent issue:

Screen Shot 2020-11-17 at 16.24.32.png

For more details, you can check the section "Add values to multi-select fields" of the documentation below:

Edit issue Fields 

Let us know if you have any questions.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS

Atlassian Community Events