Solved

Sending emails in loop with no records

  • 24 June 2020
  • 5 replies
  • 21 views

Badge +10

I'm trying to setup a weekly task reminder to users with active tasks.

In my different environments I have to seperate it out so the emails only go to specific AD Groups for those environments,
Example: 
In DEV
I need to send an email to each member of a Developers group - IF they have an email address in the stored procedure I'm using to feed in the names.
In MO
I have 3 AD Groups I am splitting out to send emails to.

I got it to work -however - if the name in the AD Group doesn't have any records - they still get an email but it's blank.  I want to do like a if then else type thing on this loop.  Tried using a Reference but it breaks if the name doesn't have a record.

Hope that makes sense

I have 2 stored procedures
1 that goes and createst a unique record for an active user with email / fqn
1 that goes and creates a list of all 'tasks' that belong to that user.

So I need to loop the SP to match AD but if they don't have a record - do not send an email.

icon

Best answer by BB33 26 June 2020, 08:57

View original

5 replies

Badge +12

Hello,

Have you tried adding a Decison step in between the Loop and the Send an E-mail step? On the Decision step, you can create a custom rule such that if the current item has a value then connect it to the Send an E-mail step; otherwise, continue back to the loop.


Badge +10

I might be missing something completely obvious on this.

I tried using a Reference & Decision - but I can't for the life of me get this to work.

So the AD Group has 3 members. (Member 1 / Member 2 / Member 3)

2 of the members have a record in my 1st Stored Procedure.
Columns in Stored Proc (ID / Display name / email / FQN)

My loop is pointed to the AD Group - pulling the Name column.

How to I do a match on the decision to say - 
If Member 1 has a record in the Stored Procedure - send email. 
If Member 2 does not have a record in Stored Procedure - do NOT send to user.

Right now Member 2 gets an email and it's blank on all my 'join' fields.   

Badge +7

@AAschenbrener 

 

1. In your loop, pass the member name to store procedure to get data using SMO execution. store that data into vairables. 

2. Add decision box, check your varibales are not blank. If it is blank then do no send email. If it is not blank then send email to user.

3. Go to next item(user). 

 

Please check attached image. 

Badge +10

BB33 -  I'm struggling.

So on the loop -  am I looping the AD SMO List based on my specific AD Group or am I looping the Stored Procedure with the Active Task Email names?

 

Including some screenshots.  Sorry, this is getting so frustrating - been trying to get this for over 1 week.

I had the loop working but then figured out that I shouldn't send if they don't have anything to report.

Badge +10

I figured it out!!! Thank you for the direction!

Reply