for each is not returning unique values
Hi guys, I'm trying to create a script that will produce an email listing all the messages for a client. The messages are held in a form of their own and the criteria for selection is the client's id and zoho.currentdate.
The email is sent and the number of records returned is correct, ie if the client has 4 messages for the day, then there are 4 records in the email. HOWEVER, the script is only picking up the values for the first record and returning it (in the above example) 4 times.
I know I'm doing something wrong somewhere but can't see it...can you help?
The following is the script that is producing the erroneous email data:
------------------------------------------------------------------------
void messages.Send_bulk_emails(string Client_Code)
{
messages1 = "The following messages have been received for you today:<br> <br>";
messages = "";
toaddress = thisapp.get_client.Get_Email_Address_Only(input.Client_Code);
c = Message_Form [(Client_Code == input.Client_Code && Date_field == zoho.currentdate)];
for each x in c
{
messages2 = "Received at " + c.DateTimeStamp + "<br><br>" + c.Caller_Name + " from " + c.Caller_Company + "<br>Mobile Number: " + c.Mobile_number;
messages3 = " Landline: " + c.Landline_Number + "<br>Message: " + " " + c.Call_Details + "<br>Source: " + " " + c.Source + " Suburb: " + " " + c.Suburb + "<br><br>";
messages = messages + messages2 + messages3;
}
Final_message = messages1 + messages + "<br>Thank you for your business. If you have any queries regarding these messages, please contact us on xx during business hours. To change your message options, please email us at xx to advise us of your changes.<br><br>Kind regards,<br><br>The team at xx.<br>";
sendmail
(
To : zoho.adminuserid, toaddress
From : zoho.adminuserid
Subject : "Messages for " + c.Client_Name + " XX to " + zoho.currenttime
Message : Final_message
)
thisapp.accounts.update_outgoings(input.Client_Code, zoho.currenttime);
}
----------------------------------------------------------------------------------------
The following is the text of the email, in this case there were 2 records to be written to the email:
----------------------------------------------------------------------------------------
The following messages have been received for you today:
Received at 10-Sep-2008 12:42:57
anna from ABC Company
Mobile Number: nnnnnnnnnLandline: nnnnnnnnnnn
Message: testing whether the add to outgoings function works
Source: aj Suburb: aj
Received at 10-Sep-2008 12:42:57
anna from ABC Company
Mobile Number: nnnnnnnnnLandline: nnnnnnnnnnn
Message: testing whether the add to outgoings function works
Source: aj Suburb: aj
Thank you for your business. If you have any queries regarding these messages, please contact us on xx during business hours. To change your message options, please email us at xx to advise us of your changes.
Kind regards,
The team at XX.
--------------------------------------------------------------------------------------
I have also shared the application to support. I love Creator, and have been madly working on it in my spare time - if I can get this particular script working it will be a huge boost to our productivity.