Create a ticket each week via automation, and attach a different form
Asked by Jamien Price:

Hi all,

I have 40 different tasklists. Each list needs to be done once a year. I have 40 forms for each of these tasklists. I now want a ticket to be created with one of the lists per week. ie.:

- week 1 \> create a new ticket and attach task list 1  
- week 2 \> create a new ticket and attach task list 2  
- week 3 \> create a new ticket and attach task list 3, etc.  

I know how to make an automation with a "schedule" trigger and a CRON that says "if week 1, create a ticket with task list 1". What I would *LIKE* to avoid though is having FORTY different automations, one for each week.

Is it possible to do this with one automation that attaches a different form depending on what week of the year it is?

Thanks.


Answers:
author: Bill Sheboy
body: Hi [@Jamien Price](/t5/user/viewprofilepage/user-id/5099182)

*First thing, I am not currently using JSM and so I cannot test my suggestion. With that out of the way...*

I recommend checking if the Attach Forms action can take a smart value to select the form. If that does work, you could try:

* using the Create Lookup Table action, add rows for each form, where the key is the week number and the value is the form
* using the date / time format function, determine the week for the current date: <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/#Date-format--->
* use that value to get() the form needed for the Attach Forms action

That likely will produce a rule with just a few steps.

Kind regards,  
Bill

comments: author: Jamien Price
body: It's a good idea and I like the logic, though I don't see any smart values for forms, and the "attach form" option is just picking from a drop down so I don't know that I could inject a smart value even if they did have them unfortunately.

Thanks for the idea though.


author: Bill Sheboy
body: Although it is not obvious with the rule editor, many of the edit fields which have a dropdown values list have the ability to accept a smart value expression.

Please try this with the Attach Forms action and a test rule:

* in the edit field, type in a smart value representing the form
* when you do, it will appear below the field
* select it, and it will then be used
* test your rule


author: Jamien Price
body: I assume you mean this field - which when I type into it it appears to just filter the options in the dropdown.

![2024-08-01_08-35-34.png](https://community.atlassian.com/t5/image/serverpage/image-id/339283i604CEB7941EDF0CA/image-size/large?v=v2&px=999 "2024-08-01_08-35-34.png")

However, even if it does have the potential to accept smart values it doesn't appear you can reference forms in that way unfortunately:

![2024-08-01_08-34-14.png](https://community.atlassian.com/t5/image/serverpage/image-id/339285i264E55E18C7E56D3/image-size/large?v=v2&px=999 "2024-08-01_08-34-14.png")


author: Bill Sheboy
body: Thanks for testing that with the rule action. And, the bot answer seems to be referring to smart values for issues, not for rule actions.

A workaround you can use is calling the REST API endpoint to add the form to the issue using the Send Web Request action. You will need the list of the form id values for that (and storing them with a Lookup Table may help).

If you want to try this, here are the references you need:

* Details for adding a form with a rule this way
  * <https://community.atlassian.com/t5/Jira-articles/Add-a-Form-using-Automation-and-API/ba-p/2385407>
* How-to article for calling a REST API endpoint using Send Web Request
  * <https://community.atlassian.com/t5/Jira-articles/Automation-for-Jira-Send-web-request-using-Jira-REST-API/ba-p/1443828>
* The endpoint needed to add the form to the issue
  * <https://developer.atlassian.com/cloud/forms/rest/api-group-forms-on-issue/#api-issue-issueidorkey-form-post>


Tags: cloud

jira-service-management

jira-service-management-cloud