JSM automation to edit ticket custom fields with attributes from linked object
Asked by Umar Ali Choudhry:

Hi,

I am very new to JSM, so apologise in advance if this is a noob question. Also, it's very likely that I might not have configured everything the way its supposed to be configured :)

Background:

I have an asset schema configured where I have Objects for "Installations". The Installation object has multiple attributes such as: "customer", "location", "Date of Installation" etc

And in JSM I have added custom fields for all the attributes that I have in that object schema.

Question:

Is it possible to set up automation such that when a JSM ticket is created, and then when I add an "Installation" in the "Installation" field, it automatically edits/updates, the other custom fields on the JSM ticket based on the value added on the Installation field?

As in,

If I add Installation: #123XYZ

automation looks up the #123XYZ object, and adds value of the "customer" attribute to the "customer" custom field in the JSM ticket, "Date of Installation" from the object to the "Date of installation" custom field....and so on.

Once again, I am very new to JSM and Jira's asset management, and can't fingure out hwo to do the above.

Thanks!


Answers:
author: Rik de Valk
body: Hi [@Umar Ali Choudhry](/t5/user/viewprofilepage/user-id/5446136) ,

You can use a smart value to access object attributes in Automation rules.

You can read about that here: <https://confluence.atlassian.com/jirakb/how-to-copy-from-to-asset-field-value-to-from-jira-text-custom-field-using-automation-for-assets-1236938142.html>

In your case, the Object is in a Custom Field. So in your Rule, you can choose the Edit issue action, and choose the Customer field and set that field to this smart value:

```
{{issue.Installation.customer}}
```

And in case the Customer attribute of your Installation object is a reference to a Customer object, you'll have to use

```
{{issue.Installation.customer.Name}}
```

Have a nice day! Rik

comments: author: Umar Ali Choudhry
body: Hey [@Rik de Valk](/t5/user/viewprofilepage/user-id/628286) Thank you for responding. I think I am getting the basic concept, but I am still messing up the syntax somehow.

Here is what I am trying:

++Automation steps++   
**Trigger** : "When: Value changed for Installation" *(Installation is an "Assets object" custom field, which is configured such that it shows up a list of all the Installations in a drop-down, and I can select and set the right installation for the specific JSM ticket.)*

**Then:** Lookup objects.

Schema: Customer Management

Query:

```
objectType ="installations" and name = ${customfield_11013.label}
?
```

**And:** Add value to the audit log. *(For now, I am just trying to log the value from the above to check if I am even getting the right now)*

```
The installation name is: {{lookupObjects}}
?
```

In the log, I just get*"The installation name is: "*, which means that it is not getting anything from the AQL in the second step.

I have tried so many permutations of the AQL, to try and get the right syntax using brute force, but so far nothing's worked.

The closest it got was this error (can not remember exactly what I had changed in the AQL for this):
> Could not retrieve objects from custom smart value query:  
> AQL "objectType ="Installations" and "Name" = Issue."".label and objectSchemaId == 2" has invalid syntax at position 44 with error message "mismatched input '.' expecting {\<EOF\>, ' '}"
>
*Edit: typo*


author: Rik de Valk
body: It's always good to first try to compose a proper AQL in the Assets search. AQL is a bit more difficult to get correct compared to JQL, especially since it doesn't auto-complete.

So go to Assets, and to your object type. And there hit Filter and switch from basic to Advanced AQL. Then start composing your AQL to get the exact syntax and desired filter result.


Tags: asset-management

automation

cloud

jira-service-management

jira-service-management-cloud