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

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Compare watchers against the initiator of an automation rule

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

1 vote
Answer accepted

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

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?  

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

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Bamboo

Bamboo Data Center Apps Program coming soon

G’day Bamboo customers, As we approach GA for Bamboo Data Center , we would like to inform you that the Data Center Apps Program for Bamboo starts this quarter. How long does it take? We are g...

75 views 0 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you