Iterate over projects
Asked by Quentin:

Hi everyone,

My goal is to send a notification to a couple of Slack channels every day at 8h. The notification aims to remind the people about unfinished stories.

I've set up an automation, and given the right project ID and the right Slack channel it could send this message, great !

It just does a "Lookup Issues", then it creates a payload for the Webhook and iterate over the issues to print their values.

Now I want something that could be more abstracted. I would like to have a global automation rule that runs for multiple projects.

First problem is the Slack channel linked to the project. I can put the ID in the project.description and call it done, so no problem here.

My second problem is the "multiple project" thing. I can filter my stories based on a project right. But how can the same automation do the same thing for each projects ?  
How can I do a different lookup for each project ?

I think it would be a really efficient way to make this automation but I'm currently unable to achieve this. Please tell me if you have an idea. Thanks for your time.


Answers:
author: Callum Carlile _Automation Consultants_
body: [@Quentin](/t5/user/viewprofilepage/user-id/4090962) Instead of using the Project Automation for your project, go to System \> Automation Rules (you will need to be a Jira admin).

Here you can create global rules. In your rule you should create branches with filters for each branch, so you'd set your trigger (only 1 can be set per rule) then you can add a filter for each branch.

Branch 1 would be "if project = ABC then do this", branch 2 "if project = DEF then do this".

Note that if you're using Jira Service Desk Cloud you have a limited number of times a global rule can run based off your Jira subscription (100 executions per month if you use the free plan, 500 for standard plan and 1000 for premium plan)

comments: author: Quentin
body: Thank you very much for your answer !

<br />

It's not as neat and tidy as what I was picturing in my mind (Only one automation and a "loop" that manage each project) but it will do the trick and it's less tiresome than making an automation for each project.

<br />

Thank you again.


author: Callum Carlile _Automation Consultants_
body: [@Quentin](/t5/user/viewprofilepage/user-id/4090962) No worries!

You should still be able to achieve what you want with only a single automation rule (assuming there is only 1 trigger), as you can have multiple branches, e.g. you can add a whole load of if/else conditions with corresponding actions for each branch


author: Quentin
body: Yes but it's not "global" you see what I mean ? If I create another project I need to go back to this automation and add another condition.  
Plus, if I want to change the action taken, I need to go over each conditions too.

Having the action independent of the context of the project is a good way to ensure a long-lasting and auto-managed automations.  

That said, it's already a good answer, I'm still thankful for it ;)


author: Callum Carlile _Automation Consultants_
body: [@Quentin](/t5/user/viewprofilepage/user-id/4090962) Ahh I see what you mean now :) well if the same action is used for all projects, you won't need to add the separate clauses for each project, and all future projects created will have the same rule applied to it. You'd only need to create the separate branches if the actions/requirements were different for each project