Automation: How to automatically create a Story every month with being linked to different Epic
Asked by Caleb Park:

Hi guys,

Is there a way to build an automation that automatically creates a Story that should be linked to a certain Epic every month?

For example, I already have monthly Epics with names like Jan 2023, Feb 2023, Mar 2023, Apr 2023, etc.

And I want to create a Story on every 25th of the month and it should be linked to applicable Epic.

On August 25th, a Story gets created under "Aug 2023" Epic.

On September 25th, a Story gets created under "Sep 2023" Epic.

On October 25th, a Story gets created under "Oct 2023" Epic.

I know how to do this by creating every different automation for every single Story, but I am wondering if there is any way to make it work in ONE automation.


Answers:
author: Trudy Claspill
body: Hello [@Caleb Park](/t5/user/viewprofilepage/user-id/5205736)

Yes, this is possible.

You can set up a rule that uses a Schedule trigger to run on the 25th of each month.

In that rule you can create the Story issue.

You can use this smart value to get the Month portion of the current date.

{{now.format("MMM")}}

With that you can execute a Lookup Issues action to find the Epic that has that month in its summary, using JQL:

summary \~ "\\"{{now.format("MMM")}} 2023 \\"" and issuetype=Epic

You can confirm that you got exactly one matching epic by using a Condition to check the size of the results set from the Lookup Issue action is 1.

{{lookupIssues.size}} equals 1

If that passes, you can get the key for the Epic in the results set using

{{lookupIssues.first.key}}

You can use that to set the "Epic Link" field for the new issue you create.

comments: author: Caleb Park
body: [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

Hi Trudy,

Where can I find "Lookup Issues action" from automation"?


author: Trudy Claspill
body: You can find that action described on the documentation page that describes all the available actions:

<https://support.atlassian.com/cloud-automation/docs/jira-automation-actions/#Lookup-issues>

From within the Automation Rule UI you can find it under the Add An Action option.

![Screen Shot 2023-08-22 at 11.53.26 AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/276507i619C84456C845756/image-size/large?v=v2&px=999 "Screen Shot 2023-08-22 at 11.53.26 AM.png")


author: Caleb Park
body: ![10.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/276508i70BE49EBBBBD9E80/image-size/large?v=v2&px=999 "10.PNG")

Our current JIRA system does not have it.

Also, one more question.

You've mentioned that i can use this one in JQL:

summary \~ "\\"{{now.format("MMM")}} 2023 \\"" and issuetype=Epic

But when I try to use this in JQL, it does not work. It gives this error.

![11.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/276509i28703C0CD3E9C298/image-size/large?v=v2&px=999 "11.PNG")


author: Trudy Claspill
body: Adding tags to your posts in the community to identify your hosting type is very helpful to us to ensure we provide responses relevant to your environment. It sounds like you are working with Jira Server or Jira Data Center. Is that correct? Automation for Jira for those hosting types does not include the Lookup Issues action.

> You've mentioned that i can use this one in JQL:
>
> summary \~ "\\"{{now.format("MMM")}} 2023 \\"" and issuetype=Epic

That only works in JQL statements within the Automation Rules. **{{now.format("MMM"}}** is a smart value. It can only be understood within Automation Rules, not within the normal Issue Search screens.

Since you don't have access to the Lookup Issues action an alternative would be to put the JQL into your Schedule trigger to first find the current month's Epic. Then you can add the steps to create the new Story and use {{issue.key}} to set the value of the "Epic Link" in the created issue.


author: Caleb Park
body: [@Trudy Claspill](/t5/user/viewprofilepage/user-id/3569011)

Yes, I am working with JIRA Server or JIRA Data Center.

So, using your alternative way, when I put the JQL into my Schedule trigger, "Validate Query" does not provide anything.

![15.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/276514iDAB945D73B5803E2/image-size/large?v=v2&px=999 "15.PNG")


author: Trudy Claspill
body: Within Automation Rules the JQL fields cannot run Validate query when the JQL includes smart values.

![Screen Shot 2023-08-22 at 1.32.29 PM.png](https://community.atlassian.com/t5/image/serverpage/image-id/276519i56B0E2D1EC9ED432/image-size/large?v=v2&px=999 "Screen Shot 2023-08-22 at 1.32.29 PM.png")