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.
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).
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(",")}}
Then passing it into the Edit Object action like this:
[ {{#filteredApps}} { "key": "{{.}}" }{{^last}},{{/}} {{/filteredApps}} ]
But it doesn't work.. any help is appreciated.
Fabio
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:
{{object.Applications.key.flatten.join(",")}}
Kind regards,
Bill
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.