Link to home
Start Free TrialLog in
Avatar of onederwomyn
onederwomyn

asked on

Need Help Using DbLookup where key is multivalue field

Hi all.  I need help doing a DbLookup to get a MailSend to work correctly.  Essentially, I have a field containing 3 plants.  1 plant can be chosen, or all 3 plants can be chosen.  The field to choose these plants is a db lookup first column and they just checkmark the ones that apply.

Well, each plant has a list of people that need to be emailed if that plant is chosen.  This is column 2 of the view.  If just one plant is chosen, it is a no brainer and works fine.  However, if 2 or more plants are chosen, the lookup to grab the names from that second column isn't working.  

Here is my code:
@MailSend(@DbLookup( "" : "" ; "" : "" ; "Directors";signofffrom; 2) where signofffrom is the name of the field containing one to three plants.  I am trying to use it as the key thinking it would look up each individually.  I thought wrong, huh?

So, long story short, how can I look up multiple values using DbLookup?
Avatar of doninja
doninja
Flag of United Kingdom of Great Britain and Northern Ireland image

I would not try to put all the values into the mail send, instead get the values into a variable first.
If using R7+ then you could put the @dblookup within a @for loop that gets each element of the signofffrom field.

Rough example
personlist:="";
@for(n:=1;
n<=@elements(signofffrom);
n:=n+1;
personlist:=personlist+@dblookup("";"";"Directors";@subset(@subset(signofffrom;n);-1);2)
);
@MailSend(personlist);

ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of onederwomyn
onederwomyn

ASKER

I used this as a base with a slight modification
Thanks!!

Could you let us have a peek at that "slight modification", if it was essential to the case?