Trying to make an aggregated list or variable

Kim Barry February 26, 2025

Trying to write an automation that:

An individual enters a team id in a field and that triggers a comment to be added with the Opsgenie services that the team is a responder and another comment is added with the Opsgenie services that the team is NOT a responder.

I have three automations that feed into this one.

1. Add the two comments with just a couple lines that include the team's id and "team is a responder to these services" or "team is NOT a responder to these services"

2. Adds the first comment's id to a field

3. Appends the second comment's id and the team id to the field

 

This automation

  • creates variables from the 3 values saved in the field
  • does web requests to get the contents of the comments and creates a variables with them
  • does a web request to get the list of services
  • then does two advanced branches, yes branch and no branch that does essentially the same thing
    • iterates through the services ids
      • pulls the responder teams for each
      • checks if the team id is in the responder team list
      • saves the service id in a variable based on the previous condition

 

I know right now it's just a list of ids, but I can do a web call to get the Service Names. However I need to make a list from the variable at the end of the two branches. If I add it directly to the comment, it just overwrites itself and I can't seem to aggregate the variable.  

I have thought to try and create two automations, one for each comment and iterate through the list without the branching but I can't seem to figure out how to accomplish that either.

 

1.png2.png3.png4.png5.png6.png7.png8.png9.png10.png11.pngfullRule.png

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2025

Hi @Kim Barry 

Without digging too far into your scenario specifics, it appears you are trying to do this:

  • create a variable
  • using an Advanced branch, iterate over some things
    • inside the branch, update the variable contents
  • use the updated variable after the branch

That will not work.

Branches which could iterate over more than one thing (e.g., Advanced Branch) are executed in parallel and asynchronously.  Each loop uses separate processing space and there is no guarantee of when the branch will complete, up until the last step of the rule.

This means any variables created / updated inside the branch go out of scope and are gone after the branch.

Workarounds for scenarios like this may involve restructuring the rules, such as removing the branches when possible.

 

If I have misunderstood your scenario, please let me know.  Thanks!

 

Kind regards,
Bill

Kim Barry February 26, 2025

You're right but I haven't figured out another way and asking for help in determining another way, because I have been attempting it for two days without luck. I have tried appending the new value to a field, but each new value, isn't appended, it overwrites. I have tried removing the branch, but cannot figure out a way to iterate through the list of services. I don't really want to have a comment for each service, but I guess I could and write a separate automation to aggregate the comments then send an email instead. 

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2025

Backing up a bit: what will the rule do with the Service ID once it is found for the respective Team ID?

 

Storing data elsewhere (such as a comment for each loop pass) is a workaround technique I have seen used before for such scenarios. It does create additional timing challenges to know the next rule in the chain should start and aggregate results.

I have not used the Opsgenie REST API before.  Is there endpoint which would allow getting the information for multiple services with one call, and the using a regular expression over the web response to parse the results?

Kim Barry February 26, 2025

I want to provide a two lists, the services the team is a responder and not a responder. 

 

How I have done this before is add a label at the beginning of the automation, remove it at the end. Have the second automation triggered of the label added, then do a delay for a little more than automation typically takes to run, have it check if the label is still there. If it isn't run the rest of the automation, if not add a little more delay, and I think you can do it one more time. I may have to try this and not care how ugly it is, if I no longer have to look up the information for people.



Reading through the API documentation, I don't see a way to pull multiple services, not that you have to read through it but here is the documentation, Service Audience Template API.

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 26, 2025

This doesn't sound like an unusual need / scenario to me, so I recommend asking your Jira Site Admin to contact Atlassian Support if there is already a capability to get the list of responders for multiple services in one go: https://support.atlassian.com/contact/#/

 

In the mean time, how stable is the list of services / responders?  If it is very stable, an ugly approach is replicating the data in a Lookup Table within a rule and so eliminate the need for the repeated REST API calls.  The rule could contain conditions to check for non-matches, alerting a rule-writer to update the table rows.

If it is not stable, it might be safer to build and host your own service (in another language) which can perform the serial and synchronous calls to loop over the services and return the accumulated results.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events