You seem to be attempting a mash up of two different approaches for emailing info:
Send an attached PDF of a layout
Set up a calculation expression inside the Send Mail dialog (used in your script) that extracts data from your database and puts it as plain text in the body of the email.
The method using the List function is used to put plain text in your email, you don't need to do any of that if you are just going to attach a PDF. Your PDF can just be of a layout properly designed to list all of the portal records--this is usually a list view layout based on the portal's table rather than the parent table. And no use of List() or the portal row calc would be needed nor used.
I attempt to do the two of them. The pdf is created properly (and attached to the email without problem. The problem I'm having is in the Send mail.
Some clients complain that they cannot open the pdf so I want to send the attached document + the information (Invoice number + amount + amount due) on the body of the email as a plain text.
If I send one record, I'm not having problem as it shows properly the information. If there are more than two invoices, the plain text shows just the first one (is not listing all)
List will only return the desired list if evaluated from the correct context. The layout that shows your portal, or one based on the same table occurrence needs to be the current layout at the time the Send Mail script step executes or List will return either Null or a single value. A single value is typical if your current layout is based on the portal's table instead of the parent record.
Thanks for your reply:
I guess I'm calling the list from the wrong table.
The invoices (see image) comes from Client Payments (based on the Portal Table - Invoices)
Then I executive the script and gathers the information from - Line Items
This is what I see and what it shows on the email body text
Dear XXX,Please find attached a statement in PDF format of the invoices Arch 5 Des have outstanding.Your outstanding invoices are:Invoice No Total Due Balance Due3770 510 510
You are correct that your "context" is not correct when the send mail script step executes.
You have three options for solving this:
1. Change layouts to the correct layout and record before executing the Send Mail step. You mentioned a portal, go to the layout where you have that portal, go to the record on that layout that is correct for this email. (I described this method in my last post)
2. While on the correct layout mentioned above, use set variable with the List function to copy this list to a global $$Variable. Refer to this global variable in your Send Mail dialog's calculation.
3. If you have FileMaker 13, use a "list of" summary field in place of the list function. This summary field will produce a return separated list of values like List, but for the current found set instead of referring to a related set of records.
I'll try your suggestions tomorrow as it seams pretty simple.