Pick a new assignee each work week for a new ticket.
Asked by Harry Heathcote:

I have an automation run daily that act as a checklist for the team. With this currently it gets assigned to me and the others are added as participants to the ticket.

It has now been said that this ticket needs to be assigned to a different person from the team each week.

When testing I can have the ticket change assignee every time its created but that's daily not weekly so I need some automation to assign the ticket in a round-robin manner to someone from the team for the week then change the next week to a different team member.

Any ideas for this would be helpful.


Answers:
author: Darryl Lee
body: Hi [@Harry Heathcote](/t5/user/viewprofilepage/user-id/3851842) - so I think I came up with something that works, although it is a little... complicated. (And ha, reading [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)'s answer, using modulo of the week is the smart answer I was trying to come up with and failing. So I brute-forced it. But hey, everyone gets to learn about Project Entities and the new [Lookup Tables](https://community.atlassian.com/t5/Automation-articles/New-Automation-action-Create-lookup-table/ba-p/2311333#M754) feature! :-)

Rotation Rule {#toc-hId--470720334}
-----------------------------------

First off we have "Assignee Weekly Rotation". It takes advantage of [Project Entity Properties](https://developer.atlassian.com/cloud/jira/platform/jira-entity-properties/) to store a **weeklyCounter** (1 to X number of people on your team) and a **weeklyAssignee** (the accountId of whomever is the default assignee for the week).

#### Setup {#toc-hId--1577110219}

Because we're using a scheduled rule, we have to specify a JQL query so Automation knows which Project we are creating these properties in.

![Screen Shot 2023-03-25 at 12.49.23 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247702iD297A9FE8A3B0A93/image-dimensions/504x425?v=v2 "Screen Shot 2023-03-25 at 12.49.23 AM.png")

Ok, now that Automation knows what project we're working in, we can start editing entity properties for the project.

I check to see if the property has been created yet, and if so, I a little bit of maths to basically increment the "counter" every week until we hit the max number of team members (in my example 3), at which point we roll back to 1.

![Screen Shot 2023-03-25 at 12.47.13 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247703i2715C3C08F6D745A/image-size/large?v=v2&px=999 "Screen Shot 2023-03-25 at 12.47.13 AM.png")

The Else case covers initialization of the **weeklyCounter** property setting it to "1" if it was previously empty.

Ok now we're getting a little ahead of ourselves because I'm using a new feature that I don't think has been released yet - [Lookup Tables](https://community.atlassian.com/t5/Automation-questions/Create-Lookup-Table-action-mentioned-in-documentation-not/qaq-p/2274070)! (What's the status on that [@Simmo](/t5/user/viewprofilepage/user-id/3608665)?)

![Screen Shot 2023-03-25 at 1.06.23 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247713iB2300C417B884716/image-size/large?v=v2&px=999 "Screen Shot 2023-03-25 at 1.06.23 AM.png")

So what we have here is simply a mapping of your team members. Every week the counter rotates through the numbers, and in the next step, we will be using the lookup table toso a search for the week's default assignee's email to the the accountId (because that's what Automation needs to assign tickets).

Because of... latency, we do need to "Re-fetch issue data" before we go to the next step.

Unfortunately nothing is too easy with Automation, and there is not an internal action to lookup user accountIds by email. Luckily there **is** an API endpoint for that, and there's [a way to use the "Web request" action to hit that API](https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828) and get back the accountId:

![Screen Shot 2023-03-25 at 1.05.54 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247711iF245F930854A554C/image-size/large?v=v2&px=999 "Screen Shot 2023-03-25 at 1.05.54 AM.png")

Now we've got the accountId, and it's just a matter of grabbing the accountId from the Web Request response and putting it into another project entity property that we're calling **weeklyAssignee:**

![Screen Shot 2023-03-25 at 1.05.39 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247712i6A7057472695ABC1/image-size/large?v=v2&px=999 "Screen Shot 2023-03-25 at 1.05.39 AM.png")

Assignment Rule {#toc-hId-209338036}
------------------------------------

OK! So now we have our weeklyAssignee as a project property! Now you think it'd be easy to just adjust your existing rule that creates an issue on a daily schedule to just have it set the assignee to be the smart value **{{issue.project.properties.weeklyAssignee}}**.

ALAS, because you're using a Scheduled Task to create a new issue, Automation doesn't actually "know" what issue or project you are in, and so it can't get that property.

SO, I created a separate rule that triggers "When: Issue created". It's scoped to the same project where the entities are stored (and where you are creating the daily tickets). And it does a check based on Summary. You would want to add checks for any other parameters to ensure you are only assigning for the daily task.

![Screen Shot 2023-03-25 at 1.13.05 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247714i234672B4E03E7234/image-size/large?v=v2&px=999 "Screen Shot 2023-03-25 at 1.13.05 AM.png")

Final Notes {#toc-hId--1598116427}
----------------------------------

* So you'll want to remove any auto-assignment from your existing rule, so it doesn't get assigned and then reassigned right away.
* Also: while there might be a way to remove the assignee from the list of participants, I figure it's just ***one*** extra email the assignee will get, so maybe you just add everyone as participants to every task.

Let's see... oh yeah, I used the [Entity Property Tool for Jira](https://marketplace.atlassian.com/apps/1214509/entity-property-tool-for-jira?tab=overview&hosting=cloud&utm_term=&utm_campaign=%5BMax-Perfo-Cel%5D%20Extension%20for%20Jira%20-%2001.2023&utm_source=adwords&utm_medium=ppc&hsa_acc=2204732923&hsa_cam=19715514438&hsa_grp=&hsa_ad=&hsa_src=x&hsa_tgt=&hsa_kw=&hsa_mt=&hsa_net=adwords&hsa_ver=3&gclid=Cj0KCQjwt_qgBhDFARIsABcDjOeyS01zHfjbAsujoaSSVQyHUl5iA1wx2PLQK708rVnMlBkDSZZOzvwaAhpJEALw_wcB) to troubleshoot these rules, and it's really handy if something's not quite working and you want to take a peek a the values Automation has set without [going through the API](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-project-properties/#api-rest-api-3-project-projectidorkey-properties-propertykey-get) (although that works great for just viewing the properties: <https://YOURSITE.atlassian.net//rest/api/3/project/YOURPROJECT/properties>)

Unfortunately leaving it on for everyone to see entity properties for issues, users, etc may be confusing so if you do install it for testing, you might want to go into its configuration and later turn off "Globally enabled". Also, unfortunately the "Personally enabled" setting appears to be broken, which is a bummer, because this would be a useful admin tool.

comments: author: Simmo
body: Another option, If you're OpsGenie, is to setup a roster and make an API call to the who is on call endpoint to get their account ID. I'm doing that at the moment for one of my teams weekly rosters :)


author: Bill Sheboy
body: Hi [@Harry Heathcote](/t5/user/viewprofilepage/user-id/3851842)

The Assign Issue action has a round-robin option which appears to match what you ask: <https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Assign-issue> I have not used this one, and per the documentation the rule is somehow keeping tracking of assignments by this rule to a list of users (or a group, role, etc.). This seems an easy thing to try first.

If this does not work for you, a more complicated approach might be to calculate the week-of-the-year number from {{now}}, mod that value by the number of people, and use that to index into the list of users to select one for assignment.

Kind regards,  
Bill

comments: author: Darryl Lee
body: Hey [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) - yeah Round-Robin works great, but I think the issue [@Harry Heathcote](/t5/user/viewprofilepage/user-id/3851842) was indicating is that it will rotate to the "next person in line" for **every new issue**, and Harry wants that to be the same person throughout the week.

I did think about mod before I wrote my horribly complicated solution, but couldn't wrap my head around it. Of course now in the light of day, it seems simple:

Assuming there are 3 team members, you just have to do a check if:

```
{{#=}}{{now.format("w").asNumber}} % 3{{/}}
```

equals 0, 1, or 2, and assign tickets accordingly.

I tested, and this works just fine:

![Screen Shot 2023-03-27 at 10.55.30 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/247972iF0F5EA1632ED9C10/image-size/large?v=v2&px=999 "Screen Shot 2023-03-27 at 10.55.30 AM.png")

So then, [@Harry Heathcote](/t5/user/viewprofilepage/user-id/3851842) you would just need to remove the Auto-assignment from your current Daily rule that creates the checklist, and create a new rule like the one above.

It relies on the Daily checklist to have a consistent Issue Type and Summary so that it *only* does the automatic assignment for the daily checklist Task.

Anyways, yeah then we just do a little maths to get the week of the year and divide it by the number of team members, spitting out the remainder. [Modulo operator](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/#Mathematical-operators) - so powerful!


author: Harry Heathcote
body: Thank you both [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) and [@Darryl Lee](/t5/user/viewprofilepage/user-id/1365322) for your assistance.

This is exactly what I was looking for and has helped immensely.


Tags: cloud