Jira automation rule to create multiple sub-tasks based on the file-name
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
This article will list out the steps in the automation rule to count the number of commas in the the FileName custom field and then create that many number of sub-tasks.
Environment
Jira Cloud.
Solution
Creating Sub-tasks Based on Commas in a Text Custom Field Using Jira Automation
To achieve the creation of a specific number of sub-tasks based on the number of commas in a text custom field value using Jira Automation, follow these steps:
Trigger Setup:
- Choose the trigger that suits your use case. For instance, "Issue Created" or "Issue Updated" if you want the automation to run when an issue is created or updated.
Condition to Check Custom Field:
- Add a "Condition" to check if the custom field contains commas. You can use the "Advanced compare condition" to evaluate if the field contains a comma.
Extract Commas Count:
- Use a Condition to check and compare the result of the below smart value to count the number of commas. The smart value might look something like
{{issue.customfield_XXXXX.split(',').length.minus(1)}}
. Replacecustomfield_XXXXX
with your field's ID. This will give you the number of sub-tasks to create.
- Use a Condition to check and compare the result of the below smart value to count the number of commas. The smart value might look something like
Loop Through Commas:
- As of the last point, Jira Automation does not directly support looping based on a count. A workaround involves using a webhook to call a script hosted externally to loop through the count and call Jira's API to create sub-tasks, or creatively using the "Create issue" action multiple times based on the number compared to the above step.
Create Sub-tasks:
- Use the "Create issue" action to create a sub-task. You will need to set this up according to the number of commas or use the external script as mentioned above.
Finalize and Publish:
- Review your rule to ensure it meets your requirements, then save and enable it.
Note: Due to the limitations within Jira Automation regarding dynamic looping based on a variable count (like the number of commas), achieving this functionality might require external scripting or a more complex setup than typical automations allow. Always test your automation rules in a safe environment before applying them to your production system.