Save Records as PDF using Current record returning first record instead of current record
I have an email script that works correctly in windows, but attaches the wrong record to the email on the iPad. Instead of attaching the current record, it attaches the first record in the table when ran on iPad, it attaches the current record as expected when ran in Windows.
Below is the script, hopefully someone can shed some light as to what the problem may be.
Go to Layout ["Walkthrough Report" (Inventory)]
If [PatternCount( Get(ApplicationVersion);"Go_iPad")]
Set Variable [$PATH; Value:Get (DocumentsPath)& "Walkthrough-" & Inventory::agentInitials & "-" & GetAsText ( Inventory::Path Date ) & ".pdf"]
Set Variable [$PATH; Value:"Walkthrough-" & Inventory::agentInitials & "-" & GetAsText ( Inventory::Path Date ) & ".pdf"]
Save Records as PDF [Restore; No Dialog; "$PATH"; Current record]
Send Mail [Send via E-mail Client; Subject:"Walkthrough Report " & Inventory::agentInitials & "-" & Inventory::Location; Message:"Attached is a Walkthrough Report by " & Inventory::agent & " for " & Inventory::Location & " on " & Inventory::Date Entered & ".¶¶"]
**I have the option Create One email using data from the current record selected and the Attach file checked using the $PATH variable. on the above script line**
Go to Layout[original layout]
One other problem in the script, when it returns to the original layout on the last line of the script, it always goes back to the first record in the table. Is there a way to make it stay on the current record?