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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Published in Jira

Announcing the waitlist for Jira Work Management

Hey there Cloud Community members! We’re excited to give you the first glimpse of the new home for business teams on Jira — Jira Work Management. Jira Work Management is the next generation of J...

141 views 3 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you