February 21, 200817 yr I found a nice way to send an email of a text-based record: Set Variable ($email, "mailto:"& YourTable::Username& "<"&YourTable::email_address&">?Subject="&YourTabl e::EmailSubjectField&"&Body="&YourTable::Field_A&" ¶"&YourTable::Field_ Open URL [$email, no dialog] But this only sends the content of one record. Is there any way to send the content of several records, in the body of a single email?
February 21, 200817 yr You'll need to be more specific about which "several records" you want, but yes, you can use GetNthRecord and/or a looping script to assemble the contents of many records into a variable that you can use for the body. Some browsers (e.g. IE) have limits on URL length. Any particular reason you're not using the Send Mail script step instead of Open URL?
February 21, 200817 yr Author Thanks for your quick reply, Tom. I want to avoid using the Send Mail script, because we generally use Google Gmail directly from our web browsers. So here's my situation: I have layout named ClientCalls that contains a portal to a table of our clients' logged phone calls. The Calls table contains the following fields: Calls::ClientName; Calls::CallDate; Calls::CallContent. I want to launch a script (perhaps from a cute little button), from the ClientCalls layout, that will send a single email whose body contains a list of all calls currently showing in the portal, one call per line (each line formatted something like "ClientName/CallDate/CallContent"). Can you guide me as to how I would construct a looping script (or a script with GetNthRecord) to assemble this? Yours, Jim Recht
February 21, 200817 yr We could just loop through the portal rows, like this: Loop Go to Portal Row (Next, exit after last) End Loop It's faster though to do it with the GetNthRecord function, but this means we won't have an "exit after last option." But that's OK, we can just figure out how many rows are in the portal and construct our exit strategy around that: Set Variable($newline ; "%0D%0A" ) // URL can't have carriage returns, so use this Set Variable($rows ; Count(Calls::CallDate) // be sure to use a field that always has data Set Variable($i ; 1) // this is our counter Loop Set Variable($name ; GetNthRecord(Calls::ClientName ; $i) Set Variable($date ; GetAsDate(GetNthRecord(Calls::CallDate ; $i)) Set Variable($content ; GetNthRecord(Calls::CallContent ; $i) Set Variable($body; $body & $name & "/" & $date & "/" & $content & $newline) Set Variable($i ; $i+1) Exit Loop If($i > $rows) End Loop In your URL you can now use $body instead of YourTable::Field_A.
February 21, 200817 yr Author Thanks again Tom. Two more quick questions: 1) Would I write the script like this: Set Variable($newline ; "%0D%0A" ) // URL can't have carriage returns, so use this Set Variable($rows ; Count(Calls::CallDate) // be sure to use a field that always has data Set Variable($i ; 1) // this is our counter Loop Set Variable($name ; GetNthRecord(Calls::Clien tName ; $i) Set Variable($date ; GetAsDate(GetNthRecord(Ca lls::CallDate ; $i)) Set Variable($content ; GetNthRecord(Calls::CallC ontent ; $i) Set Variable($body; $body & $name & "/" & $date & "/" & $content & $newline) Set Variable($i ; $i+1) Exit Loop If($i > $rows) End Loop Set variable ($email, "mailto:"& YourTable::Username& "<"&YourTable::email_address&">?Subject="&YourTabl e::EmailSubjectField&"&Body="&$Body Open URL ($email, no dialog) ?? 2) Is it legal to define a variable like $i (1) and then re-define it ($i + 1), in the same script? Yours, Jim Recht
February 22, 200817 yr 1) Looks right. 2) Yes, notice how we did the same thing with $body, defining it as ($body & etc.) It's really helpful to use FileMaker Advanced so you can use the Data Viewer to watch the values of variables and fields while stepping through a script.
Create an account or sign in to comment