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

New Automation action - Create lookup table

42 comments

Comments for this post are closed

Community moderators have prevented the ability to post new comments.

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

I'd love to see a screenshot of the rule arrangement, that would help.

Certainly using status.id isn't going to work. I think you may be right in that the scoping problem is dropping visibility of the table. I'll ask the smart values master about it.

Update: confirmed that you're right, it is the scoping issue.

Like # people like this
Ingo Wenke
Contributor
April 27, 2023

ok, now while it's confirmed. What's the next step?

(cross fingers to get a fix for that)

Eric Rosche May 26, 2023

Hey,

is it possible to loop over the values of the look up table in any way? 
So something like:

{{#lookupTable.values}}

// use the value here

{{/}}

Or in a key-pair way? (i only need a list of the values). I searched and tested for a while, but couldn't find anything.

Edit:
I have found a "workaround" for this. when creating a "Create variable" action and putting the lookup table as value the table gets transformed to a string.

Then a "For each" branch can be created which iterates over {{lookupTableVariable.split(", ")}}. then one can create another lookup table in the branch with a chosen key and as value: {{branchSmartValue.remove("{").remove("}").split("=").get(0)}} (0 for the Key and 1 for the value).

This is not every nice though, but at least it works.

Like denis_sheridan likes this
Guido Menardi
Contributor
June 14, 2023

Tables are useless if you don't fill them with 'text values'. If you want to import an asset field, first you must 'convert' it to text with a normal variable (even if the source asset field is type=text). If you try to apply any function over a value imported directly to table, this will fail as empty.

{{tableName.get("tableKey") wil show the value, but

{{tableName.get("tableKey").asJsonObject("value")}} will not work as expected, returning null. It happens with any function (split, replace, etc).

Workaround:

  1. Create variable assetField = {{object.field}}
  2. Create lookup table (tableName) with key=tableKey and value={{assetField}}
  3. {{tableName.get("tableKey").asJsonObject("value")}}

@Doug Levitt : In cases like yours, we use an Asset to store huge information. This can be splitted into several tables and also can be retrieved from different automation rules. But I also agree that the limit is to short.

Like # people like this
Jordan Wilkinson June 19, 2023

@Nicolas Philip awesome workaround for the custom field variable issue. Reading another post above regarding status references and specifying the attribute, that seems to apply to custom fields as well. I added `.value` to my custom field reference, and it works correctly but not without. I'm testing with a single-select custom field.

before (non-functioning):

{{table.get(issue.custom field)}}

after (functioning):

{{table.get(issue.custom field.value)}}

@Simmo when calling a custom field value in the smart tag in this case, it is pulling an id instead of the "value" attribute from the custom field choice? Referencing {{issue.custom field}} for instance in an audit log entry seems to pull the value attribute by default, making this a bit confusing.
EDIT: I see your post regarding the scoping problem related to status references. Seems to be the same with custom field references.

Like Italo _Modus Create_ likes this
denis_sheridan
Contributor
June 28, 2023

@[deleted] , I wanted to follow up on the post from @Eric Rosche ... is there an easy way to loop over the keys in a lookup table? I would like to have a table containing "team name" and "slack channel". My intention would be to iterate over all the team names, create a Lookup Issues using the team name as a parameter in the JQL, and then send a Slack message with the results to the team's corresponding channel (from the lookup table). If this is possible, can you please share some example code? Thanks!

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.
June 28, 2023

Hi @denis_sheridan 

I was able to do that in two steps...

  • Copy your table to a created variable to convert it from an object to text.  Let's name that varCopyOfTable
  • Extract the keys from the resulting text version of the table:
    • {{varCopyOfTable.split(",").match("(.*)=.*")}}

That works by splitting the table rows back up, then finding the key values to the left of the equals sign.  The result could then be split to use as input to an advanced branch for your scenario.

Please adjust the searches accordingly if you have any embedded commas or equals signs in your table values.

Kind regards,
Bill

Like # people like this
denis_sheridan
Contributor
June 30, 2023

Here's a screenshot of how I got this setup via the UI in case anyone else needs a little more help. This builds off of the great advice from @Eric Rosche and @Bill Sheboy.

lookup-table.png

Like # people like this
Gergana.Damyanova
Contributor
July 19, 2023

For some reason I can't get the lookup table to work with a variable.
Am I doing something wrong?

 

This works

{
"fields": {
"customfield_10464":{"value":"{{otherteams.get("JITP")}}"}
}
}

 

This doesn't work

{
"fields": {
"customfield_10464":{"value":"{{otherteams.get("{{linkedIssueKey}}")}}"}
}
}

I tried all variations with quotes, without quotes, brackets, etc. 

Deepak Prasanth July 19, 2023

I am trying to work out a way where we can add user names under Lookup table and add those values in the request participants field based on a day [Monday to Friday].

Any suggestions on this will be very much appreciated.

Screenshot 2023-07-19 at 13.09.32.png

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.
July 19, 2023

Hi @Gergana.Damyanova 

For what you are trying to use a created variable as the get() parameter, the syntax would be:

"customfield_10464":{"value":"{{otherteams.get(linkedIssueKey)}}"}

However I retested and that seems to also not work.

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.
July 19, 2023

Hi @Deepak Prasanth 

Have you tried adding a delimited list of the accountId values for the users to the table rows?  Once a row is selected, it could be split by your delimiter for use.

Gergana.Damyanova
Contributor
July 19, 2023

@[deleted] that actually worked for me, it gets the right value from the table. I tough I have exhausted all possible quote-bracket combinations, but obviously except this one. Thanks a lot for your help!

Like Bill Sheboy likes 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.
July 19, 2023

Thanks, @Gergana.Damyanova 

And an FYI for @Simmo -- It seems there is a difference in behavior when using a Created Variable as a value for the get() in lookup tables:

  • when the table key and variable represent a value that cannot be interpreted as a number (e.g., "Five") the lookup works
  • when the key can be interpreted as a number (e.g., "5") the lookup does not work

Has something changed where created variables, or the parameter to get(), are now explicitly or implicitly typed?

Thanks!

UPDATE 2023-07-20: After retesting this morning in a free license, Jira instance, I was unable to repro the symptom noted above.

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

Hi all,

I've been on leave for a few months so apologies for not getting back to questions. Thanks @Bill Sheboy for running point.

We have innovation week again next week so I plan to work on improvements to the action based on some of these observations.

@Bill Sheboy I'm not quite following the issue that you're talking about. There have been some changes while I've been away.

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.
July 20, 2023

Hi @Simmo 

After retesting this morning I was not able to repro the symptom I saw where a number stored as a created variable could not successfully look up a table value with get().  I sent you my rule in a separate communication.

I will update my earlier post accordingly.

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

An update to this article can now be found at https://community.atlassian.com/t5/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

I'm going to close comments as they're starting to get a bit unwieldily. If you're after support for this component, best to ask a new question or raise a support request.

Thanks everyone for your feedback!

Like Bill Sheboy likes this

Comments for this post are closed

Community moderators have prevented the ability to post new comments.

TAGS
AUG Leaders

Atlassian Community Events