@mailsends in a loop

Hello beautiful people. Have a rookie question that has me banging my head against the wall. Trying to loop a mail send using formula language and not getting it to work. Here’s the situation:

I have to send reminder emails to supervisors whose employees haven’t filed time sheets for the last pay period; one email to each supervisor with a list of the employees. I already have a handle on StartingDate, which is a text value. Here’s my code:

{This gets me a list of the supervisors who have employees who haven’t filed a time sheet. This works perfectly.}

sups:=@Unique(@DbLookup(“”; “”; “LUPinkSheetStatus”; StartingDate; 2));

{This gets me a list of the employees who haven’t filed a time sheet, but returns ALL employees, not one for each supervisor:}

emps:=@Unique(@DbLookup(“”; “”; “LUPinkSheetStatus2”; StartingDate+sups; 2));

{Finally, this is the code that I was hoping would send an email to each supervisor with a list of just that supervisor’s employees, but doesn’t do a thing:}

Total:=@elements(sups);

@For(Counter:=1;

Counter<=Total;

Counter:=Counter+1;

emailaddr:=sups[i];

@MailSend(emailaddr;“”;“”;“Employees who haven’t filed a time sheet for the period starting on “+StartingDate;””;@Implode(emps;@newline))

I’m thinking the employee list needs to be in a loop, too, but I can’t get far. Any advice would be very much appreciated!

Subject: I probably need to see what your view columns are.

Some pointers:

  • @DbLookup will only look up one key.

  • Though your primary column can be a category, there can be no subcategories. None.

  • Of course, the column has to be sorted. But that’s getting basic. Although, don’t get me wrong, I’ve forgot this myself, too. :smiley:

One other thing – @Mailsend doesn’t always need a default view, but I always set up one on the database. @Mailsend with a doclink, it’ll send out nothing if it can’t find a default view.

Subject: It was addressed in the Notes 6/7 forum

was an error in their formula