Forums

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

Automation - Remove a component

Gabriel Chaves September 28, 2023

Hello guys, I would like to know how to remove a component from the Jira automation, I tried the documentation, but it was not clear for me. I know that would be from a JSON, but didnt work for me.

The code would be, every time a trigger happens, remove the component 'abc'.

 

 

3 answers

1 accepted

3 votes
Answer accepted
Gabriel Chaves September 28, 2023

Thank you @Kian Stack Mumo Systems , I looked through 18 pages, and didn't see this one.

The second solution was missing some information (The variable {{compsCsv}} converts {{comps}} variable with CSV delimited by string quotation (")), but I got the necessary knowledge to do the automation.

I thought there was something simpler, similar to what is presented in the documentation:

"components": { "required": false, "schema": { "type": "array", "items": "component", "system": "components" }, "name": "Component/s", "hasDefaultValue": false, "operations": [ "add", "set", "remove" ]

Anyway, it works. Thank you very much!!

My solution:

Strutucture:

img03.png

Solution:

  1. Create a variable (issueComponents) to receive all the components

    {{#issue.components}}{ 'name': '{{name}}'} , {{/}}

    output:

    { 'name': 'Component 1'} , { 'name': 'Component to be removed'} , { 'name': 'Component N'} ,

  2. Create a variable (updatedIssueComponents) to remove a specific component and format the string (remove the last comma, and replace the quotes) to be used in a advanced JSON editing

    {{issueComponents.remove("{ 'name': 'Component to be removed'} ,").substringBeforeLast(",").replace("'","\"")}}

    output:

    { "name": "Component 1"} , { "name": "Component N"}
  3. Edit the issue with a JSON input

    {

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

    }

Kian Stack Mumo Systems
Community Champion
September 29, 2023

I'm glad you got it working!

Like Gabriel Chaves likes this
3 votes
Kian Stack Mumo Systems
Community Champion
September 28, 2023

@Gabriel Chaves

 

You should check out this page - it looks like @Bill Sheboy answered a very similar question in some great level of detail, so full credit to him for that!

If you do run into trouble with the implementation, I'd be happy to help troubleshoot your issues.

 

Thanks,

Kian

1 vote
Benoit
Contributor
November 14, 2023

here is the most easy way to do it:

In JSON format in a modify issue use this syntax:
{
"update": {
"components": [{
"remove": {"name": "Component_Name_To_Remove"}
}]
}
}

Irina Lemus
Contributor
July 18, 2024

.

Slava Gefen December 13, 2024

💯 agree with this solution!

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events