Forums

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

How to properly exclude a specific string from a list in Jira automation

Alexis LAFONT July 6, 2023

Hi,

 

I created a Jira Automation that aims to notify several people when a ticket is moved.

I created a custom field named "Relecteur(s)" of type "User list". Any user from this list can move the ticket. When the ticket is moved, it sends a mail to the assignee.

Inside my mail, I write that {{initiator.displayName}} has moved the ticket. But I want to display the names of the others "Relecteur(s)". I tried a lot of stuff to remove {{initiator.displayName}} from this list without succeeding...

 

I could remove the initator from the string, but the format is not great.

{{issue.Relecteur(s).displayName.remove(initiator.displayName)}}

For example, if Relecteur(s) is equal to [Alex], [John] and [Maria], and [Alex] is the initiator, I got ", John, Maria".

 

I tried to parse the list, and to condition the display. It seems that while parsing a list, other variables are not reachable...

{{#issue.Relecteur(s)}}

{{if(not(equals(displayName, initiator.displayName)), displayName)}}

{{/}}

With the example list above, I got "AlexJohnMaria"

 

What I really want is to have a list of two entries with [John] and [Maria].

 

Anyone has an idea ? I couldn't find an easy regex to solve my problem. I think that something inside Jira Automation List can help me, but couldn't find any solution.

 

Regards,

Alexis

2 answers

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.
July 6, 2023

Hi @Alexis LAFONT -- Welcome to the Atlassian Community!

As you have found, once inside of a list iterator no other higher scoped fields/variables are visible.

There are several possible work-arounds for your scenario.  One is to expand all of the displayNames into a created variable first (with delimiters), then use the remove() function on the result, and finally use split to create a list for processing again.

Kind regards,
Bill

Alexis LAFONT August 8, 2023

Hi,

I tried something like this but is is hard to correctly remove the initiator using split. Using a delimiter can always result in "NameA, , NameB" instead of "NameA, NameB", and it changes if the name to remove is first, last or in the middle.

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.
August 8, 2023

Yes, and the text functions replace() and replaceAll() can help with that...For example, you can chain functions to remove anything extra or which does not match your needs.

This could also be a problem with the iterator, so if you post that the community can offer suggestions.  For example, to avoid the trailing comma in can help to use the {{^last}} expression:

{{#someObjectToIterateOver}}{fieldWanted}}{{^last}}, {{/}}{{/}}

This would create a comma-separated values list, and leave off any trailing comma.

0 votes
Gokaraju gopi
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 6, 2023

Hi @Alexis LAFONT 

Inside the custom field list you cannot access any other values(for example assignee or another custom field value). So that's the reason you could not filter the names

Can you explain a bit more about how many people you want to send email so that we can find alternate approach in automation

Alexis LAFONT July 6, 2023

Hi Gokaraju gopi,

 

Ok that is why !

 

I've got multiple Relecteur(s), only one initiator. So my list size is [1;n] and should be [1;n-1] afterwards.

Alexis LAFONT August 8, 2023

Hi Gokaraju gopi,

Was out of the office for a few weeks, so I'm bumping this thread again !

Do you know if there is a workaround to access other values ? Like passing values into temp variable and manipulate them after, or something like this ?

Thanks

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events