The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

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

Compare watchers against the initiator of an automation rule

Sujaira Moughawiche
October 22, 2020

Hi,

I am trying to create a Smart Value with all the watchers to send an email but I want to make sure the initiator is not included. So I created a Smart Value where I use the following expression

{{#issue.watchers}} {{#if(initiator.displayName.eq(displayName),' ',{{emailAddress}})}}  {{/}} {{/}}

But the Smart Value comes back empty.

How can I check each item on an array and create another array only with the items that didn't matched the if condition?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
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 Champions.
October 23, 2020

Hi @Sujaira Moughawiche 

I believe that the #if syntax only works for numbers and not for strings.  And, I do not believe you can nest smart values with multiple curly-brackets.

Instead you can solve your problem using strings and the Join and Remove functions:

  • {{issue.watchers.emailAddress.join(";").remove(initiator.emailAddress)}}

How does this work...

  • {{issue.watchers.emailAddress.join(";")}} will concatenate the list, adding a semicolon separator
  • .remove() removes characters from a string.
  • In this case, we want to remove the initiator's email address:  .remove(initiator.emailAddress))
  • Note that if the initiator's email address is in the middle of the list, you could end up with an extra semicolon, such as: a;b;c;;e;

 

Best regards,

Bill

Sujaira Moughawiche
November 4, 2020

Hi @Bill Sheboy ,

Thanks so much for your help, this information was super helpful. I was able to remove the initiator by:

Adding a ; at the end of the join. 

Then proceed to remove the initiator including a ; at the end as well.

But I still have one ; at the end of the string and I haven't been able to remove that ;, I can't leave it because it's causing an error when sending the email. 

Smart value watchers:

{{issue.watchers.emailAddress.join(";").concat(";").remove(initiator.emailAddress.concat(";"))}}

Is there a way to do this, I tried to save the length of this smart value in another and the use the left function to return the string minus the last character but it's not working.

Smart value watcherslen:

{{#=}} {{watchers.length()}} - 1{{/}}

 Smart value emails:

{{watchers.left(watcherslen)}}

But the emails returns blank. Any ideas on how to remove the last character of a string?  

Sujaira Moughawiche
November 4, 2020

@Bill Sheboy  Never mind I figured it out. Thanks. 

Like • Bill Sheboy likes this
brian.stubelt@owenscorning.com
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 28, 2023

I couldn't get this to work with the join operation, but using the below format worked for me!

 

{{issue.watchers.emailAddress.remove(initiator.emailaddress)}}

Like • # people like this
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events