I have a prodedure SendNewsletterToMembers as follows:
FIND Newsletters WHERE Newsletters.ID=LoggedInSystemUser.ChosenNewsletter
FIND Emailaddresses WHERE Emailaddresses.Newsletter='Yes' IN BATCHES OF 1
FIND Members WHERE Members IN Emailaddresses.Member
SEND NewsletterOutNotificationMember TO Emailaddresses
When I run this procedure from the Query Newsletters directly it runs fine. However I want to run a procedure SendNewsletters that does the following:
SendNewsletterToMembers
SendNewsletterToFriends
So basically calling the the procedure from another one.
When I run the second scenario the following strange thing happens:
- Find Newsletters finds the right Newsletter
- Find Emailaddresses finds 346 instances
- Find Members finds 1 instance for each Emailaddress
- When the first object is processed all goes well.
- When the second object is processed it seems it keeps the old value of Members, i.e. the Member it found in step 3 for the first object.
- The NewsletterOutNotificationMember contains a HTML message that is filled with a template referring to fields from the Members table. For the first object the template fills well, for the second it returns an error message -Failed to fill document template NewsletterMember with data
Again, on running the procedure directly from the Query it sends out all Newsletters as expected, but when I run the procedure as a nested procedure it gives the above errors.
Is this a bug or am I overlooking something?