I'm trying to create a system to automatically assign items to a user based on who has the least amount of assigned items. Below I have the post function and the result of the dumps. It seems like the nested for loop is being executed async, because it dumps the result of the nested loop before any of the dumps that should be executed before it.
One thing I'm absolutely sure of is that the user ID being returned to assign does not have 0 items assigned to them.
Am I doing something incorrectly, or are there just limitations I would have to try and work around to get this to function the way I'd like it to?
Hi Drew,
There are no issues with using nested for loops in Nunjucks scripts executed by JMWE.
I would suggest troubleshooting these:
1) Print the output of {{allIcsOpenTasks | length}} and verify the output is greater than 0
2) Check the output of t["fields"]["assignee"]["accountId"] and see if it actually matches the current role member in the first for loop.
Regards
Yi Ming
Printing out the length of allIcsOpenTasks lead me right to the answer...
Apparently searchIssues(1000, 0, fields="assignee") doesn't work. It was only returning 10 results.
What I had to do was: searchIssues(maxResults=1000, startAt=0, fields="assignee")
when I added maxResults= I noticed it changed the 1000 to green. It seems like it was seeing 1000 as a string until I added the parameter name.
Thank you!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Drew
are you sure this is the exact code you're testing? On the script screenshot I don't see the words "Current user being checked".
Also, don't use the "===" operator but "==". And you don't need "| dump(2)" to print a string. Finally, the whole point of templating is to avoid having to build strings, so you can do something like:
Current task assigned to user: {{t.fields.assignee.accountId}} Current task assigned user: {{currentAccountIdTaskCount}}
Can you share the full script as text (inside a "code block" format) instead of a screenshot?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.