Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Lookup Table - how to iterate through all elements with a For Each Loop

Wojciech Wardaszko _HeroCoders_
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.
April 22, 2024

Hi Community!

Today I've had an interesting challenge which I failed to solve.

A customer wanted to send Slack messages to people who did not track the expected amount of time on the day before. I managed to create a simple automation rule using Clockwork API and a schedule to do that for one user, but we wanted to scale this without creating a separate rule for every user.

Now I've never used Lookup Tables before, but I figured I'd try.
The setup was this: Jira Account ID was provided as the Key and Slack MemberID was provided as the Value. We could introduce all users manually to the rule this way.

The lookup table was called {{theUsers}}

Then came the Loop: For Each of {{theUsers}} as {{theUser}}, do stuff (send a web request with the account ID as a request parameter, then if conditions met send a Slack message with the MemberID of the same user to ping them in a shared channel. I tried referring to the MemberID with {{theUser.value}}.

This didn't work. The rule kept running without a result for minutes to come.

I understand that lookup tables are designed to work with the .get() function, but I don't want to call any specific account ID. I want to go through all of them one by one. Is this even possible?

@Bill SheboyI know you have experience with this stuff, can you help?

Thank you!

1 answer

1 accepted

1 vote
Answer accepted
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.
April 22, 2024

Hi @Wojciech Wardaszko _HeroCoders_ 

In this updated article about lookup tables: https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

It shows the entries function to return the rows as a list.  Your advanced branch could use:

  • smart value: {{theUsers.entries}}
  • name: varUser

And the references inside of the branch would be:

{{varUser.key}} and {{varUser.value}}

Kind regards,
Bill

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events