Add a list of assets to an asset objects list field

Luka Urushadze August 14, 2024

Hello everyone,

I have a custom field - Select List (multiple choices) and from this custom field I want to fill in an Assets objects custom field which can hold multiple objects. With automations, I was only able to edit the field and add one value - with advanced branching for each value, it simply overwrites the previous one so in the end I always have a single value in the field. Any ideas on how I can maybe attend a value instead of setting it?

4 answers

1 accepted

1 vote
Answer accepted
František Špaček _MoroSystems_
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.
August 14, 2024

Hi @Luka Urushadze

 

I am not sure what your query to the Asset database is, but my guess is that it returns single object everytime? If so, is it maybe possible to use just one Lookup with combined query to search for all objects altogether? I can help you with that, but I will need a little bit more info about the original multiple select and how do you translate those values selected to assets query.

 

If so, then you can really shorten this automation to two actions:

  1. Lookup objects
  2. Edit issue

Once you get the Lookup Objects to return all objects you need, you can then simply use "Edit issue" action, select field you want to edit, and put this inside:

Key IN ({{#lookupObjects}}"{{.}}"{{^last}}, {{/}}{{/}})

 

This will ensure all returned objects are stored in your multi picker assets field.

 

Have a nice day!

Luka Urushadze August 14, 2024

Hello František,

that'd be fantastic - the select field holds the labels of the objects. I couldn't think of a way to look up all values from the select list at the same time. Could you advise how I could do that?

Best Regards,

Luka Urushadze

František Špaček _MoroSystems_
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.
August 14, 2024

Hi @Luka Urushadze

 

could you please provide us any example? What does the values in the multi select look like and what does a single object in your databse look like, so I can help you with the query?

Luka Urushadze August 14, 2024

Thanks! Here's the values of the select field as an example, and one of the assets. It's a list of countries actually.

Field values:

Screenshot 2024-08-14 at 18.59.01.png

Asset Object:

Screenshot 2024-08-14 at 19.00.27.png

František Špaček _MoroSystems_
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.
August 14, 2024

Ok, that should be fairly easy - I see that you can search by label for assets, so I would do something like this (for having it well aranged and debugable for the future).

 

After trigger will follow these actions:

  1. Create variable
    1. Put whatever name you want there (e.g. countries - so the resulting smart value will be {{countries}})
    2. Smart value will be like this:
    3. {{#issue.Field}}"{{.}}"{{^last}},{{/}}{{/}}
    4. Replace "Field" by the name of your multi select custom field. This will create variable, that will create list of values, from your example it should generate "DE", "FR", "IT", "ES"
  2. Log action and just put {{countries}} in there - just to be sure you've got correct variable in the audit log. It should print "DE", "FR", "IT", "ES" to the Audit log when rule is executed.
  3. Lookup issues
    1. Set the scheme you want to search in.
    2. AQL will be:
    3. label IN ({{countries}})
    4. This should return all objects, 4 in your example (assuming that all exists in Assets database and have correct names).
  4. You can add another "Log action" here and just put "{{lookupObjects}}" there, again just to see what is happening.
  5. Last will be Edit issue action.
    1. Select Assets field you want to edit and put this into it:
    2. Key IN ({{#lookupObjects}}"{{.}}"{{^last}}, {{/}}{{/}})

And this is it.

 

Obviously "Log action" steps are optional, but I always recommend printing at least some variable from within the automation to the audit log. In case it fails somewhere from time to time, it will be much easier for you to see what happened. E.g. you will add new option to the select, but forget to add new value to the assets too. That might result in lookupObjects being empty.

 

Also one last note: I am not sure what your process is, but why won't you let people use that asset field directly? Thats probably the biggest advantage of the whole assets - to be able to select from them. Even on the customer portal or anywhere. Here you are basically just duplicating things.

 

Have a nice day!

Like # people like this
Luka Urushadze August 15, 2024

Hi František,

thanks a lot, that saved my day! It worked perfectly and was exactly what I was looking for.

I couldn't use the asset fields directly as the flow usually starts from people importing large number of issues via CSV, with large number of assets in the list, so we needed it to be automated.

Huge thanks and have a nice day!

František Špaček _MoroSystems_
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.
August 15, 2024

Hi @Luka Urushadze

 

it was pleasure to help you. If you can, please accept my answer as an "Accepted answer". thanks to that, this answer will stay on the top and your question will be labeled as answered.

 

Thanks and have a nice day!

0 votes
Marc - Devoteam
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.
August 14, 2024

Hi @Luka Urushadze 

The object that is linked with the asset custom field, what is the cardinality set for the attribute.

By default this is 1, you might need to change that.

Luka Urushadze August 14, 2024

Hi Marc, thanks for the answer! The custom field can hold multiple values when I add them manually, is that still relevant?

Marc - Devoteam
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.
August 15, 2024

No, then your cardinality of the custom field of type assets is correct

0 votes
Ryan M
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.
August 14, 2024

Hi Luka,


I imagine you'd probably have to get creative and use JSON in conjunction with smart values to update this, similar to what's illustrated in solution 2 in this article. https://support.atlassian.com/automation/kb/how-to-update-a-select-field-multiple-from-the-content-of-other-fields/

Have you attempted that yet?

Ryan M
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.
August 14, 2024
0 votes
Luka Urushadze August 14, 2024

Here's the automation currently:

Screenshot 2024-08-13 at 21.08.23.png

Suggest an answer

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

Atlassian Community Events