Using MoneyWorks Datacentre over the internet

This article describes how to set up a MoneyWorks Datacentre server to make it available to clients connecting over the internet.

Requirements

Most office networks are connected to the internet via a VDSL or fibre router.

You will need:

  1. Administrative access to your office router's settings to configure port-forwarding. If you do not have administrative access, you will need to talk to your internet provider about configuring the router for you
  2. A static IPv4 address for your internet connection (talk to your ISP about this), or if that is not available, you will need a globally-routable dynamic IPv4 with Dynamic DNS set up on your router (Note that some ISPs are now providing connections with Carrier-Grade Network Address Translation (CGNAT) — these cannot be used on the server end — if you have a CGNAT IP, you will need to ask your ISP for a real IPv4 address, even if dynamic)
  3. You will need to know the local LAN IP address of the computer that MoneyWorks Datacentre is running on

Setup

You will need to configure your office internet router to forward the following ports to the LAN IP address of the server running MoneyWorks Datacentre:

Port       Purpose
6699       The MoneyWorks Datacentre service port
6700       The MoneyWorks Datacentre software update http service
6674..6698 Data Ports. One port for each data file that is active
6710       REST API port

Forwarding the port range 6674-6710 to the server computer is generally the easiest setup.

This is done by logging into the administration UI of the router and configuring port forwarding (it may be termed "NAT Settings" (Network Address Translation), or "Permit Access", or similar). Every router brand is different so you will need someone familiar with your particular router to do this. It is possible that your internet provider can push the necessary settings to your router remotely.

Security

Make sure that password protection is turned on for any accounts document in the server!

It is recommended that the server be configured to use SSL/TLS encryption.

Connecting

To connect to the office server from outside the office, use the Manual Using IP Address connection method in the connection dialog.

  1. Type the IP address or domain name for the external static IP address of the office internet connection
  2. Enter 6699 for the Port
  3. If the Datacentre is configured to use SSL, then trn on the SSL checkbox
  4. If the server is configured to use folder logins (ASP mode) then type the folder name and password (or "root" and the root folder password). Otherwise leave the user name and password blank
  5. Click Log In
  6. You should see a list of the accounts documents being shared by the server. Select the document and type your user name and password for that document and click Log In

Inside the office network you can continue to connect the same way as before (using the internal LAN IP of the server or the Local Network Browser). Some routers may work with the external Internet IP as well (e.g. Fritz!Box which provides hairpin NAT by default), but most won't.

Performance

If you wish to run custom reports, be sure to turn on the Run on Server option in the Report Prefs of the report (on the client). This option is set for all standard reports supplied with MoneyWorks (as of v7), but will likely not be turned on for custom reports that were written prior to v7.1.4.

MoneyWorks Now™

Alternatively, we can host your accounts on one of our MoneyWorks Now cloud servers.

Posted in Networking, Servers | Comments Off on Using MoneyWorks Datacentre over the internet

MoneyWorks 7

Key new features
These are the headline new features for MoneyWorks 7. This version concentrates more on the internals and technical and usability improvements, rather than features per-se.

  • Faster—Optimisations in the core database have yielded speed improvements which in some cases have been on the order of 10x, but are generally more modest. Optimisations in the network protocol and caching have made many network operations significantly faster, particularly list display; Posting is now done on the server; most formerly hard-coded reports have been reimplemented as custom reports, which as well as allowing user-customisation, can now be run on the Datacentre server. In general, it is now possible to access Datacentre server over a high latency (order of 30-60ms) network connection without painful slowdowns, and even moderately slow LAN access (multi-ms latency) is noticeably faster.
    Datacentre database servers now run in 64-bit mode on Windows as well as Mac, improving memory availability and therefore  performance for very large files.

    With v7, MoneyWorks Datacentre now works well over a (reliable) internet connection (and will continue to improve)

  • Easy full-text search—While Moneyworks has always had quite powerful searching, it was not sufficiently useful to naïve users who did not know which field they wanted to search on. These days people are used to near-instant results from a browser search bar. So that is what we now provide. The new search field in the toolbar does a fast asynchronous full-text search (including sticky notes and transaction details). Additionally, Advanced Find is now optimised and progressively executed on the server.

    Finding information is faster and easier than ever.

  • Unicode—Up until now, accented characters have not translated between Mac and Windows, and there has been no proper support of non-Roman characters. In v7, all text is encoded as Unicode (specifically in the UTF-8 encoding), so the full gamut of non-Roman characters can now be entered into the database and are preserved across platforms. Accented characters (including macrons for Māori), special symbols, Chinese, Japanese, Runes, Emojis, etc..

    您可以输入中文字符. પણ અને ગુજરાતી

  • Scripting—MoneyWorks Gold 7 includes a built-in script editor and compiler for an easy to learn and use scripting language which allows for extensive customisation of application behaviour.

    When end-users ask for new features, the answer will now more often be "yes, you can have that".

  • Stock Counting—Super simple "stock" mode, fot those who want a stock count but don't want the complexity of inventory accounting.

What you need to know

  • Conversion—In Gold, Express or Cashbook, opening a v6 or earlier file will convert a new copy of the file. For a large file, you may see transmogrification progress as the text in the file is transcoded to Unicode.
    On Datacentre, use the Convert Files to v7 button in the Folders tab of the console to convert all files. Copies of the files will be converted and transcoded, and the original file's file extension will be changed to .archive. You can delete these archived files after conversion if you wish. IMPORTANT: Conversion to v7 should be done on the same platform the file has always been used with. This is because any non-ASCII text (e.g. accented characters) will be assumed to be encoded using the native codepage of the platform that you are doing the conversion on. Note that "same platform" refers to the client platform where text is actually displayed. If the server is Windows and all clients are Mac, the file conversions should be done on a Mac. Some non-database text such as custom column headings may be transcoded on the fly only when it is actually loaded and used. Reports and forms will be transcoded the first time they are used. Some standard forms may have special characters that are MacRoman-encoded. These will be correctly transcoded even on Windows (Windows version knows about MacRoman special characters such as « and » that may be used in forms).
  • Posting—When networked, posting now happens on the server so it is much faster. There is no longer a posting options dialog box—the job credit option has been moved to preferences. Posting will no longer stop if inventory would go negative and ask for a course of action—inventory will just go negative. This alert used to lock the entire database for all users while it was up.
  • Customisable Reports and report signing—With the exception of the GST report, all reports have been reimplemented as custom reports, so you can modify them if you want. The factory-standard reports have been signed by Cognito to allow them to be run by anyone with appropriate privileges (usually Account Enquiry). If you change a standard report, then it will need to be signed for use by users who don't have the signing privilege (and they will still need whatever privs the report requires, unless you remove those (they are in the custom controls list)).
  • Building products—parts need no longer be in stock (they will just go into negative stock).
  • Running reports on server—Most reports are set to run on the server if required. This will happen automatically if the network latency is beyond a threshold considered to be "slow". If a report will be run on the server, you will see a ↔ symbol next to the Output to... control. If you hold down the Shift key when you click the Preview (or Print or whatever) button, then the run-on-server setting will be reversed (if it wasn't going to run on the server, then it will, and vice versa). Server-side reporting no longer requires a spare concurrent connection.
  • Details printing—The list printing dialogs no longer have a bunch of format options. Instead all of the relevant options are available as separate reports in the list sidebar. In the case of Details printing, there is also a specific toolbar icon, since that is an often-used report.
  • Asterisks in window titles—These indicate that the window is being affected in some way by a script (you will notice that this is often the case with standard report settings, which often have special custom control behaviour in the settings dialog. If you notice that some other window is behaving oddly and has an asterisk in the title bar, then the odd behaviour may be due to a script—check the scripts window.
  • Uploading plugins to server—Upload All now REPLACES the plugins folder on the server (it used to merge the folders). If you do not want to replace the folder, use Upload One to upload individual files. There is also a Remove Custom Plugins button on the index to reports (change the folder popup to see it). This trashes the custom plugins on the client so that a fresh set will be downloaded on next login.
  • Report writer font settings—If you change the font for a selection of parts, all of the cells on those parts will now change as well.
  • Manual—is now downloaded on-demand, rather than being part of the install.
  • On-line help—is now served from the web, rather than installed locally. The move to online documentation allows update installs to be full installs without a huge increase in the download size.
  • Using v7 and v6 side-by-side—The Gold v7 serial number will not overwrite your v6 serial number, nor will the v7 standard plugins overwrite the v6 standard plugins, so it is entirely possible to run v6 and v7 side-by-side. Just be sure to make a copy of the v6 app/exe before updating (name the copy MoneyWorks Gold 6.1.3). Note that custom reports and forms opened/used by v7 will not be usable by v6, so also be sure to keep a copy of custom plugins with your old v6 files. This issue will only apply to accountants and consultants who deal with clients' older version files.

Outside of these, and the headline features, there are many small tweaks and fixes.

Posted in News | Comments Off on MoneyWorks 7

Attachable Scripts

As of MoneyWorks Gold 7, attached platform-specific helper scripts are deprecated in favour of document-based MWScript scripts.

You can write a script which MoneyWorks will send messages to every time something happens with the user interface (open window, validate window, validate field, exit field etc). This script should be named "Helper.scpt" and goes into the Scripts folder of MoneyWorks Custom or Standard plug-ins.

On Mac, the Helper.scpt script must be written in Applescript (and the .scpt extension implies that it is compiled);

On Windows, the Helper.scpt file should actually be a one-line text file containing nothing but the name of a COM object that is registered in the registry. The COM object can be implemented in VBScript or similar using a .WSC file or you can go the whole hog and implement it as a DLL with an IDispatch interface. If this is gobbledegook, don't worry—wait for the code samples, which you can just modify to do what you want.

The following messages will be sent to the Helper script:

Script messages

Load - when script is loaded

Unload - when script is unloaded

Document messages

OpenedDocument - when the document opens

AllowCloseDocument - when the document is about to close. You can prevent it from closing by returning false.

ClosedDocument - after the document has closed

AllowSaveDocument - just before saving the document. You must return true to allow the document to be closed. You must return true to allow saving to go ahead. You can prevent it from saving by returning false.

SavedDocument - after the document has been saved

UserLoggedIn - after a user has logged in (you won't get this if the document is not password protected)

UserLoggingOut - just before a user logs out.

Window messages

WantMessages - when window opens

Before - when window opens or loads a new record

Validate - when window is about to be accepted

Cancel - when window is cancelled

After - when window is accepted

ValidateField - when field is about to be exited

ValidateCell - when detail line field is about to be exited

ExitedField - when field has been exited

ExitedCell - when detail field has been exited

And by "messages", I mean that your script implements functions with these exact names and MoneyWorks calls them.

For more details and examples of use, see the sample scripts.

New user interface scripting

Of course, having your script be notified of events like exiting a field is only useful if you can get and set field values. To this end MoneyWorks 4.1.1 and later has enhanced scripting access to the user interface. You can get and set field values in dialog boxes, and add and delete detail lines.

Applescript Object Model (Mac)

MoneyWorks 4.1.1 added the following classes and verbs to the Applescript dictionary. In keeping with standard Applescript terminology, the detail line entry list in a transaction window is referred to as a "table", containing "rows". Each row in turn contains "cells". You can make new rows and delete rows. You can get and set contents of cells and fields. The front window (the one you will usually be concerned with is always window 1 although you can also refer to windows by name. Likewise the detail line entry table is always table 1, but you can refer to it by it's name which is the same as the selected tab (i.e. "Service" or "Product" etc).

See the Applescript Dictionary in Script Editor for details.

Component Object Model (Windows)

On Windows, the following functions are available in the COM IDispatch interface. The dialogHandle and listHandle parameters get passed to your attached script by MoneyWorks. Since this is the only way to get a dialogHandle, you can only use these functions from within an attached script, not from a standalone script.

BSTR GetField([in] LONG dialogHandle, [in] LONG fieldNumber)

Get a field value from a dialog box. The dialog box handle is passed to you as a parameter to your script function.

void SetField([in] LONG dialogHandle, [in] LONG fieldNumber, [in] BSTR value)

Set a field value in a dialog box

BSTR GetListField([in] LONG listHandle, [in] LONG lineNumber, [in] LONG columnNumber)

Get a detail field value in a dialog box. lineNumber and columnNumber start at 1

void SetListField([in] LONG listHandle, [in] LONG lineNumber, [in] LONG columnNumber, [in] BSTR value)

Set a detail field value in a dialog box.

void AddListLine([in] LONG listHandle);

Add a line to a list

void DeleteListLine([in] LONG listHandle, [in] LONG line);

Delete a line from a list

LONG GetListHandle([in] LONG dialogHandle, BSTR listName);

Get a reference to a list in a dialog box. The list name should match the selected tab in the dialog box. e.g. "Service", "Product" etc.

LONG GetDialogHandle([in] LONG listhandle);

Get a reference to dialog box that a list belongs to

LONG GetListLineCount([in] LONG listHandle);

Get number of lines in list. listHandle is either passed to your attached script by MoneyWorks or you can convert a dialog handle to a list handle using GetListHandle

LONG GetFieldNumber([in] LONG dialogHandle, BSTR fieldName);

Get the index of a field whose symbolic name you know. Thus to get the contents of the transaction description field you would use:
mw.GetField(dialog, mw.GetFieldNumber(dialog, "e_desc"))

ImportantField numbers may change between MoneyWorks versions. You must get the field number at runtime using the symbolic name.

BSTR GetFieldName([in] LONG dialogHandle, LONG fieldNumber);

Get the symbolic name of a field

LONG GetFieldCount([in] LONG dialogHandle);

Get number of fields in a window. Use this if you need to iterate over fields (maybe to get all their names)

Code Samples

Mac

/download/scripting/Mac.zip

The Mac code sample is named Helper.scpt. Chuck it in the Scripts folder. This contains declarations for all messages you will get. The sample just has a "say" statement that will tell you each message as it is called. You can comment out or delete the messages you don't care about.

Windows

/download/scripting/Win.zip

The Windows code sample consists of Helper.scpt (which contains nothing but the text "MoneyWorks.Helper"), plus the actual script which is named Helper.wsc. You need to place these in the Scripts folder, and, having done so, you need to register the Helper.wsc script. Do this by right-clicking on it and choosing Register from the contextual menu. It will not work until you do this. The reason that there is an indirection file (Helper.scpt) is so that you can have different Helper.scpt files in different Custom Plug-Ins folders that point to different registered .wsc files. Without this indirection you could not have different scripts for different documents.

You can double-click Helper.wsc to edit it in Notepad. The file is XML containing declarations of the script functions that it implements. Don't touch this stuff. The only thing that you might change here is the progid, which you will note matches the contents of Helper.scpt. To have different scripts on the same machine you need different progids. If you do this, each unique progid also needs a unique classid. You can use the Windows Script Component Wizard to create a new .wsc from scratch but probably easier to edit the sample one. You'll need the guidgen.exe tool to make a new classid, although it is probably safe to just change the last digit of the one that is in there.

Other than that, the only bit you care about is inside the <![CDATA[ ... ]]> section. This is text containing Vbscript code that actually implements the script. In most of these I have just put some script code that uses the built-in Wshell object to log to the system log. As usual, to call back into MoneyWorks you need to CreateObject("MoneyWorks.Application").

You can look at the results of the logging in Start -> Control Panels-> Administrative tools -> Event Viewer -> Application Log (in which you have to hit F5 to see new log entries)

Q&A

Q. How do I know what kind of transaction it is?

A.  Look at the window name.

Q. I know that in AppleScript I can get the window name using get the name of the front window. How do I do it on Windows?

A.  Use the pseudo field number: -1.
GetField(dialogHandle, -1).

Posted in AppleScript, COM/VBS | Comments Off on Attachable Scripts

Applescript Suite

Use Applescript commands to interface MoneyWorks to other programs running on the same Mac.

Note: As of v7, the recommended technology for implementing automation within MoneyWorks is MWScript.

Unless otherwise noted, AppleEvents are only accepted if there is no modal dialog box open on the screen. As a general rule, if the quit command is currently available, these appleevents can be processed. If MoneyWorks is busy, you will get error number 500.

Required Suite

open: Open the specified object(s)

Usage:

open item -- list of objects to open (file, alias)

Example:

tell application "MoneyWorks Gold" to open file "Hard Disk:Applications:MoneyWorks Gold Folder:XYZ Accounts"

This will open the specified document, closing any currently open document. This command can also be used to open report files (but this is not very useful)

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 

print: Print the specified object(s)

Usage:

print item -- list of objects to print

Example:

tell application "MoneyWorks Gold" to print file "Hard Disk:Applications:MoneyWorks Gold Folder:MoneyWorks Standard Plug-Ins:Reports:Balance Sheet"

This will print the specified report (bringing up the settings dialog). An accounts document must already be open to provide a context for the report.

This is not the recommended way of generating reports—use do report

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 
506 no document is open 

quit: Quit application

Usage:

quit

Example:

tell application "MoneyWorks Gold" to quit

Asks MoneyWorks to quit.

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 
505 MoneyWorks refused the quit event (user may have aborted) 

MoneyWorks Suite

import: Imports data from a text file using a specified import map.

Usage:

import data using map map

data can be the actual textual data to import, or a reference to a text file.

map can be the name of an import map residing in the Import Maps subfolder of the Custom or Standard Plugins folder; or a reference to an import map file anywhere else; or it can be text containing an xml argument block, described below.

Example:

tell application "MoneyWorks Gold" to import file "Hard Disk:Documents:SomeData.txt" using map "Named Map"

You must already have set up and saved an import map to suit the data being imported. MoneyWorks determines where the records are to go from the import map (i.e. if its a Name import map, they will be names). If any errors are encountered with the data, the entire import is aborted, and your script will get an error number 503.

MoneyWorks Gold 4.0.6 and later:

The map parameter may be xml text containg a single "args" tag with the following attributes:

<?xml version="1.0"?>

<args file="transaction"

   map="updatemap"

   update="true"

   post="true"

   seqnum="999"/>

Yes, the <?xml version="1.0"?> is required.

file must be present. Useful values are "transaction", "account", "user", or "build". You can import into other files this way but there is no point—just use the regular syntax. If it's "account", the import data should be in the same format you get when you Copy accounts from the accounts list.

map must specify the name of an import map in the Plug-Ins if the file is "transaction".

update is optional for transactions. If true the import data must specify a single invoice to replace an existing transaction whose sequence number is specified using the seqnum attribute. If the invoice identified by seqnum is not posted, then it gets deleted upon successful import of the new transaction (new one effectively replaces it). If the invoice is posted (and providing any payments are not processed for GST), it is cancelled. If there were any payments on it, they become overpayments which may then be (manually) allocated to the new (or any other) invoice.

post is optional for transactions. Transactions are posted on successful completion of the import

Note that from Applescript, the quotes in the xml will need to be escaped with a \

If the file is "build", You are importing build recipe data for manufactured products. The import data must contain the fields: ProductCode, Qty, PartCode in that order, tab-delimited.

If the file is "user", you are importing any persistent data that you may need to store—usually in support of your external system—the import data must contain the fields: Key, Data, in that order, tab-delimited (key is up to 9 chars (must not start with '#')). Data can be up to 255 chars.

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 
501 the named import map could not be found 
502 the logical file name is not valid 
503 errors in import: non-specific 
506 no document is open 
509 Update Failed Due To Lock 
510 Privilege Violation 
511 errors in import: specific 

export: export data from specified file

Usage:

export filenamestring -- the name of the file to export from (e.g. "Job")

[using search string] -- a search expression (e.g. "Gross > 500")

[into file -- a reference to a text file to export into

Possible values for filenamestring are: "Account", "Ledger", "General", "Department", "Transaction", "Detail", "Log", "TaxRate", "Message", "Name", "Payments", "Product", "Job", "Build", "JobSheet", "BankRecs", "AutoSplit", "Memo", "User".

Example:

tell application "MoneyWorks Gold" to export "Transaction"using search "TransDate &gt; \"31/5/96\"" 

This returns the matching transaction records as tab-delimited text. You get every field from the record, including some gobbledgook ones that wont mean much to you.

tell application "MoneyWorks Gold" to export "Job" into alias "Hard Disk:Some Jobs"

This exports all job records (since there is no search specification) to a file called “Some Jobs” on the hard disk. (We use alias instead of file, since the file does not yet exist)

Special Searches

Using "=" as the search expression will export a single "record" containing just the field names for the file

Using "*" as the search expression will give you the highlighted records in the main list window belonging to the file you have asked for, or all records if there is no highlighted selection

Using "**" as the search expression will give you the highlighted records in the main list window belonging to the file you have asked for or none if there is no highlighted selection

The 4.1.4 export syntax allows the 'filename' parameter to contain formatting information that specifies what is to be exported:

export "Filename[.sortfield[-]][#formatstring]"

sortField can be included to sort the export by that field

sortField can have a "-" appended to specify descending sort

formatstring can specify what to export. Everything in the format string is returned verbatim except for anything inside [...] which is treated as an expression which can reference the fields of the file being exported. Thus if you want tab-delimited, then put tabs between the expressions. You can use metacharacters \t \r \n \xHH (hex) or \\. Note that since Applescript expands the same metacharacters, you are best to use meta-metacharacters in applescripts, e.g. \\t \\r \\x0a etc

As of v6.1.1, If the format string is exactly the text "xml", then the records will be exported as xml.

examples (Applescript)

export "Name"

same as usual

export "Name.Code-"

export in usual format but sorted descending by code

export "Name.Code-#[Code],[Phone]\\r"

export code and phone number separated by a comma with lines delimited by a Return character

export
"Name.Code-#\"[Code]\",\"[Phone]\"\\r\\n"

as above, but fields are quoted, and line delimiter is MSDOS-style

export
"Ledger.concat#\"[AccountCode + if(Department != ``, `-` +
Department, ``)]\",\"[Lookup(AccountCode, `Account.Description`)+
if(Department != ``, ` (` + Lookup(Department, `Department.Description`) + `)`,
``)]\",\"Y\",\"[Lookup(AccountCode,
`Account.TaxCode`)]\"\\r"

exports account codes in banklink format

Added ?path option for importing and exporting on Windows: If file path stars with ?, use it as default but put up a dialog box (the given filename extension in the path will be respected)

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 
502 The logical file name (i.e. "Job" in the above example) is not valid 
504 Bad search expression. MW could not do the search (try it out in the
    advanced Find dialog box [option-Find] to make sure it works) 
506 No document is open 

do report: run a named MoneyWorks report(s)

Usage:

do report reportname -- the name of the report

[from period string] -- a date (as text, e.g. "31/3/96") within the

tarting period to run the report for

[to period string] -- a date (as text, e.g. "31/3/96") within the ending period to run the report for

[outputting to printer/preview/text file] -- where to send the report (if no destination specified, text is returned as command result)

[spooling to file] -- the text file to export into (if output option is text file)

[job dialogs boolean] -- if false, no dialogs are shown (this is the default)

Examples:

do report "Profit Report" from period "1/4/96" to period "1/4/96"¬

   
outputting to text file spooling to file "Hard Disk:EIS folder:Profit rep.text"¬

   without job dialogs

This runs the reports for the (entire) period in which the date 1/4/96 falls. The result is exported to the text file and the settings dialogs are bypassed (the user does not need to do anything). Any settings you want (except the period range) must already have been set up in the report. If you need to do the same report with different settings, save copies of the report with those settings already set.

do report "Profit Report" without job dialogs

Runs the report for the current period, and returns the tab-delimited text of the report to AppleScript.

Note: If the output is not specified, the job dialogs must be suppressed.

do report "Profit Report" outputting to preview

Brings up the settings dialog for the report, with the output set to preview. The user can change the output option, settings etc, and can even cancel it if they want.

Important Note: The “job dialogs false" (or “without job dialogs) option currently only works for ordinary custom reports (not Analysis, hardwired, alias, or chain reports). Notice also that there is currently no way to supply settings to other types of reports (only a date range).

Possible errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up)
506 No document is open
507 Report name not recognised
508 User cancelled report (this can happen even if you suppress the dialogs) 

evaluate: Evaluate an expression using the built-in expression parser

Usage:

evaluate expressionText

Example:

evaluate "Today()"

returns today's date (as text)

evaluate "1 + 1"

returns "2"

evaluate "Lookup(`1000`, `Account.Descripton`)"

Returns the name of account 1000. Note that quotes in the expression have been done using backquotes ` instead of ". MoneyWorks treats ` as " for this purpose. In Applescript you can also pass an actual " by escaping it thus \".

Possible errors:

Any parser error—error message will be returned in Apple Event error message

Full list of possible AE errors:

500 MoneyWorks can not service AE requests at this time (modal dialog up) 
501 the named import map could not be found 
502 the logical file name is not valid 
503 errors in import: non-specific 
504 could not understand expr 
505 MoneyWorks refused a quit event 
506 no document is open 
507 report name not present 
508 the user cancelled report generation 
509 Update Failed Due To Lock 
510 Privilege Violation 
511 errors in import: specific 
	
Posted in AppleScript | Comments Off on Applescript Suite

Using FileMaker with MoneyWorks

OVERVIEW

simple FMP transaction

FileMaker Pro provides an easy, cross-platform way to extend the functionality of MoneyWorks, either with a FileMaker front-end to help automate internal office procedures (specialised order entry, manufacturing, etc), or, using FileMaker Go, as a mobile front-end to MoneyWorks Datacentre.

From a FileMaker front-end, you can submit transactions (e.g. orders, quotes, invoices) into MoneyWorks, run reports, update/create new customer/items/jobs and so forth. Depending how you script your FileMaker solution, this interaction can be transparent to the end-user, even if they are in a different location or using a different platform.

DESCRIPTION

There are two ways that FileMaker can communicate with MoneyWorks.

  • Client to Client: Where the user has both MoneyWorks and FileMaker Pro running on their local machine, FileMaker is able to extract and submit information to directly to MoneyWorks in a manner that is transparent to the user. This relies on a FileMaker plug-in that we provide which works with MoneyWorks Cashbook, Express, Gold and Datacentre clients.
  • FileMaker Client to MoneyWorks Datacentre server: If the FileMaker instance is on a different machine to MoneyWorks, such as an iPad or iPhone, it can communicate directly to MoneyWorks Datacentre server using the MoneyWorks REST APIs.

The FileMaker Plug-in

Note: A 64 bit version (required for FileMaker Pro and later) of this plug-in is now available through the MoneyWorks Add-On Store

The MoneyWorks-FileMaker Plug-in (300k) allows seamless integration between FileMaker Pro and MoneyWorks at the desktop level (i.e. both FileMaker and MoneyWorks must be running on the same computer). From your customised FileMaker Pro front end you can extract information directly from MoneyWorks, and also send information (invoices, orders, time sheets etc) directly to MoneyWorks. There are two plug-ins (one for Windows and a Universal Binary one for Mac). Both these plug-ins provide the same command set, so a single FileMaker database can talk to MoneyWorks using the same commands, regardless of platform. The plug-ins work with FileMaker Pro 7 and later, and MoneyWorks 5 and later. An older (unsupported) plug-in is available for FileMaker Pro 5.5 and 6.

  • Mac Installation: Place the plug-in "Moneyworks Plugin.fmplugin" into the Extensions folder (in your FileMaker Pro x folder, in your Applications folder).
    Note: FileMaker Pro 14 must be set to run in 32-bit mode for it to recognise the plug-in.
  • Windows Installation: Place the plug-in "MoneyWorksFMPlugin.fmx" into the Extensions directory in your FileMaker x directory in your Program Files directory.
  • The MoneyWorks Connectivity Tutorial, which is included with the download, is designed to let your explore the plug-in with built in examples. You can also experiment with your own commands. The tutorial requires FMP 8 or later (it runs fine on FMP 12, but will need to be converted), and runs fine with the MoneyWorks Gold trial (the sample "Acme Widgets" file provided with the trial version of MoneyWorks will never expire, so, if you don't have a MoneyWorks license, you can use it for all testing and development).

Using FileMaker with the MoneyWorks REST APIs

The MoneyWorks REST APIs allow data to be displayed and submitted to MoneyWorks Datacentre using a standard URL. This makes it easy in FileMaker to display live data from MoneyWorks in the webviewer, or to extract data using the Insert from URL command. Note that FileMaker Pro Server is not required for this implementation.

A FileMakerGo example app (requires FileMakerGo/Pro 16) is available for free download from the MoneyWorks Add-on Store. The app uses the MoneyWorks REST APIs so that it can:

  • Run any (authorised) report.
  • Do customer management
    • Display customer dashboard showing balances and historic purchases.
    • Retrieve any invoice for a customer.
    • Update customer details.
  • Enter new quote, sales order or sales invoice, with option to require customer signature.
  • Record time and materials used on a job.
  • Do stock count with option to use iPad/iPhone as scanner
  • Record expense claim, with photo of docket/receipt.

The app works with MoneyWorks Datacentre 8.1 or later, or MoneyWorks Now, and data entered on the device can be sent live back to MoneyWorks. It is pre-configured to talk to a sample file in Brisbane, Australia, but you can easily reconfigure it for your own Datacentre or MoneyWorks Now file.

You will be able to dissect the app to see how to use the REST APIs from within FileMaker, and also modify and extend the app (but with the proviso that you must send us any enhancements, which we might put in an updated version of the app).

Posted in FileMaker | Comments Off on Using FileMaker with MoneyWorks

CLI Overview

MoneyWorks may be used from the command line for automating tasks, such as data import, data export, and reporting.

Screen shot 2013-07-27 at 8.48.16 AM

On Mac, use /usr/bin/moneyworks (MoneyWorks Gold must be installed).
On Windows, use moneyworks.exe in the MoneyWorks Datacentre folder in Program Files.

See the moneyworks man page

Note: As of v6.1, the recommended way to access MoneyWorks Datacentre is via the REST interface. The REST interface provides everything the command line interface does, in a platform agnostic way, that will also generally be faster.

Posted in CLI | Comments Off on CLI Overview

Perl wrapper

A third party Perl script is available from here. It uses the Command Line Interface to talk directly to MoneyWorks Datacentre.

Note: As of v6.1, the recommended way to access MoneyWorks Datacentre is via the REST interface. The REST interface provides everything the command line interface does, in a platform agnostic way, that will also generally be faster.

Posted in CLI | Comments Off on Perl wrapper

CLI Manual

moneyworks - MoneyWorks command line modes

Synopsis

moneyworks [options] [file-or-url]

On Mac OS X, the short form (moneyworks) is a symbolic link to the actual executable (/Applications/MoneyWorks\ Datacentre Console.app/Contents/Resources/moneyworks). On Windows, a separate command line client, moneyworks.exe is installed in C:\Program Files\ MoneyWorks Datacentre\.
See notes for caveats on symbolic link usage.

Description

On MmacOS, MoneyWorks Gold can be executed from the command line in either normal GUI mode with an optional file or URL parameter, or as a non-GUI command line tool. In the latter case, it is useful for automated access to local or remote MoneyWorks Gold databases.

On Windows, moneyworks.exe is a command-line-only tool (vs MoneyWorks Gold.exe which is GUI-only due to Windows subsystem limitations).

Interactive Mode

If executed with the -i switch, MoneyWorks will enter interactive mode, reading commands from stdin, and writing results to stdout. Any errors will be written to stderr. Diagnostics may also be written to stderr, and will precede the error message. The quit command will end the interactive session, as will (on OS X) closing stdin by sending an EOT (ctrl-D). Any open network connection or document will be cleanly closed first.

Execute Mode

If executed with the -e command line switch and a supplied command, the command will be executed and the tool will exit after completion, writing any output to stdout. Multiple -e command terms may be passed. They will be executed from left to right. The command in the -e term should be quoted to protect it from shell expansion, especially if it contains spaces. A URL or file may be supplied as the final parameter. MoneyWorks will open the file/url before executing the commands. Errors are reported as for the -i case.

Output Format

-h and -x can be used with -i or -e (if neither of these is specified, -i is implied). These output format modes are intended to make the interactive output more reliably machine-parsable.

The -f option is useful only on managed Citrix desktops, where you can control the launch environment of the app to restrict users to their own subfolder. It should be used in conjunction with Datacentre server login for server-side enforcement of folder views. It is helpful in that it removes the requirement for the user to manually log in to the server.

Options

Long form options are only available in the Mac version.

-i, --interactive

Run in interactive mode, reading commands from stdin, writing output to stdout and errors to stderr, until command is quit. In verbose mode, success notifications may be appear on stdout for some commands that do not otherwise have output (e.g. "Connect Succeeded")

-e cmd, --execute=cmd

Execute the supplied command and exit.

-x, --xml

Output results as xml to stdout (use with -i or -e).

There is always an xml header line; root tag is <commandstream>; each command (including any implicit open) outputs a <command> result tag; there is always a <status> tag with 'OK' or 'Fail'; If status is OK, there will be a <result> tag (may be empty). If status is Fail, there will be an <error> tag and may be a <diagnostic> tag with additional information. Do not rely on the contents of the diagnostic tag. Contents of the result tag are utf-8 and entity-encoded and may be CDATA if it can't be entity-encoded. Stderr may be ignored, although it may contain additional error messages (such as import error logging).

Note: the <commandstream> wrapper is new in version 6, as is the result from the implicit open.

-h, --http

Output results in http-header style to stdout (use with -i or -e).

Each header line consists of the header name (which does not contain spaces), a colon, a space, a value which may contain spaces, and a return+newline. The final header is followed by an additional return+newline (i.e. a blank line). There is always a 'Status' header with value 'OK' or 'Fail'; If Status is Fail there will be an 'Error' header and may be a Diagnostic header (as for xml). If Status is OK and there is output following the headers, there will be a Content-Length header whose value is the number of bytes of content. Stderr may be ignored, although it may contain additional error messages (such as import error logging).

-q, --quiet

Quiet. No initial greeting or success notifications on stdout in -i mode (-x and -h imply -q). Also no chatter on stderr (log to system.log and MoneyWorks_Gold.log only).

-v, --verbose

Verbose mode. Provide more status feedback on stdout in -i mode.

-p, --plugins

Download plugins from server (if they need refreshing) when logging in.

-o, --readonly

Open document read-only.

-r regonum, --rego=regonum

Use registration number. If you are executing as user www or similar and wish to connect to a Gold server or open a local file, MoneyWorks does not have access to a preferences file to obtain a registration number; in this case you would need to supply one on the command line. Usually, you don't need a registration number to connect to a DC server, although you might like to connect using a full Gold serial to avoid any possibility of all concurrent connections being exhausted.

-u user:pass, --user=username:password

When opening a password-protected local file on command line, use the given username and password.

-a, --activate

Come to front on launch (GUI mode)

-n, --no-manual-connect

Don't allow use of manual connections (Windows GUI mode)

-f folder, --fold=folder

Connect only to named subfolder on Datacentre (Windows)

On Windows, the older, Windows-style switches are also supported (although use of this style of switch is deprecated):

/user=user:pass equivalent to -u
/nomanualconnect equivalent to -n
/fold=foldername equivalent to -f

Commands

The commands you can issue are analogous to the Applescript and COM commands.

Commands are given in the form

verb [ param-name "=" DELIM param-value DELIM ]*

The parameter delimiter can be pretty much any character you like except for whitespace or =.

version

Returns the MoneyWorks Gold version

$ moneyworks -e version
6.1

$ moneyworks -xe version
<?xml version="1.0"?>
<commandstream>
        <command name="version">
                <status>OK</status>
                <result>6.1</result>
        </command>
</commandstream>
evaluate expr='expression'

Evaluates the expression and returns the result. You can also abbreviate this to =expression.

$ moneyworks -e "evaluate expr='DateToText(Today(), -7)'"
20111216000000
open file='URL-or-path' [user="user"] [pass="pass"] [docuser="user"] [docpass="pass"]

Open the file at the given path or connect to the url (which should follow the moneyworks:// scheme). The MoneyWorks URL scheme is documented here http://www.cognito.co.nz/support/?developer&art=url

If connecting to a URL of a document that requires login, you may include the login information in the URL, as per the URL scheme. However it is recommended to use the separate user, pass, docuser, and docpass parameters. You can also pass login="user:pass" but this is deprecated since it does not allow user names containing colons (likewise this problem applies to passing credentials in the url).

If logging in to a Gold server, use user and pass only. If logging in to a Datacentre server, use docuser and docpass for the document login and, if required, use user and pass for the Datacentre subfolder and password.

close

Close the current file or connection, if any

quit

Exits interactive mode

import [data='...' | file='path'] map='path' [additional arguments]

Import data. If plugins are available, the map name can be given, otherwise a full path should be given. Likewise if importing from a file, the full path to the file must be given.

There is no metacharacter expansion in the data parameter, so you can't use \t, \n etc.. If you have multiple lines to import, write your data to a temp file and use the file parameter.

Output is a report of number of records created and updated (except for User, Contact and Build files, which will always report zero).

Additional arguments may be:

filename='Account | User | Build | Memo' Import into fixed format file (no import map)

update='true' seqnum='num' [discard='true'] Transactions only. Recall the identified invoice. Optionally discard imported invoice (i.e. just delete or cancel invoice being recalled)

return_seq='true' Output will be sequence number of newly imported record

post='true' Transactions only. Post the imported transactions

The data parameter may contain xml or the file parameter may identify an xml file (in this case, the map parameter should be omitted or be "xml"). The xml should be marked up in the same manner as the xml export format (see below). fields or records with the attribute "system" will be ignored.

post seqnum='sequence number'

Post the transaction identified by sequence number

export table='...' [format='...'] [search='...'] [output='path'] [user_var='value']*

Export data from the given file ("table") in MoneyWorks. If there is no search parameter, you will get all records, otherwise only those matching the search expression.

Using "=" as the search expression will export a single "record" containing just the field names for the file.
The table name may include a sort specifier (e.g. "Name.Code-"). To export with a particular format, use the format parameter. Everything in the format string is returned verbatim except for anything inside [...] which is treated as an expression which can reference the fields of the file being exported. Thus if you want tab-delimited, then put tabs between the expressions. You can use metacharacters \t \r \n \xHH (hex) or \\. e.g. "[Code],[Phone]\n"

If the output parameter is not supplied, the data is sent to stdout, otherwise a file is created using the full path supplied and the data is written there. If you supply an output parameter and no format parameter, you will get the format equivalent to a manual export, otherwise you get all fields. Using a format parameter is strongly recommended, since default export formats are subject to change.

As a special case, an output path of "tmp" will create a temp file for you and return the path of that file.

You can also export xml by specifying "xml" as the format. By default, the xml will be terse (also specifiable by "xml-terse" as format) in that any blank or zero fields will be omitted, as will system detail lines for transactions and system (no-importable) fields. To get all fields, specify "xml-verbose" as the format. In verbose format, system detail line records and non-importable fields will include a "system" attribute in their opening tag.

doreport report='path' format='text|html|pdf' [from='date' to='date'] [output='path'] [user_var='value']* [font='name' size='num' leading='num'] [title='titletext']

Executes the report and writes output to stdout or to the given output file. Since there is no plugins folder in command line mode, the full path to the report must be given. If outputting to stdout, the format is tab-delimited. If a path is given and the filename ends with ".html" then the output will be in HTML. Otherwise you can explicitly specify the format.

All parameters are inserted into the name table and are available to the report. Thus you can pass values for custom controls defined for a report.

If format is pdf, html, or xml, and output not supplied or is the magic name "tmp", then MoneyWorks will generate a temp file for the output and tell you the path. It is up to you to delete this temp file. If the -x option has been specified, then the tag for the temp file path is <output> and there will also be a <mimetype> tag.

doform form='path' [format='pdf'] [search='expr'] [output='path'] [user_var='value']*

Renders the form to a pdf file. For form types other than .rept a search expression must be provided to select the record(s) to use. If multiple records are selected, all output still goes to the same PDF. Output path is optional--if it is not supplied, a file will be created in the temp directory. The return value on stdout is the path to the generated pdf. The only supported format at present is "pdf". For forms that use variables supplied by the form printing dialog (such as Message, Print_Copy etc) you may provide values for those variables by passing them as parameters e.g. Message="Hello" Print_Copy="0" Include_Remit="0" for typical invoice forms; Stmt_Date="1/1/2010" for statements.

diagnose

Runs file-system and integrity diagnostics for the currently-open file

list [folder='reports'|'forms'] [filter='all'|'user'|'standard'] [type='filetype'] [name='filename']

List plugin files in the custom or standard plugins folder. Output is xml.

getimage product='code' | transaction='seqnum'

Downloads a transaction or product image to a temporary file. Output is the file path.

putimage input='path' [product='code'] | [transaction='seqnum']

Uploads a transaction or product image.

putplugins [file='matchingfilename']

Uploads the local custom plugins folder (or a single matching file therein) to the server.

Notes

Error reporting

-x and -h modes return a 'status' tag/header indicating success or failure. In the default mode (without -x or -h) errors are written to stderr. Typically one or more errors tagged with "[ERROR]" followed by a failure notice tagged with "[FAIL]". In -x or -h mode, the final [ERROR] is included in the output to stdout tagged as 'diagnostic', and the failure notice tagged as 'error'.

Performance

Note that connecting to the server is relatively expensive. This will of course be much longer if the server has to open the document from scratch. In command line mode, no plugins are downloaded from the server unless you specify the -p switch.

In most circumstances, a short-lived connection to the server with command(s) passed using the -e option will be the easiest mode of use. This is because the calling code can read all of the output to the end of file. In interactive mode you need to know how many bytes of output to read before sending the next command (hence the -x and -h options). If you need a number of results that require some complex processing, consider writing a custom report and executing that using doreport, thus obtaining all the results at once. For highest performance for many requests, you would need to stay connected in -i mode.

If using the -i option, avoid keeping connections open indefinitely, Datacentre should be allowed to close documents overnight for housekeeping purposes. In fact, if you do attempt to stay connected for more than 5 minutes without doing anything, the Datacentre server will treat you as a stale connection and disconnect you. You would need to be pinging the server with some kind of database request, such as an export, to keep the connection alive.

Examples

(note that these examples are for Mac OS X)

Connect to a DC document and get the output from the given report for the period range.

    moneyworks -e "doreport report='/Users/rowan/My Balance Sheet' \
from='20100201' to='20100331'" \
"moneyworks://zaphod.local.:6699?doc=Acme.mwd6"

Interactive mode (verbose, unformatted output)

    moneyworks -iv
    MoneyWorks Gold 6.0 interactive mode. Type 'quit' or ctrl-D to exit.
    open file="/Users/rowan/Documents/Acme Widgets.mwd5"
    Open succeeded
    =name
    Acme Widgets Ltd
    close
    Close succeeded
    quit

Piping commands in from a file (such as multiple exports)

    moneyworks -i < ~/mycommands > ~/output.txt ~/Acme\ Widgets.mwd5


For the latest version of the CLI manual:

in Mac Terminal.app (with Datacentre installed):

man moneyworks


in Windows Command Prompt (with MoneyWorks Datacentre installed)

moneyworks.exe -?

Posted in CLI | Comments Off on CLI Manual

MoneyWorks Datacentre REST API

Synopsis

The MoneyWorks Datacentre REST API provides a simple, platform-neutral, stateless network interface to MoneyWorks Datacentre.

Description

The MoneyWorks REST API is hosted on a MoneyWorks Datacentre server. The server may be self-hosted on-premises, self-hosted on a cloud VM, or hosted by Cognito as a MoneyWorks Now instance. Therefore there is no single URL for the REST API. On a self-hosted server, if the API is to be accessed from the Internet, the network administrator will need to ensure a static IP and port-forwarding for the REST port on the router.

The MoneyWorks Datacentre REST interface is configurable by the server administrator. If enabled, the REST API runs on port 6710 by default, but may be configured to run on a different port.

The REST API should use TLS (https) provided the server administrator configures it to do so and supplies an appropriate certificate. Unencrypted access (http) should only be used on a trusted private network.

Internally, the server uses MoneyWorks command-line instances to service REST requests (hence the similarity of the REST API to the CLI API). It keeps a pool of logged-in instances which stay alive for 30 seconds or so, so the latency cost (on the server) of making multiple requests over a short space of time is low. Note that sometimes latency for a request may be high if the database needs to be opened to service the request (MoneyWorks databases do not stay open when no users are logged in, so periodic polling via REST with a frequency less than about 10 minutes is strongly discouraged as it can cause unreasonably high server load).

Authentication

MoneyWorks Datacentre REST API uses Basic Password authentication.

MoneyWorks Datacentre servers can be configured with single-level (document password only) or 2-level (folder password + document password) login requirements. In the latter case, the Server: header will include Login_Required.

The MoneyWorks administrator should create a user in MoneyWorks specific to the REST client. To deny access to the REST client in future, simply delete that user or change the password on it.

If folder login is not required (Login_required is not present in the Server: header), then the only authentication required is a document username and the password for that user. This should be provided in an Authorization: header with the method Basic for realm Document i.e: a Base64-encoded concatenation of username:Document:password. E.g. if the username is "Robot" and the password is "s3cret", then the authorization data will be base64-encoded Robot:Document:s3cret

Authorization: Basic Um9ib3Q6RG9jdW1lbnQ6czNjcmV0

If the server is set up to require folder-level login (The "Require Folder Name and Password to Connect (ASP mode)" option in the console; the Server: header string will include Login_Required. This is always the case on a MoneyWorks Now server), then you must additionally supply a folder name and folder password Authorization header for the realm "Datacentre". If the document is at the top level of the server root, then the username should be root. If the document is in a folder named Some Folder with a password soMe-p4as5word, then the additional header will be base64-encoded "Some Folder:Datacentre:soMe-p4as5word":

Authorization: Basic U29tZSBGb2xkZXI6RGF0YWNlbnRyZTpzb01lLXA0YXM1d29yZA==

With Login_Required, you must supply both Authorization headers. They can be separate headers or you may concatenate them into one header separated by a comma and a space:

Authorization: Basic Um9ib3Q6RG9jdW1lbnQ6czNjcmV0
Authorization: Basic U29tZSBGb2xkZXI6RGF0YWNlbnRyZTpzb01lLXA0YXM1d29yZA==

or

Authorization: Basic Um9ib3Q6RG9jdW1lbnQ6czNjcmV0, Basic U29tZSBGb2xkZXI6RGF0YWNlbnRyZTpzb01lLXA0YXM1d29yZA==

The order does not matter.

CURL command line URL and authentication examples

Doc in subfolder with spaces in name, all credentials in explicit headers - RECOMMENDED

curl -H "Authorization: Basic `echo -n 'Folder/sub folder:Datacentre:FPASS' | openssl base64`" -H "Authorization: Basic `echo -n 'Admin:Document:DPASS' | openssl base64`" "https://example.moneyworks.net.nz:6710/REST/Folder%2fsub%20folder%2fDocument.moneyworks/export/table=login&format=xml" 

Doc in ubfolder with spaces in name, folder credentials in explicit header, document credentials in URL- NOT RECOMMENDED

curl -H "Authorization: Basic `echo -n 'Folder/sub folder:Datacentre:FPASS' | openssl base64`" "https://example.moneyworks.net.nz:6710/REST/Admin:DPASS@Folder%2fsub%20folder%2fDocument.moneyworks/export/table=login&format=xml" 

Doc in subfolder with spaces in name, folder credentials parsed by UA, document credentials in URL - NOT RECOMMENDED

curl "https://Folder%2fsub%20folder:FPASS@example.moneyworks.net.nz:6710/REST/Admin:DPASS@Folder%2fsome%20new%20folder%2fDocument.moneyworks/export/table=login&format=xml" 

API

The URIs for the REST API generally take the form

https://server:6710/REST/Document_Path/command?param=value

for requests that operate on a database document, or:

https://server:6710/REST/server/command?param=value

For simple server enquires (version, list).

The document path/name must be URL-encoded. If the document is located in a subfolder on the server, the document path will include path separators url-encoded (%2f) e.g.

https://server:6710/REST/Folder%2fSubfolder%2fThe%20Document.moneyworks/command?param=value

If the document is on a private server and is at the root level, then you just need the name:

https://server:6710/REST/The%20Document.moneyworks/command?param=value

You shoud consider URI components to be case sensitive. Be careful to match the case of the document name and path. Some servers may tolerate case mismatch in some parts of the URI and may tolerate alternative path separators such as backslash. Do not rely on this tolerance.

The REST endpoints are effectively command verbs. Available commands are:

version, list, export, import, evaluate, post, doreport, doform, and image

Simple server information GET requests (version, list) do not require a document name or parameters. The document name can either be empty or server if your UA does not permit double slashes.

In the example server responses below, irrelevant headers are omitted for clarity.

Server information commands

version

Get the server version number.

GET /REST/server/version

Does not require any login credentials. Returns the Datacentre version number as text/plain. e.g.:

HTTP/1.1 200 OK
Server: MoneyWorks_Datacentre/9.0 REST/9.0 Login_Required
Content-Type: text/plain

9.0

The version is also supplied in the Server header of every request.

Iff the server requires per-folder login, then the string Login_Required will appear in the Server header of the response.

list

List the documents (databases) on the server.

GET /REST/server/list HTTP/1.1
Authorization: Basic cm9vdDpEYXRhY2VudGU6UjAwdC1wYXNzd29yZA==

Returns a list of the available documents in the server or a subfolder thereof as text/xml. e.g.:

HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0"?>
<documents>
        <document>Acme.moneyworks</document>
        <document>CognitoAccounts.moneyworks</document>
</documents>

If you authenticate with a subfolder password instead of as root, you will only get the documents within that subfolder

GET /REST/server/list HTTP/1.1
Authorization: Basic U3ViZm9sZGVyOkRhdGFjZW50cmU6cDRzNXcwcmQ=

This command can also be used with a document. See below.

Note: DO NOT use list as an "is the server there" test. It is relatively expensive to service.

Requests that operate on a document

These must include the document name (case-sensitive).

https://server:6710/REST/DocumentName.moneyworks/command?param=value

DocumentName is the name of the MoneyWorks document in the Datacentre that you are accessing.

If the document is in a subfolder (rather than at the root level of the server), the document name must include the path to the document. Non-alphanumeric characters in the URL should be url-encoded by converting to %-prefixed hexadecimal. This includes any / path separators if the document is in a subfolder (/ = %2f).

Credentials in the URL: if you are using a very stupid user agent that cannot supply headers with your requests (Filemaker Go... looking at you) then you may prefix the document name with login credentials in the form user:password@ and the server will parse these out of the URL. This is obviously not good practice. The login credentials will be logged on the server. Such user agents will also usually parse out a user:password@ preceding the domain name of the server in the URL and add an Authorization header for you (with no realm specified). The server will interpret this as a Datacentre realm credential or Document realm credential depending on the whether folder login is required or not.

Platform-specific path separators: You should use %2f as a path separator in the document path. This will work for all servers. You can use \ (unescaped backslash) as a path separator if the server is hosted on Windows, but you should not, because if the operator migrates the server to another platform, your requests will stop working.

Backwards compatibility: if your document name ends with .mwd7 (the MoneyWorks 7 file extension), the server will automatically convert that to .moneyworks.

Requests with parameters

Params sections are a list of named parameters in the form paramName=paramValue, separated by ampersands. ParamValues must be url-encoded. Note that characters such as = in the paramValue that are not normally url-encoded must be, since they are syntactically significant in the parameter list. i.e encode = as %3d

Parameters follow the command in the URL separated by either a ? or a /.

e.g.

GET /REST/DocumentName.moneyworks/export?table=login&format=xml&search=Name%3d%22John%22

export

This is the principle means of extracting information from the database.

GET /REST/DocumentName.moneyworks/export

Parameters for export:

table=tablename —required, (see Appendix A of manual for table names)

search=expr —optional, url-encoded search expression. All records if omitted. You must use the MoneyWorks-specific search syntax to find records. For information on MoneyWorks search expressions see Find by Formula and, for advanced cross-table searching MoneyWorks Relational expressions in the MoneyWorks manual. Don't forget to URL-encode the expression.

format=xml|xml-terse|xml-verbose|format-expr —optional, may be omitted for canonical text export

sort=expr —optional, can be simply a field name or an arbitrary expression

direction=ascending|descending —optional, direction of the sort

start=N —optional, start offset when format is xml

limit=N —optional, limit of number of records returned when format is xml

If the search parameter is omitted, you'll get the entire table. BEWARE: it may be very large. Downloading entire tables without good reason should be avoided. Use the start and limit parameters to page through "windows" on the data.

Result will be text/plain or text/xml as per the requested format.

The XML export format is fully compatible with the XML import format. xml-terse omits blank/zero values and non-importable system fields and detail line items for transactions. The xml-verbose format includes that data, but with a system="true" attribute.

A format expression should be fully url-encoded. It defines the export format with anything inside square brackets considered an expression to be evaluated. Anything outside square brackets will be output verbatim for each record.

e.g. XML output

GET /REST/Acme.moneyworks/export/table=name&search=Category1%3d%22NORTH%22&limit=2&format=xml

produces

HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0"?>
<table name="Name" count="2" start="0" found="6">
        <name>
                <code>AUTUMN</code>
                <name>Autumn Fabrix Ltd</name>
                ...
                <payaccount>2500</payaccount>
                <email>accounts@autumn.co</email>
                <productpricing>A</productpricing>
        </name>
        <name>
                <code>BROWN</code>
                <name>Brown Suppliers</name>
                <contact>Bronwyn</contact>
                <address1>PO Box 12</address1>
                ...
                <email2>fred@brown.co</email2>
                <productpricing>A</productpricing>
                <receiptmethod>2</receiptmethod>
        </name>
</table>

Canonical plain text output (default)

GET /REST/Admin:fred@Acme.moneyworks/export/table=name&search=Category1%3d%22NORTH%22 

produces

HTTP/1.1 200 OK
Content-Type: text/plain

0       2       24/09/11 7:44:58 PM     AUTUMN  Autumn Fabrix Ltd       Allan     ...
1       3       31/01/11 4:58:07 PM     BROWN   Brown Suppliers         Bronwyn   ...
4       6       31/01/11 4:35:56 PM     SMITH   J Smith & Sons Ltd      Simon     ...
7       9       31/01/11 4:58:28 PM     WHITE   White Contractors       Grey      ...
8       10      31/01/11 3:58:09 PM     WINTER  The Winter Bakery       William   ...
21      32      31/01/11 4:21:45 PM     BROWNX  Brown Suppliers         Bronwyn   ...

Formatted output, using format string [Code], [Name]\n

GET /REST/Admin:fred@Acme.moneyworks/export/table=name&format=%5BCode%5D%2C%20%5BName%5D\n

produces

AUTUMN, Autumn Fabrix Ltd
BROWN, Brown Suppliers
BSUPP, Beetle Suppliers Limited
CANON, Canon Photocopiers
CSUPP, Casbah Suppliers Int
GREEN, Green's Garden Depot
LIST, Listener
NEWHER, Newton Herald
NEWPOW, Newton Power and Electric
NEWPROP, Newton Properties

import

Create (or update) records in the database. Method must be POST.

POST /REST/DocumentName.moneyworks/import

Optional Parameters:

return_seq=true —get seqnum of last record updated, else get created: N; updated: M

Data to be imported must be XML. The structure of the XML will generally that provided by the xml-terse export format. Further information on the required structure of the XML can be found at XML Importing in the manual, and information on importing data generally: Exporting & Importing

Supply the XML to be imported as the POST payload.

It is important to note that if using the work-it-out="true" attribute for fields to be imported, that the prerequisite data for calculating the field value must precede the calculated field in the XML.

MoneyWorks will not import invalid records. You should prevalidate your data before attempting to import it, rather than relying on the error messages from the import command to be meaningful to end users who have supplied invalid data (such as an invoice for a non-existent customer, or that does not add up).

The usual response is text/plain in the form

created N; updated M

Where N and M are the number of records created or updated, respectively. If you supply the return_seq=true parameter, then the response is text/plain containing the decimal representation of the last sequence number created or updated (not all tables respond to this option).

If there are errors in the data, the response will begin with the text [ERROR] followed by some information about the error(s). No records will be imported or updated in this case.

Extra import behaviours (such as posting the imported transactions) may be specified by passing the required parameters as attributes to the table element in the xml data. See XML Importing.

evaluate

Evaluate an expression

GET /REST/DocumentName.moneyworks/evaluate/expr=expression

Evaluates the given expression in the context of the document and returns the result. The expression should be fully url-encoded. The result will be text/plain. If you only need one data point from the database, this is more efficient than an export.

e.g.

GET /REST/Acme.moneyworks/evaluate/expr=Today%28%29 
HTTP/1.1 200 OK
Content-Type: text/plain

31/01/11

e.g.

GET /REST/Acme.moneyworks/evaluate/expr=Lookup%28%22SPRING%22%2C%22Name.DBalance%22%29 
HTTP/1.1 200 OK
Content-Type: text/plain

5678.12

post

Post an existing transaction, identified by its sequence number. Note the method must also be POST, since the database is changed by this operation.

POST /REST/DocumentName.moneyworks/post/seqnum=sequencenumber 

Posts the transaction. Sequence number should be decimal, without thousands separators. Result will be text/plain status, either "OK" or "not posted".

doreport

Run a report

GET /REST/DocumentName.moneyworks/doreport

Parameters:

report=name — required, the name of the report, which must exist on the server (either a standard report, or in the Custom Plugins folder for the document)

format=html|text|pdf

from=yyyymmdd|nnnn

to=yyyymmdd|nnnn

font=fontname

size=pts — optional, font size in points

leading=pts — optional, extra spacing between lines (only relevant if output is PDF)

title=heading — the title to appear at the top of each page.

control-id=value — custom control values

The report can reside in custom or standard plugins on the server. All params except report are optional.

Default format is text, delivered as text/plain. You will probably usually want to specify html or pdf. From and To dates can be ISO dates (which effectively denote a period range) or period numbers.

User-defined identifiers will be entered into the name table and can be used to specify custom control values by name (which some custom reports may require). The proper control-ids to use may be obtained using the list command (see below).

Example

GET /REST/doreport/report=Balance%20Sheet&format=html&leading=8&font=Verdana&size=10 
HTTP/1.1 200 OK
Content-Type: text/html

<HTML>
<HEAD>
<META NAME=GENERATOR CONTENT="MoneyWorks">
<style type="text/css">
...
</HEAD>
<BODY style="background-color: #f7f6f2;">
<div>
<div>
... etc

list

When used for a document, the list command provides information about installed and available reports or forms.
Parameters

folder=reports|forms —one of these is required

filter=user|standard|all —default is all

For folder=forms, the type may be specified

type=invc|stmt|prod|job_|remt|rept —default is invc

For folder=reports, a report name may be specified to get details of the report name=reportname

GET /REST/Acme.moneyworks/list/folder=forms 
HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0"?>
<plugins type="invc">
        <form>
                <name>Business Check 104 (US)</name>
        </form>
        <form>
                <name>Business Check 105 (US)</name>
        </form>
        ...

or

GET /REST/Acme.moneyworks/list/folder=reports 
HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0"?>
<plugins type="crep">
        <report>
                <name>Balance Sheet</name>
        </report>
        <report>
                <name>Bank Balances</name>
        </report>
        ...

Querying for parameter details of a specific report. These are returned in html-compatible format. Theid of the input elements should be used as parameter names to the doreport command. Boolean parameters should be passed as 0 or 1. Select parameters should be passed the selected value.

Users for whom the report is signed are indicated in the signatures element. If you are connecting as a user who does not have privileges to run unsigned reports, then your username must appear in the signatures block, or else doreport will fail with a 403 for the report.

GET /REST/Acme.moneyworks/list/folder=reports&name=Bank%20Balances 
HTTP/1.1 200 OK
Content-Type: text/xml

<?xml version="1.0"?>
<plugins type="crep">
        <report>
                <name>Bank Balances</name>
                <signatures>
                        <user>Admin2</user>
                </signatures>
                <controls>
                        <div>
                                <input id="Omit_Zero_Balances" type="checkbox" />
                                <label for="Omit_Zero_Balances">Omit Zero Balances</label>
                        </div>
                        <div>
                                <input id="Include_Unposted" type="checkbox" />
                                <label for="Include_Unposted">Include Unposted</label>
                        </div>
                        <div>
                                <input id="Print_Movements" type="checkbox" />
                                <label for="Print_Movements">Print Movements</label>
                        </div>
                        <div>
                                <input id="Cash_Basis" type="checkbox" />
                                <label for="Cash_Basis">Cash Basis</label>
                        </div>
                        <div>
                                <input id="Show_Departments" type="checkbox" />
                                <label for="Show_Departments">Show Departments</label>
                        </div>
                        <div>
                                <label for="sort">Sort</label>
                                <select id="sort">
                                        <option value="2">Code</option>
                                        <option value="3">Description</option>
                                        <option value="4">Accountant Code</option>
                                </select>
                        </div>
                        <div>
                                <label for="from">Period</label>
                                <select id="from">
                                        <option value="112">Mar:2008/09</option>
                                        ...
                                        <option value="310">Jan:2010/11</option>
                                </select>
                        </div>
                </controls>
        </report>
</plugins>

Note that you can use the <controls> element more or less directly in an HTML page to collect settings:

doform

Generate a PDF of a form

GET /REST/DocumentName.moneyworks/doform

Parameters

form=name

search=expr

Message=messagetext

Print_Copy=1|0

Include_Remit=1|0

Stmt_Date=yyyymmdd

Omit_Zero=1|0

Omit_Credit=1|0

The form can reside in custom or standard plugins on the server. All params except form and searchare optional.

Output format is pdf, delivered as application/pdf.

Example

GET REST/Acme.moneyworks/doform/form=Plain%20Ruled%20Invoice&search=sequencenumber%3d1686&message=Thanks

image

Use GET to retrieve an image.

GET /REST/DocumentName.moneyworks/image/product=code 
GET /REST/DocumentName.moneyworks/image/transaction=seqnum 
GET /REST/DocumentName.moneyworks/image/key=ident 

Retrieves a product or transaction image. Response will be image/png, image/jpg or application/pdf.

Use PUT to upload an image and attach to an existing transaction or product. Any existing image will be replaced.

PUT /REST/DocumentName.moneyworks/image/product=code 
PUT /REST/DocumentName.moneyworks/image/transaction=seqnum 

Note that the PUT data must be binary (if using curl use the --data-binary option) and content type should be image/png or image/jpg for a product image. For a transaction image it may also be application/pdf. In actual fact, a Content-Type of application/octet-stream is fine, just make sure you are PUTting binary data.

The transaction flags field will be updated to indicate that the transaction has an image, provided that no user has the transaction locked. If the transaction is locked, an error is returned, even though the image has been uploaded (and may have replaced an existing image). If the transaction is locked, it may be that a user is editing the transaction and will subsequently overwrite your image when they save the transaction.

Concurrent users and availability

Most REST requests are performed by a worker process on the server. This process logs into the database with the credentials you provide. It may consume one of the concurrent logins allowed for the server or folder account. If there are no concurrent logins available, then the request will fail.

If the server is configured with a dedicated REST availability serial number, then this will never be a problem. If it is not, then you should take the possibility of concurrent login saturation into account.

Note also that, by default, these worker processes linger for a short time (on the order of 10-30 seconds), so that a subsequent request with the same credentials can be serviced much faster. These lingering processes will continue to consume a concurrent login. If you do not wish this to happen, as of v7.1.5 you can add a parameter no_linger=true to your requests to cause the worker process to die immediately after servicing your request (this will allow a subsequent request with different credentials to succeed where concurrent logins are in short supply).

History

MoneyWorks REST interface first appeared in MoneyWorks Datacentre 6.1

HTTPS support was added in v7.1

HTTP/1.1 support was added in v8.0

Posted in REST | Comments Off on MoneyWorks Datacentre REST API

MoneyWorks URL Scheme

The MoneyWorks URL scheme follows the pattern of the Common Internet Scheme syntax described in RFC 1738.

Where can I use it?

On both Mac OS X and Windows you can make a shortcut file that will connect you to a MoneyWorks server when you open it.

You can use a URL in place of a file path on the command line when starting MoneyWorks (usually using a shortcut) or as the parameter to the "open" command in a VB script.

On Mac and Windows you can type a moneyworks URL into your web browser, or use a bookmark to initiate a connect in MoneyWorks

You can create a standalone shortcut file containing the url that can be opened by double-clicking.

URL scheme

The syntax is as follows:

"moneyworks://" [ "ssl/" ] [ folderuser [ ":" folderpass ] "@" ] server [ ":" port ] [ "?doc=" [ docuser [ ":" docpass ] "@" ] documentname ]

folderuser is the folder name on the server (if the server requires folder login)

folderpass  is the folder password to use (if the server requires folder login)

server is the server IP address or domain name

port is the port to connect to (usually 6699)

ssl/ must be included if the server has TLS enabled.

documentname is the name of the document on a Datacentre to connect to. This must be URL-encoded: i.e. characters such as spaces and other non-alphanumerics must be %hex encoded. Document and folder names are matched case-sensitively. Make sure you have the correct case. If the document is in a subfolder then the partial path from the folder you logged into must also be supplied (with a url-encoded path separator).

moneyworks://ssl/root:rootpass@prefect.cognito.co.nz:6699?doc=rowan:pass1@MyFold%2fAcme%20Widgets%20Ltd.moneyworks

Connect to named document in the MyFold folder but logging into the server as root. Note that spaces and special characters in the document name/path must be escaped as hexadecimal according to standard URL rules. If the document is in a subfolder on the Datacentre, you must include the subfolder name and path separator appropriate to the platform the Datacentre is running on (/ for Mac, \ for Windows)

When MoneyWorks Datacentre is set up to require login itself (ASP user partitioning), you will need to pass the document username and password as part of the ?doc= part of the URL; the Datacentre login username and password come before the server in that case.

moneyworks://MyFold:MyPass@prefect.cognito.co.nz:6699?doc=rowan:pass1@Acme%20Widgets%20Ltd.moneyworks

Connect to the named document by logging into the folder MyFold using supplied folder user name and password. The document is specified starting at that folder, so the folder name is not included in the document path. No SSL.

moneyworks://MyFold@prefect.cognito.co.nz:6699?doc=Rowan@Acme%20Widgets%20Ltd.moneyworks

In this instance, no passwords are supplied. MoneyWorks will try to retrieve them from the Keychain/Vault.

moneyworks://MyFold:fred@prefect.cognito.co.nz:6699

Just connect to the server. A login dialog box will be presented to ask for credentials and choose a document.

MoneyWorks Now URL scheme

There is a special URL format for MoneWorks Now connections. These do not include any kind of server name, since the host for a document is managed by the MoneyWorks Now login system.

The syntax is as follows:

"moneyworks://now/" mwnowusername [ ":" password ] "/" [ companyName | hostFolder "/" documentName ]

The Company name, if supplied, is the name as it appears in the Company Details dialog in the document; URL-encoded.

The document pathname, if supplied, must include the "folder" or MoneyWorks Now hosting account name, followed by a slash, and then the document name.

Examples:

moneyworks://now/someuser@example.com/Example%20Company%20Ltd

No password supplied: It will be obtained from the Keychain/Vault on your computer, if present.

moneyworks://now/someuser@example.com:password/Example/Example%20Accounts.moneyworks

Supplying a password in the URL (not recommended — use your computer's Keychain/Vault).

Making a shortcut to a network document

Mac OS X

[v4.1.4 and later]

In Safari Bookmarks, click the + icon; Type the address for your shortcut in the form described above. Note that you can omit the password for the document if you have already stored the password in your Keychain.

Typing a MoneyWorks URL in Safari. The server address in this case is the localhost address, since this connection happens to rely on a previously established SSH tunnel to a remote server 1000 miles away.

You can now start a connection by clicking the bookmark. You can also drag this bookmark to the Finder to make a double-clickable shortcut document, however, Safari will create this document with a file extension of .inetloc, and this will not work due to a bug in the Mac OS X Finder (currently under investigation by Apple). You can make it work by simply renaming the file extension to .webloc. Double-click it to start a connection.

Windows

On Windows, you can use a regular shortcut (.LNK) file to pass the URL as the command line argument.

Make a New Shortcut by right clicking in Windows Exporer and choosing New -> Shortcut and typing the 2 arguments in quotes. The first argument is the path to the MoneyWorks .exe, the second is the URL to the network server.

E.g:

"C:Program FilesMoneyWorks GoldMoneyWorks Gold.exe" "moneyworks://Admin@Prefect.local:6699?doc=Play%20File"

Using URL from a script

Windows

You can pass the url as the argument to the COM/OLE open command, from Visual Basic etc.

Mac

Use open location "moneyworks://...."

Posted in CLI, Esoterica, Networking | Comments Off on MoneyWorks URL Scheme