For loop Automation to create issues with custom summary
Asked by perla.miranda:

Hi,

The following has been working for months and randomly stopped working. I'm out of ideas on what to do. No changes have been made with custom fields. This was working for various types of custom fields and stopped working for all of them.

Goal: Parent task has "Module Count" custom number field. When creating a parent task:

1. The automation rule reads the value and creates that many subtasks (e.g. if Module Count is 5, it creates 5 subtasks)
2. The summary for each subtask should be "Module 1", "Module 2", etc, up until the value of Module Count

Problem: This has been working fine and stopped. Now the module subtasks are created with the same name which is "Module" followed by "Module Count". (e.g. 5 subtasks are created and are all named "Module 5", instead of iterating through the numbers).

Here is a screenshot of the rule:

![for loop.png](https://community.atlassian.com/t5/image/serverpage/image-id/220229i5DF1053B3658F527/image-dimensions/306x664?v=v2 "for loop.png")

--------------------------------

Here is the code for each section:

#1![num_1.png](https://community.atlassian.com/t5/image/serverpage/image-id/220230i58FCF871E332F03D/image-size/large?v=v2&px=999 "num_1.png")

------------------------

#2![num_2.png](https://community.atlassian.com/t5/image/serverpage/image-id/220231i2B830757EBE85E47/image-size/large?v=v2&px=999 "num_2.png")

```
{{#varLoopValues.rightPad(varLoopValues.length.plus(issue."Module Count"), "X").remove("NULL").replaceAll("X","X,").substringBeforeLast(",").split(",")}}{{#=}}{{index}}+1{{/}}{{^last}},{{/}}{{/}}
```

-------------------

#3![num_3.png](https://community.atlassian.com/t5/image/serverpage/image-id/220234i13F756B128ABDFC2/image-size/large?v=v2&px=999 "num_3.png")

-------------------------

#4![num_4.png](https://community.atlassian.com/t5/image/serverpage/image-id/220233i56D250725F9D26B0/image-size/large?v=v2&px=999 "num_4.png")

```
?
```


Answers:
author: Bill Sheboy
body: Hi [@perla.miranda](/t5/user/viewprofilepage/user-id/4760887)

In your rule before the advanced branch, would you add a write to the audit log to show the value of {{varLoopValues}} then run your rule and post an image of the audit log details? That may help to isolate this symptom a bit. Thanks!

As a reference for other readers, this question is following up from a technique described in this article's thread: <https://community.atlassian.com/t5/Automation-articles/Branching-over-smart-values-in-Jira-Automation/ba-p/1741935>

Kind regards,  
Bill

comments: author: perla.miranda
body: For {{varLoopValues}}, I got the following which seems right when I placed it before the advanced branch.

![log1.png](https://community.atlassian.com/t5/image/serverpage/image-id/220252iD05C2E748F8482F1/image-dimensions/250x73?v=v2 "log1.png")

But then I tried another log under the advanced branch for {{varLoopVariable}} and I got just 3, when I set the custom field to 3

![log2.png](https://community.atlassian.com/t5/image/serverpage/image-id/220253i4CB634B903190441/image-dimensions/361x296?v=v2 "log2.png")


author: Bill Sheboy
body: That first log is correct and the second one is not.

I just retested this and advanced branch over a smart value list is also not working, per that defect noted by [@Manu Devos](/t5/user/viewprofilepage/user-id/5008973) so I will add a comment to the defect.


author: perla.miranda
body: Thank you! If you are aware of any workaround, please let us know. I appreciate you looking into this :)


author: Bill Sheboy
body: Until that defect/symptom is fixed I believe you are blocked for your use case. The only work-around would be to manually create, clone, or import issues...and perhaps disable that rule for a while.


author: Manu Devos
body: [@perla.miranda](/t5/user/viewprofilepage/user-id/4760887) We've been struggling all day with why this was not working for us and just noticed this bug was created:

<https://jira.atlassian.com/projects/AUTO/issues/AUTO-179>

comments: author: perla.miranda
body: Wow, this is really helpful. Thank you. Have you tried any workaround?


author: Manu Devos
body: Sadly in our cloud instance the provided workaround doesn't seem to be available.  
We've opened a support ticket as well


author: Manu Devos
body: [@perla.miranda](/t5/user/viewprofilepage/user-id/4760887) Just to inform you, we've retried running our rules this morning and they seem to be working as intended at this moment. Haven't had official feedback from Atlassian yet though


author: perla.miranda
body: I just checked and they are working now! Great! I was already going to take some time to Script them through script runner today and I was not looking forward to it haha! Looks like they added a comment that it is fixed now fixed: <https://jira.atlassian.com/browse/AUTO-179>

Thank you for taking your time to point me to bug logged, and it was helpful to know this was not occurring to our team only. Thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) as well for helping me confirm that it was an Atlassian bug.


author: perla.miranda
body: [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) you helped me with this last time so hoping we can figure out what happened here and if anything is no longer supported. Thank you