Forums

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

Automation Rule to Remove Object from Assets Multi-Object Attribute

Fabio Cerullo July 26, 2025

 I’m trying to build an automation rule in Jira Cloud that removes an object attribute (application) from a multi-object attribute (field type: Assets object attribute) in the Employees object type.

Context 

  • Schema: Staff

  • Object Type: Employees

  • Attribute: Applications (multi-object, references the Applications object type)

  • We already have a working rule that adds applications using a structure like:

Now, I want to remove a specific Application (e.g., APP-17) from an employee’s list of Applications when a sub-task is created (used for access revocation).

What I Tried 

  1. Using variables allApps, filteredApps and appToRemove:

appToRemove

{{issue.customfield_10629.key}}

allApps

{{object.Applications.key.join(",")}}

filteredApps

{{allApps.replace(", ",",")
.replace("[","")
.replace("]","")
.replace(appToRemove, "")
.replace(",,", ",")
.trim(",")}}

  1. Then passing it into the Edit Object action like this:

[ {{#filteredApps}} { "key": "{{.}}" }{{^last}},{{/}} {{/filteredApps}} ]

But it doesn't work.. any help is appreciated.

Fabio

 

1 answer

1 accepted

7 votes
Answer accepted
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.
July 26, 2025

Hi @Fabio Cerullo 

Without seeing your complete rule and the audit log details...

Have you tried writing to the log the incremental pieces of that smart value expression, confirming each step parses as you expect?  For example:

appToRemove: >>{{appToRemove}}<<

allApps: >>{{allApps}}<<

filteredApps: >>{{filteredApps}}<<


And then the pieces of the parsing:

allApps.replace(", ",","): >>{{allApps.replace(", ",",")}}<<

allApps.replace(", ",",").replace("[",""): >>{{allApps.replace(", ",",").replace("[","")}}<<

...

Please note the extra >> and << characters to help confirm the exact contents.

 

Also, as the allApps variable apparently contains a nested list (which is why you are removing the square brackets), perhaps try adding the flatten function instead:

  • action: create variable
    • name: allApps
    • smart value: 
{{object.Applications.key.flatten.join(",")}}

 

Kind regards,
Bill

Fabio Cerullo July 26, 2025

Hi Bill,

thanks for your answer.. here is the output of the action log:

allApps: STAF-17,STAF-16 >> {{object.Applications.key.join(",")}} <<

appToRemove: STAF-17 >> {{issue.customfield_10629.key}} <<

Final:

The following Edit Object action wipes all contents but I would like to just remove a single app.

{{allApps.replace(", ",",").replace("[","").replace("]","").replace(appToRemove, "").replace(",,", ",").trim(",").split(",").distinct}}

By the way, I'm not using nested lists as per above example.

Any pointers are appreciated.

Thanks

Fabio

Like John Funk likes this
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.
July 27, 2025

Thanks for testing those expressions, @Fabio Cerullo 

As you have no nested lists, the replace functions to remove the brackets should not be necessary.  Let's try a different expression to see what happens...initially just writing the result to the audit log:

{{allApps.replace(appToRemove, "").split(",").trim.match("(.++)").distinct}}

What that does is:

  • for your allApps variable, remove the undesired one with replace
  • and then split on just a comma; we do this next because...
  • we could leave leading / trailing spaces on each item, so we add a trim function
  • and because there could now be empty elements, we add a match() function with a regular expression to only return non-empty items
  • finally, adding a distinct to remove any duplicates

Please try that one, and if it works, you may add iteration to build your dynamic JSON expression.

 

Fabio Cerullo July 28, 2025

Hi Bill,

Thanks for the input.

I've tried split/filter but it is not playing nicely.

What I've done and I (almost) got it working is as follows:

appToRemove >> {{issue.customfield_10629.key}}

allApps >> {{object.Applications.key.join(",")}}

cleanedAppsOne >> {{allApps.replace(appToRemove, "")}}

cleanedAppsTwo >> {{cleanedAppsOne.replace(",,", ",").replace("^,", "").replace(",$", "")}}

trimmedApps >> {{cleanedAppsTwo.trim(",")}}

uniqueApps >> {{trimmedApps.distinct}}

 

Here is the action log:

 

Variable Debug Log: appToRemove: STAF-17 allApps: STAF-17,STAF-16 cleanedAppsOne: ,STAF-16 cleanedAppsTwo: ,STAF-16 trimmedApps: uniqueApps:

As you could see, the trailing comma never goes away and that cascades into an empy value.

Any help is appreciated.

Fabio

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.
July 28, 2025

Something seems incorrect if that expression does not work.  This is one reason posting images of rules, actions, and the audit log helps to confirm we are aligned on what is being tried.  Regardless...

 

  • The trim() function does not take parameters, and so trim(",") does not do anything with the "," passed in
  • The distinct function works on a list, not on a text variable.  A variable would need to be split into a list first.
  • The trailing comma is a remainder after the replace.  The way I was suggesting to handle that is to split() into the list and use the match() to only return non-empty list items before using distinct.

 

Fabio Cerullo July 28, 2025

Bill,

Thanks for your help.

I went back to your example and the output of 

{{allApps.replace(appToRemove, "").split(",").trim.match("(.++)").distinct}}

is exactly the application that remains after the appToRemove is removed.

So it is working as expected.. now, you mentioned something about adding iteration to build your dynamic JSON expression. I believe that should go in the Edit Object action?

{{#filteredAppKeys}} >> is the expression you provided me above.

I've tried the following in the Edit Object but it is not working:

[ {{#filteredAppKeys}} { "key": "{{.}}" }{{^last}},{{/}} {{/filteredAppKeys}} ]

Can you please guide me on how to do that?

Thanks,

Fabio

 

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.
July 28, 2025

If your variable filteredAppKeys contains a comma-delimited list of values, it needs to be split before iteration will work:

[ {{#filteredAppKeys.split(",")}} { "key": "{{.}}" }{{^last}},{{/}} {{/}} ]

 

FYI...I am not currently using assets in my test site and so cannot experiment with that expression for an object update.

Fabio Cerullo July 28, 2025

hi Bill,

{{filteredAppKeys}} contains STAF-16

But it is giving me an error when trying the expression above.

Attribute value is not valid on Objects
STAF-693 (Applications = [ { "key": "STAF-16" } ])
Unable to update objects

any pointers are really appreciated.

Fabio

Fabio Cerullo July 28, 2025

Hi Bill,

Thanks a LOT for your help. 

That smart variable that you provided me was a life saver.

I've finally managed to edit the object successfully... here is the syntax:

{{filteredAppKeys.replace(", ",",").replace("[","").replace("]","").split(",").distinct}}

Kind regards,

Fabio

Like Bill Sheboy likes this

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