Is there a way to iterate through list which I get from a Webrequest?
Use Case:
I get a list from a webrequest which I make via Automation. And I want to save every single value in different Customdields, Is there a way to do it?
Would something like this help? https://community.atlassian.com/t5/Jira-Software-questions/Using-variables-in-functions-in-smart-values-in-JIRA-for/qaq-p/1630769 they mention adding separator characters to display the list items nicely.
No; I do not believe there is a generic iterator/looping structure in automation rules yet. Here is one suggestion to add that feature: https://jira.atlassian.com/browse/JRACLOUD-76906
If you know the list of custom fields, you could include each one as an edit in the rule, and then repeatedly parse the response message with text functions and regular expressions.
A more risky alternative would be to create a "queue" field, and use a second rule which repeatedly triggers itself to consume the values, and halts when the field becomes empty. Given automation rules already have observable race-track timing issues (sometimes) I would strongly advise against that...and, there is no guarantee that the built-in runaway prevention wouldn't halt the rule defensively.
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Bill Sheboy
I have just saw this old post about iteration over list via automation rule.
Not only list but any delimited multiples values, the automation rule still doesn't support such iteration/branching out; so thinking out of the box I saw your answer about "risky alternative" and actually I did something similar and it works like a charm.
We have a rule that calls a web request (REST API) that gets the list of issue links from some remote issue, so the problem to go over the issue links (from the web response) and try to locate a target issuekey (predefined) in order to get its link Id (and delete the linkage from the target issue)
The way I implemented is to iterate over the issuelinks' web response and store it in a smart-value as a delimited pair of issuekeys and Ids (we focus here only in outward for now):
{{#webhookResponse.body.fields.issuelinks}}{{outwardIssue.key}}:{{id}}|{{/}}
And using a special custom field (behave as a queue), we save this delimited string (along with the target issuekey I am searching).
I created another rule that is triggered by the 1st rule, once this "queue" custom field is changed:
That rule fetch first pair of data (issuekey:Id) and the target issue (mostly using substringBefore and substringAfter) and check if the the pair contains the target issuekey.
If it does contain then just fetch the related Id (link Id) and send it to the REST API to delete the link.
Else (if the target issuekey not found yet), update/modify the custom field with the delimited string subtracting/removing the 1st pair ==> this will trigger the rule again on the modified string.
The rules continue to be triggered until Id is found or the custom field becomes empty.
(the rules are checked to "Execute immediately" to avoid any delays)
I hope that was helpful to the community to give some way to resolve this issue of lack of iteration using Jira automation rule.
Best Regards,
Moheeb.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Since that original question was written in June 2021, advanced branching and incoming webhook trigger were both added for Jira Cloud automation:
Either one can be used to generically iterate a list of items, where advanced branching is limited to 100 issues / items and the webhook trigger is limited to < 10 items. An incoming webhook rule could support sequential processing, but it has a lower limit because it relies about recursive rule execution and might hit the automation service limit (although I have not tested that hypothesis). Advanced branching would use parallel and asynchronous processing, and so is a better fit for scenarios without sequential processing needs.
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As you said these are only for Jira Cloud.
We use a Jira Datacenter in our company, so that's not relevant and we need the alternative tricky way to accomplish that.
Best Regards,
Moheeb.
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.