Automation Rule is not populating Asset Custom field.

Christopher Kim February 18, 2025

I am using Assets to set my custom field "assignment group." How I plan on making this work is by leveraging Automation Rules to trigger once an issue is transitioned to a specific status. 

An important fact to point out is that the Description field is templated to include text called CO AG:, where the name of the assignment group will appear. For example in the description it will say CO AG: Service Desk.

 

1st attempt

1.  I had an "Edit Issue Field" Action which was written as follows, and got an error saying data was not an array.

{

"fields": { "customfield_16604": { "name": "{{issue.description.match("\#1st AG:\s+(.*)")}}" }

}}

 

2nd attempt

1. I added "Lookup Asset objects from AQL" action with the following query 

Name = "{{issue.description.match("\#CO AG:\s+(.*)")}}"

2. Add Log Action 

Lookup result: {{lookupObjects.Name}}

3. Add Edit Issue action to fix array issue

{

"fields": { "customfield_16604": [{ "key": "{{lookupObjects.Key}}" }]

}}

4. Result shows "Success" but the field is not being updated, and the log is showing no value either.

 

I've tried name and asset key and neither worked. If someone could help with this it would be immensely appreciated. Thank you!

1 answer

0 votes
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.
February 18, 2025

Hi @Christopher Kim 

For a question like this, context is important for the community to help.  Please post the following:

  • an image of your complete automation rule in a single image for continuity,
  • images of any relevant actions / conditions / branches,
  • an image of the audit log details showing the rule execution, and
  • explain what is not working as expected and why you believe that to be the case.

Until we see those...

Have you tried writing the results of the match() functions to the audit log to confirm they return what you expected?

Have you checked if the Lookup Objects action found any results?

Kind regards,
Bill

Christopher Kim February 18, 2025

The automation rule is triggered as follows and am expecting to update the custom asset field "Assignment Group" by first looking up the asset (image1) based on what is specified in the ticket (image2).  

image1

Lookup Asset.png

image2

 

 

 

once identified the following edit issue action is meant to update the field with the asset object with the same name mentioned in the description. In this case an object named Service Desk exists.

Automtation Rule.png

log shows the rule ran successfully but the field still remains empty and I believe it is because the rule is unable to retrieve the correct object. 

array fix.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.
February 18, 2025

As you certain that is the log for the rule shown as the steps do not match?  For example, the log shows a write to the audit log but that action is not in the rule shown.

 

The Issue Created trigger can fire so quickly that the issue data may not yet be available to the rule, causing errors and weird symptoms.  I recommend adding the Re-fetch Issue immediately after that trigger to slow the rule down a bit and reloading the data before it proceeds.

Have you checked if the Lookup Objects action found any results?

Have you consider consolidating those different Edit Issue actions to prevent collisions and improve rule performance?

Christopher Kim February 25, 2025

Hi Bill, 

I've tweaked the automation rule including your suggestion to add in a re-fetch action at the beginning. Here's what I am seeing so far...

I first wanted to confirm the rule was recognizing the text that is being inserted in the description field. It is grabbing that. This is important since the AQL will need that data for the query.(in red)

When I manually insert the query in Assets, it returns the object I am trying to use to populate the custom field. 

The log in the blue box however is not returning any values and consequently the final edit issue field doesn't populate since no value is found. 

I tried retrieving the key but no luck either.

 

 

Automation Rule.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.
February 25, 2025

When using lookup actions like Lookup Assets, I recommend adding a write to the audit log (or a condition) to confirm it returns results:

records returned: {{lookupObjects.size}}

 

If hardcoding the value for the AQL works and the value from the match() of the Description does not, that indicates some possibilities we can test, all by using a Created Variable action:

  1. The match() result is a list of values.  To confirm that returns one-and-only-one value, please store the result of the match on the Description in a variable, and then use that variable in your AQL.
  2. The value could have leading / trailing spaces (or other non-visible characters).  Storing the match results in the variable, as described in #1 above, and then adding trim() to the end will remove them before used in the AQL.
  3. There could be a timing problem where the AQL is evaluated before the match() completes.  Storing it in the variable will force complete evaluation before the lookup tries to use it.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events