This example shows you another way to record, save and play a basic script. This example also introduces you to error trapping. The script in this example will add two narrative lines to an invoice.
ALT+F1).Note: The pop-up Narrative Editor (activated by clicking
Open Narrative Editor in the Description field) is not supported by scripting, so cannot be used here.
Note: Any spelling mistakes you fix as you go are not recorded. Field entries are recorded after you move off the field, so don't end recording till you move past the last narrative description.
Alt+F1) to turn off the script recorder.Result: Script Editor opens and displays what it has recorded:
Dim frmINInvoice1 as Object
frmINInvoice1 = GetActiveObject
If IsNull(frmINInvoice1) or frmINInvoice1.ClassName <> "INInvoiceEntryForm" then Error "Wrong form class for script"
frmINInvoice1.Line.Append
frmINInvoice1.Line.LineType = "Narrative"
frmINInvoice1.Line.Description = "These goods remain the property of ABC"
frmINInvoice1.Line.Append
frmINInvoice1.Line.LineType = "Narrative"
frmINInvoice1.Line.Description = "Holdings Limited until payment is received in full"
If IsNull(frmINInvoice1) or frmINInvoice1.ClassName <> "INInvoiceEntryForm" then Error "Wrong form class for script"
Alt+F1)), and load the script.frmINInvoice1.Edit before the first instance of frmINInvoice1.Line.Append. The script will look like this:Dim frmINInvoice1 as Object
frmINInvoice1 = GetActiveObject
If IsNull(frmINInvoice1) or frmINInvoice1.ClassName <> "INInvoiceEntryForm" then Error "Wrong form class for script"
frmINInvoice1.Edit
frmINInvoice1.Line.Append
frmINInvoice1.Line.LineType = "Narrative"
frmINInvoice1.Line.Description = "These goods remain the property of ABC"
frmINInvoice1.Line.Append
frmINInvoice1.Line.LineType = "Narrative"
frmINInvoice1.Line.Description = "Holdings Limited until payment is received in full"