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

Workaround for: How to look up Assets objects in automation when the AQL contains an "&&"

 

Problem

There is a known bug about looking up Assets (Insight) objects in Jira automation when the AQL contains an “&” character throws an error and returns no results: https://jira.atlassian.com/browse/JSDCLOUD-11142

Steps to Reproduce

  1. Create an object with a Name containing an & (e.g. "A & B")

  2. Create an automation rule (schedule trigger, lookup objects action)

  3. Add an IQL like "Name = "A & B"

  4. Execute the automation rule

Expected Results

The IQL is executed and the object with the name "A & B" is returned in the results

Actual Results

An error is returned like "IQL has invalid syntax... token recognition error at..."

 

Workaround

  1. Create a new attribute (Alternative Name) as the alternative attribute for Name.

  2. Set the alternative value without “&” to the new attribute Alternative Name for all objects that contain the “&” character. For example: If the Name is "A & B", the Alternative Name should be set to “A and B”.

  3. Via automation rule, create a formatted search input to replace the “&” character by “and” word:

    1.png

    (The searchInput can be a custom field value or a variable)
    {{searchInput.replace("&", "and")}}

     

  4. Update the AQL with the formattedSearchInput instead.

    2.png

    • BEFORE:

      key IS NOT EMPTY AND Name = "{{searchInput}}"

       

    • AFTER:

      key IS NOT EMPTY AND (Name = "{{formattedSearchInput}}" OR "Alternative Name" = "{{formattedSearchInput}}")

      (The part "key IS NOT EMPTY" is just a test AQL to remind using the parentheses () after this test clause - without the parentheses () it will not work as expected).

  5. Test result: 

    3.png

Pros and cons

Pros

  • The original attribute value with “&” is preserved and can be found via AQL.

Cons

  • Have to add a new alternative attribute.

  • Have to populate the alternative attribute for all affected objects.
    However, we might automate this step if there are too many objects:

    4.png

    • Branch on AQL through all objects.

    • Check if {{object.Name}} contains "&".

    • Edit the object to set the Alternative Name = {{object.Name.replace("&", "and")}}:

      5.png 

 

2 comments

Jennifer Luo May 10, 2023

I've been using a web request in my automations to grab the object key, which queries for a name that includes the ampersand:

image.png
This will return the object/s you specify.

UPDATE: You no longer need this workaround since Atlassian has fixed the bug.

Like Jennifer Luo likes this

Comment

Log in or Sign up to comment
TAGS
AUG Leaders

Atlassian Community Events