Apple Script and Importing
This article describes how to use MultiLedger’s built-in AppleScript capabilities for importing information into MultiLedger for Macintosh.
Importing Information into MultiLedger Using AppleScript
AppleScript is a feature of the Mac OS that lets you automate tasks on your computer. All of the available Import functions in MultiLedger, such as importing customers, vendors, invoices, disbursements, etc…, can be called automatically using AppleScript commands. This means you can automate interaction from other AppleScript-aware applications, such as FileMaker Pro or Microsoft Excel.
AppleScript is a scripting language. A scripting language lets you control a computer by writing a series of commands, which make up the script. When you run the script, the computer performs the actions indicated by the commands. As with any programming or scripting language, AppleScript consists of a set of commands, operators, control structures, and syntax rules. Writing successful scripts is a skill that takes time to acquire. Details about the AppleScript language, including a beginner’s tutorial, can be found on Apple’s AppleScript web site, http://www.apple.com/applescript.
MultiLedger’s AppleScript Dictionary is available from any scripting tool, including Apple’s Script Editor. Below is MultiLedger’s scripting dictionary.
- The Required Suite of scriptable commands are Open, Run, and Quit, and are standard with most scriptable applications.
- The Open command opens a specified set of MultiLedger company files. Be sure to type in the complete path name, including the file name with the extension .ML0 (e.g. HardDisk:Folder1:Folder2:FileName.ML0).
- The MultiLedger Suite consists of three commands: Launch, Import, and Exists.
- The Launch command opens the specified application. In the example below, it is the application MultiLedger.
- Import is used from within a script to call any import function within MultiLedger.
- Scripting commands begin with a “tell application” command and end with an “end tell” command. Comments are prefaced with a double hyphen (- -).
Below is an example of an import script written in Apple’s Script Editor that imports a check into MultiLedger. This script checks first to see if the disbursement “Ck 1234” already exists in the MultiLedger company files. If the transaction already exists in the company files, the import command is skipped.
Note: The field order used for the import is the same as the field order in the Import List (on the Import window under the File menu) for the company you are importing into. You should check the Import List in the company files you are importing into to make sure that the field order is correct.
The Import commands use the keywords import, the data, from, and alias.
Exists is used to determine if a customer, vendor, or item name, or, in this case, a transaction document number already exists in the MultiLedger company files.