For each only outputting last and single record in set
Hi all,
I have created a simple function that sends an email to admin when a member of staff requests some stock items. It's all working perfectly, however, I must be doing something wrong as it's only outputting the latest and one row, whereby sometimes it can be 3 + items.
Foreach Loop:
- for each r in itemsSubform[ParentID == requisitionCollection.ID]
- {
- cat = Stock_Categories[ID == r.Category].itemCategory;
- subcat = Stock_Sub_Categories[ID == r.Sub_Category].Sub_Category1;
- // Output
- items = "[" + cat + "] " + r.Qty + " " + subcat + " (" + r.Status + ")";
- }
I use this to output to the email as shown below:
- sendmail
- [
- from :"admin email address"
- to :"user email address"
- subject :"New Requisition: " + personnelCollection.combined_name + " (" + requisitionCollection.Added_Time + ")"
- message :"<div>New Requisition</div><div><br/><br/><b>Item(s): </b><br/>" + items + "<br/><br/><b>Remarks</b><br/>" + reqRemarks + "</div>"
- ]
Can anyone shed any light on what I am doing wrong? Do I need multiple loops or am I misunderstanding this totally?
Thanks