Iterate multi picklist errors

Iterate multi picklist errors

Hello, 

I'm trying to set up a script wich iterates values in a Lookup field with multiple entries. 

I have 2 forms:

Werkopdracht
wich contains the lookup field medewerkers_select

Medewerkers
wich holds the field Voornaam (text single line) wich is related to  the lookup field in the Werkopdracht form
and has a field wich contains and email field; email_medewerker 

I want to send any individual selected person in medewerkers_select and email when the Werkopdracht form in succesfully submitted. 

I tried using the tutorials and examples on the Zoho help docs, but nothing seems to work. The only thing i have achieved is sending every person in the Lookup field a email. 

It seems to throw an error when i try to add crtiteria to the for each function. 

How can i achieve this? 

heres the code: 

  1. for each medewerkers_select r in WerkOpdracht  [medewerkers_select == input.ID]
  2. {
  3.     temp = input.medewerkers_select.toString();
  4.     rec  =  medewerkers_form  [voornaam_medewerker == temp];
  5.     sendmail
  6.     (
  7.         To       :  rec.email_medewerker 
  8.         From     :  zoho.adminuserid 
  9.         Reply to :  "email adress hidden"
  10.         Subject  :  input.Projectnaam + "  - " + input.projectnummer + " - " + input.Datum + " - Toegewezen" 
  11.         Message  :  "<div>Planning heeft een nieuwe werkopdracht toegewezen.&nbsp;</div><div>Voor meer info, zie PDF</div>" 
  12.         Attachments : template:Werkopdracht as PDF
  13.     )
  14. }
greets.