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

Update: Create lookup table action improvements

42 comments

David Meredith September 25, 2023

Hey @Simmo ,

I've raised something to support too (PCS-213544) but I'm hoping I can get some insight from the guy who built it!

I'm not sure if this is an improvement that can be added or whether I'm doing it wrong but I can't get the table.get(name) function to work while in a smartvalue list. 

I have a lookuptable set up as a mapping for Organization Name and ID:

  • ACME: 15
  • MADE-UP:  8
  • FICTICIOUS: 26

I'm trying to get a list of matching Organization IDs from the lookup table using by setting a smartvalue as:

{{#addedFieldChange.values}}{{orgmap.get(name)}}{{^last}},{{/}}{{/}}

So I'm expecting the smart value to contain a comma separated list of Organisation IDs out of the lookup table: ( "15, 8, 26" ). But it never seems to return any data.

I would do this in a branch based on {{#addedFieldChange.values}} instead but then I can't use the smartvalue that I've created outside of that branch to actually make the edit to the Organizations field. 

Hope you can help / provide some insight!

Many thanks,
Dave

Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2023

Hi @David Meredith,

I feel your pain mate. Unfortunately, this is a limitation with the smart value system and not just the lookup table. It isn't possible to refer to outside variables when you're traversing a list. I've tried to do the same myself.

Our smart values guru tried to fix it during the last ship it but ran into some complications. I want this functionality myself, so I'm on his back about getting it fixed but it might have to wait till the next ship it or innovation week I'm afraid.

Nothing you've done wrong, apologies that it doesn't work as you'd like right now!

Cheers,

Simmo. 

Like # people like this
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.
September 25, 2023

Hi @David Meredith and @Simmo 

A work-around I have found for that scope limitation of searching within iterators is to:

  1. expand the list (in this case, a table) into a created variable, prefixing with your key / index and adding a known delimiter between records
  2. store your search criteria in another variable, as a regular expression
  3. then split the created variable from step #1 on your delimiter, and use the match() function using your search expression from step#2

This works because we are using inline functions to split/match rather than doing so inside of an iterator (like with a smart value, list filter).

Unfortunately, this will lose typing information of the original list, and so parsing/casting may be needed.

Kind regards,
Bill

Like David Meredith likes this
David Meredith September 25, 2023

Hey @Simmo ,

Really appreciate the response!

Glad to hear someone is working on an improvement for refering variables when in smart value lists... Could be really powerful. Is that work being tracked anywhere on JAC that I can subscribe to or anything?

I did have a workaround by branching on {{#addedFieldChange.values}} and then creating a smart value within it for the Edit, which did work but if there were 10 values they'd all try to edit at the same time and conflict... Even when I put random waits in the branch we could only get it working ~ 90% of the time.

I've ended up ditching the lookup table and having over 20 separate IF, ELSE statements to match up the Organization name and edit based on the Org ID which does the same thing... It works but it's ugly and I don't like it.

Hope to see the improved version soon!

Many thanks,
Dave

David Meredith September 25, 2023

@Bill Sheboy that sounds really interesting!

Do you have an example? I'm struggling to understand how you'd implement it.

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.
September 25, 2023

David, sorry if I was unclear as the work-around I was describing (for searching) is not a good fit for your scenario.  What you seem to be trying is:

For the entries in a list (addFieldChange), replace an attribute (name), with a value looked up from a table (orgmap).

The replacement is the challenge, and so I think you are limited to chained replacements for each table entry:

  • expand the list into a created variable with delimiters
    • name: varFieldChanges
    • value: {{#addFieldChange.values}}{{.}}{{^last}},{{/}}{{/}}
  • {{varFieldChanges.replace(orgmap.entries.key.get(0),orgmap.entries.value.get(0)).replace(orgmap.entries.key.get(1),orgmap.entries.value.get(1)).replace(orgmap.entries.key.get(2),orgmap.entries.value.get(2))}}
  • and then split the result back into a list
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
September 25, 2023

@David Meredith I'm afraid we couldn't find a JAC for it. The closet was https://jira.atlassian.com/browse/AUTO-490

Jennifer Luo September 25, 2023

Hi @Simmo ,

Yes, the order in .entries doesn't match what's in the UI - it's not showstopping but definitely a nice to have in terms of having the choice to order the lookup table / list in a certain way using jira's smart value functions!

Thank you,
Jennifer

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.
September 26, 2023

Hey @Simmo -- It appears there are several defects/suggestions for this symptom and most are either marked as duplicate or won't do:

https://jira.atlassian.com/issues/?jql=project%20IN%20(%20%22Automation%20for%20Cloud%22)%20%20and%20(summary%20~%20%22iterator%22%20or%20summary%20~%20%22iteration%22)%20ORDER%20BY%20Key

Michiel
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 9, 2023

I would love the ability to create them dynamically and also to push values in them along the way. For example I want to create a lookup table of assets, and while branching over the assets is want to store each asset key as the key, and the name of the asset as the value. Later on I could then print these out to a table and add them in comments or text fields.

Like # people like this
Simmo
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 9, 2023

@Michiel, nice idea! I'll keep that on the back burner for future innovation weeks!

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 25, 2024

@SimmoI love these changes and really appreciate the ability to loop through all entries on a lookup table.

It would be really cool if  the .entries method made it to relevant documentation pages: I'd love to see this mentioned here and here.

Shoutout to @Bill Sheboy for directing me towards this article and for the initial help with making this change happen. You rock, man!

 

Like Bill Sheboy likes this
Slava Gefen May 8, 2024

@Simmo @Bill Sheboy hey Friends, your help in workaround is really appreciated 🙏

I need to send a report by email from an Epic. The report should contain a list of stories with the info as follows:
KEY | Team | Team Type

E.g.

KEY-2 | Galaxy     | Type 1
KEY-3 | Stars | Type 2
Key-4 | Super Team | Type 3
..
KEY-n | Team n | Type n

For Epic KEY-1

I have a predefined lookupTable with values accordingly

Key | Value
Galaxy = Type 1
Stars = Type 2
Super Team = Type 3
..
Team n = Type n

As I understood .get() method for lookupTable still doesn't work inside List iterating 😕

Currently I'm trying use this:

lookupIssues: key = {{issue.key}} <-- iterates Stories

Then send email Action:

{{#lookupIssues}} {{key}} | {{Team.name}} | {{lookupTable.get(Team.name)}} {{/}}

For Epic {{issue.key}}

 Maybe it's possible to do so with Advanced Branching? How could I collect an email body then?

Thanks in advance!
With kind regards
Slava

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.
May 8, 2024

Hi @Slava Gefen 

The more general, automation limitation is: once inside of an iterator, only data from that scope and lower is visible.  And so nothing from outside (or higher in scope) can be accessed. 

For your scenario, I believe there may be only a few options possible rather than using a Lookup Table:

  • brute force
    • Use a long chain of replaceAll() function calls in place of the table get() call
    • For example: .replaceAll("Galaxy", "Type 1").replaceAll("Stars", "Type 2")...
  • extra data
    • Using a different automation rule, when the Team field is set, set another field which contains the Type data
    • This rule could use the table, as it is directly setting the value of a custom field
    • Then use the custom field in your message
  • external service
    • Build an external service, or find one which can perform a key / value table replacement on a text string, and call it with the Send Web Request action to perform the substitutions outside of Jira

Kind regards,
Bill

Slava Gefen May 8, 2024

Hey @Bill Sheboy thanks for the quick and professional reply 🙏

automation limitation is: once inside of an iterator, only data from that scope and lower is visible

Now, I'm remembering that even me created Atlassian ticket when if(equals) didn't work inside of iterator if compare with value out of iterator 😃

Do you know there will be some improvements on the matter? I believe this feature is really desired nowadays.

I believe there may be only a few options possible

Thanks a lot! First two are nice enough 🙏

With kind regards
Slava

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.
May 8, 2024

@Slava Gefen -- The only open suggestion I found is this one: https://jira.atlassian.com/browse/AUTO-490  Reading the details, the intent appears to be access data from other scopes once inside the iterator.

From other communications and community posts, my understanding is the Atlassian team has tried several times to address this limitation without success.

Like Slava Gefen likes this
Slava Gefen May 9, 2024

@Bill Sheboy I've found mine one:

[AUTO-239] Comparing values in the response of a webhook request against a custom field or smart value using string functions do not work - Create and track feature requests for Atlassian products.

it's even recognized as a bug 🅾

It seems there are several that are not linked to each other but have the same root of the issue.

Have a nice weekend!
With kind regards
Slava

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events