Common script steps explained
If you have seen our videos on creating and editing layouts you might be curious about how scrips work. The majority of scripts used in Briefcase layouts have the same steps as the example below.
Go to Layout ["Estimate" (Estimate to Estimate Items)]
Specifies the layout to target when clicking print.
Perform Script ["System | Initialize Layout; Parameter: Get ( ScriptParameter )"]
Finds records and test if any records have been found before continuing.
Sort Records [Restore, No Dialog]
Define sort order for records used in the layout. Without a dialog prompt. The sort order can affect the appearance of your layout and the records which are displayed, read the guide on Editing Layouts to understand how 'Subsummaries' work in the last section titled Working with parts on a layout.
Print Setup [Restore, No Dialog]
Printer selection and page setup (A4 Portrait).
Perform Script ["System | Number Pages"]
Option script step to apply pages numbers, this step requires page number merge fields to be placed on the layout.
Set Variable [$$Subject; Value:Estimates::Kind & ": " & Estimates::Estimate & " - " & Estimates::Description]
Email sending default for the Subject field.
Set Variable [$$Recipients; Value:Estimates to Contacts::Email]
Email sending default for the To field.
Set Variable [$$File; Value:Estimates::Estimate]
Email sending file attachment name.
Exit Script [Result: Modify ( "Sent" ; 0 ; Get ( ScriptParameter ) )]
This step applies the Modify function. The Modify function is executed when the layout window is closed. Upon closing the layout a dialog appears to modify the status of the estimate, in this script step we are applying the default status to modify as "Sent", the second parameter "0" defaults the locking option to false.