Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use automation to populate Assets custom field with multiple objects

Klime Buneski November 27, 2023

Hello,

At the moment we are using the Components field in the JSM portal for users to select the application/s for which they are raising the ticket.

In the near future we want to replace the Components field with a Assets custom field named Affected Service - this field has been already created and added to the screens, and the ObjectType Applications & Products also is created in Assets, each object containing different attributes. The Affected Service field can accept multiple Objects.

Each Component in the JSM project has its corresponding Object, for example, Jira Component has Asset Object with attribute Application Name = Jira

Jira Applicaiton Asset Object.png

As we have many separate automations triggered by the Components field, we do not want to replace it straight away, but instead temporary we want to have both fields in the screens - Components to get user app selection from the portal, and additionally the Affected Service Asset field to provide additional info on the selected apps.

To have that, I need an automation that will work in this way:

- On issue created, for each selected Component in the JSM issue, check if in the Applications & Products there is an Object where the Application Name equals to the selected Component, and add that same Application Object to the Affected Service Asset field

I have created one automation, but it works only when a single Component is selected. 

AutomationConfig.png

When there are multiple Components selected, an error is thrown:

Logs.png

I am suspecting on two things: either I have not set properly the Components iteration, OR I need to use some Array reference when populating the Affected Service Asset field with multiple values. However, I am a bit stuck for some time.

Can anyone give some guidance or directions here - either how to fix this, or maybe suggest some alternative approach?

Thanks in advance.

Best,

Klime

4 answers

1 accepted

0 votes
Answer accepted
Klime Buneski September 3, 2024

Thanks guys, I totally forgot on this post.

I managed to find a solution with help from Atlassian Support:

  • first, I do an Assets Object lookup where "Application Name" IN ("{{components.name.join("\",\"")}}")
  • if there are Objects found - checking this by smart value condition if {{lookupObjects.size}} > 0
    • I create new variable ComponentName with smart value {{lookupObjects.Application Name}}
    • Finally, I update my Assets custom field with this value: "Application Name" in ("{{Components.name.join("\",\"")}}")

 

automation.png

It  looked a bit strange to me, but it works as desired.

Hope it will do the same for someone else too :)

Best,

Klime

 

0 votes
Marek Bujak August 29, 2024

Hi @Klime Buneski

not sure if the answer is still needed, but maybe it will be helpfull for someone else.

I managed to solve quite similar concern thanks to this articles:

https://community.atlassian.com/t5/Jira-Service-Management/How-to-add-multiple-quot-affected-services-quot-via-automation/qaq-p/2036542

https://community.atlassian.com/t5/Jira-Service-Management/Dynamically-assign-value-to-Affected-Services-field-via-JSM/qaq-p/1728392 


I used below approach and it worked perfectly fine form me:


If you Service Objects field (which is a custom Insights object field type) accepts multiple values, you might as well wanna use Jira's loop-over-list template stanzas: 

{
"fields": {
"Affected services":[{{#issue.Service Objects}}{"id":"{{Service ID}}"}{{^last}},{{/}} {{/}}]
}
}

 

What it does is looping over a list of values and creating JSON structure {"id":"Service ID"} for each value inside list. 



Basicaly, multiple objects Asset field stores an array of elements 

[
{object_1},
{object_2},
{object_3}
]

thus it's not possible to update such field by trying to push multiple objects as one "entry"

[

{object_1, object_2, object_3}
]

0 votes
Lydia Kreibig
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!
May 25, 2024

Hi @Klime Buneski , 

I have exact the same problem. Is there a solution in the meantime?

Best,

Lydia

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

Hi @Klime Buneski 

What is the config of the Assets CF looks like.

I think it might that the option multiple is not enabled in the Asset CF field.

Klime Buneski November 28, 2023

Hey @Marc - Devoteam , thanks for responding.

Below is the field configuration, the option is enabled and manually I can add multiple objects. 

I cannot do that via the automation.

FieldConfiguration.png

Best,

Klime

Suggest an answer

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

Atlassian Community Events