JIRA automation to create dynamic filters and to edit the filter permissions

Abhishek Kalamkar July 28, 2023

Hi All,

I want to create a dynamic filter as soon as Version is created. Based on the version values, like version name and version description, need to create a dynamic filter and save it as version description name. once done, need to edit the filter permissions. can you please help on this. here is the screenshot of what i am doing. image.png

4 answers

1 accepted

1 vote
Answer accepted
Jehan Bhathena
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 30, 2023

Hi @Abhishek Kalamkar

As @John Funk rightly mentioned this cannot be achieved out of the box, since the {{version}} is limited to provide only the version name and version ID.

In theory you can do this as a workaround :

  1. Use the Below webrequest to fetch the newly created versions
    image.png

    Note: the Delay further requests option is important for the next steps
  2. Use the details received from the above webrequest as input to another Webrequest, namely:
    {{webResponse.body.description}} and {{webResponse.body.name}}
    https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-post

You might need to do some trial and error with the create Filter API since the input may not be in the specified format needed.

Do let us know how it goes.

PS: would recommend Hidding the Auth token in your image

Jehan Bhathena
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 30, 2023

Hi @Abhishek Kalamkar ,

As shown in your image

image.png

This webrequest should work (in theory), do you get any error? What is not working in this use case now?

Also, as a request please use the individual thread for responding to each response, so that we have a more clear line of reasoning. :-)

Abhishek Kalamkar July 31, 2023

@Jehan Bhathena : please find the error. I have tried multiple ways, it will allow only text value but not {{version.name}} or {{webResponse.body.description}}

When I try for Get, custom data - that works fine for me as it retrieves all the filters data.

image.png

Jehan Bhathena
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 31, 2023

@Abhishek Kalamkar , you cannot validate a request that uses a smart value.

For {{webResponse.body.description}} to be resolved the first Webrequest needs to be fired, once done, the next request will use the output from the first request in the body.

As of now, you're trying to send a empty value in your request that is why you receive the error "name has to be provided".

Would recommend triggering the automation and let the whole automation run and see if it works.

Let us knw how it goes.

Abhishek Kalamkar July 31, 2023

@Jehan Bhathena : you wont believe, even the JQL is working fine. It is accepting below and able to create filters based on create version. Thank you Thank you Thank you.

Now only pending part is how to edit the filters permissions dynamically. 

image.png

Jehan Bhathena
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 31, 2023

To edit the filters owner and editor you need to add the "sharePermissions" In the body of the request.

You can find that in the documentation here : https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-post

Like Bill Sheboy likes this
Abhishek Kalamkar July 31, 2023

@Jehan Bhathena do I need to create another webhook request as the web request URL will be different and update the body to add the "sharePermissions" like below ? or can I add the "sharePermissions" in webhook request where I created the filters.

image.png

Jehan Bhathena
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 31, 2023

@Abhishek Kalamkarbelow is the Body you can use with this API https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-post, you dont need to create a new webRequest

 

{

    "jql""<JQL>",

    "name""<name>",

    "editPermissions": [

        {

            "type""user",

            "user":

            {

                "accountId""<<account ID>>"

            }            

        }

    ],

    "sharePermissions": [

        {

            "type""group",

            "group":

            {

                "groupId""<<groupID>>"

            }            

        }

    ]

}
Like Abhishek Kalamkar likes this
Abhishek Kalamkar August 1, 2023

Thank you so much  @Jehan Bhathena that works fine for group, project, users etc. if possible, can "My organization"be added. its not allowing me to add My organization in the viewers list

image.png

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 1, 2023

@Abhishek Kalamkar Glad to know it works.

For the "My Organization" part, I didn't find any direct setting for this but the below workaround should suffice:

  1. Create a filter manually with the required permission
  2. Using the API https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-filters/#api-rest-api-3-filter-id-get, fetch the details that filter has in the "sharePermissions"
  3. Use that in your API call

Hopefully this should work.

Please let us know how it goes, also, if this thread helped solve your original query would be great if you can mark this thread as the Accepted answer.

Abhishek Kalamkar August 1, 2023

Thank you for your help.

Abhishek Kalamkar August 2, 2023

@Jehan Bhathena sorry to bother you again. i have created a filter manually and fetch the details. please see below. 

image.pngSeems like the id referring is the filter ID not the filter permission "My Organization " id. so not updating the filter Viewers permission as not have much data for sharepermissions.

FYI - Edit permissions are working fine. 

"sharePermissions": [
{
"id": 40837140
"type": "loggedin"
}
]

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 2, 2023

Hi @Abhishek Kalamkar ,

for the "My Organization" Query would recommend creating a new question, since the main threadis already addressed in the current thread.

With a new question you're more likely to get more inputs. 🙂

Like Bill Sheboy likes this
Abhishek Kalamkar August 7, 2023

@Jehan Bhathena : one last question for this post - 

can I create two filter in one webhook request. somehow it is creating only first filter and not second one. some syntax error i guess.

{

"name": "{{webResponse.body.description}} Fix Version",
"description":"{{webResponse.body.name}}",
"jql":"fixversion = {{version.name}}"

},

{

"name": "{{webResponse.body.description}} Exception Version",
"description":"{{webResponse.body.name}}",
"jql":"fixversion = {{version.name}}"

}

Jehan Bhathena
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 8, 2023

Hi,

you will need to create a new webrequest for the second filter.

Like Abhishek Kalamkar likes this
0 votes
Abhishek Kalamkar July 30, 2023

@Jehan Bhathena Thank you for your answer. below is working for me as it is only the text value. As you mentioned, I only need the {{version.name}} value should be name field and JQL should use JQL: "to use smart value"

image.png

"name": "{{version.name}}" --> Filter name should save as value of {{version.name}}. filter name should save as CWC 9.5

image.png 

This is what I have tried but no luck. image.png

image.png

@Bill Sheboy : Thank you for your input. I don't really care about the description. If possible, I would like to have version description or version name same as above screenshot which is CWC 9.5

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, 2023

HI @Abhishek Kalamkar 

Adding onto the answers already provided...you note wanting to name your new, saved filter using the just-created version's description.

What information are you putting into the version description?

It is possible that your description contains text which cannot be saved as a filter name, so please keep that in mind when creating this rule.  Some work-arounds could be to remove/replace any characters in the description which are not permitted in saved, filter names, or to instead use the version name.

Kind regards,
Bill

0 votes
John Funk
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, 2023

Hi Abhishek - Sorry, but you will not be able to do any of those things with an Automation rule. 

Abhishek Kalamkar July 30, 2023

Thank you @John Funk 

Like John Funk likes this
John Funk
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 30, 2023

You are welcome.

Like Abhishek Kalamkar likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events