Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,299,390
Community Members
 
Community Events
165
Community Groups

JSM Automation - Problem with 'For each: Smart value'

Hi there,

I have an automation rule in place that checks maintenance end dates from Insight and sends an email with some information.

The problem is I want to add the details to one email and then have it sent off, currently what is it doing is sending an email 'per' line so I end up with a heap of emails.

I have a check for the lookupObjects.size being greater to 0, then a for each: smart value {{ObjectList}} to send an email which I get is doing what it should, but I just want them all in the one email.

What do I need to tweak to have all the info listed in the email body then send to the recipients.

thanks.

1 answer

1 accepted

Nice, heading there right now - will loop back with questions if you don't mind.

@Fabian Lim Hmmm, I sort of have something happening but not quite.

I used this in the content for the send email (remembering I am pulling values from Insight)

{{#lookupObjects}}
{{ObjectList.Product Name}} - {{ObjectList.Quantity}} - {{ObjectList.Maint End Date}}
{{/}}

Now I get an email containing the right amount of lines, but the email is just fill of

- -

AND I an getting that email for the same number of items.  So it is adding something to the body of the email, but also sending the email on repeat.

Fabian Lim Community Leader Jun 02, 2022

Looks like you are using the wrong smart value syntax. You should be using lookup objects instead.

Link: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-insight/#SmartvaluesInsight-Lookupobjects

hmmm I use ObjectList. as the step before has Advanced Branching that has the smart value of {{lookupObjects}} and it is turned into the ObjectList variable.  Other send emails I have where I don't need to loop through the results all work like this.

 

I'll check the link to see if there is something else wrong.  The email is still being sent dozens of times also so I think the automation is wrong in general somewhere.

MaintenanceExpiry.JPG

@Fabian Lim   I have this working now using this;

 

{{#lookupObjects}}
* {{Product Name}} - {{Quantity}} - {{Maint End Date}}
{{/}}

 

BUT, I still get an email with all the combined output for each item.  So my test returns 15 lines in the email, but I get that 15 times?!

Fabian Lim Community Leader Jun 03, 2022

I think the for each object component is causing it to go 15:times. You should remove it.  

Like Steven Lees-Smith likes this

yep makes perfect sense when you see it written out?!

 

Thanks, of course if it is doing that same thing for each returned instance it was going to email that many times - all good now and only sending the one email.

Like Fabian Lim likes this

Make sure you accept the answer this one is a very good example that others can use.  

Like Steven Lees-Smith likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Service Management

Coming Soon: Insight Changing to Assets

The 2020 acquisition of Mindville added powerful asset and configuration management capabilities to Jira Service Management in the form of Insight. Following the completion of that integration, custo...

402 views 3 12
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