This is an old revision of the document!


Introduction

If you use Moneyworks v5 or newer, and would like to integrate it with 4D v11 or newer, then you've come to the right place! Simply download and install the component, play with the example database (or read the documentation), and you're away.

This document is based on the Moneyworks command-line documentation from Cognito (http://cognito.co.nz/developer/cli-manual.

The component has been tested on 4D v11r8, v12.1 and v13.4, connecting to Moneyworks v5, v6 and v7 respectively. It will operate as a trial for one hour. For a license key, or to obtain the source code, please contact us (http://www.sussol.net/contact/). Pricing is a simple flat rate of $250 per year for unlimited use.

Now updated for 4D v15, including support for REST connections to versions of Moneyworks newer than v6.1 - see http://cognito.co.nz/developer/moneyworks-datacentre-rest-api/

Examples using the available methods are included in the accompanying example database, which also includes a form which can be used to experiment (use the mwks_preferences method to open it).

Downloads

Component (unicode) + example database for v11 is available here

Component only (without example database), with unicode switched off, for v11 is available here

Component only (without example database) for v12 (fixed for Moneyworks 7.1.9) is available here (Previous version available here)

Component only (without example database) for v13 (fixed for Moneyworks 7.1.9) is available here

Component only (without example database) for v14 (fixed for Moneyworks 7.1.9) is available here

Component only (without example database) for v15 (including Moneyworks REST support) is available here

This wiki will always have the latest version of the documentation, but an older PDF version is available here

Files and Strings

The full path must be given for any files, as the Moneyworks command line doesn't know about the Moneyworks plugins folder. Paths on the Macintosh should use the posix standard rather than the old OS9 standard. Spaces within paths may need to be escaped.

For non-REST connections, double quotes within strings should be escaped, or use Char(Double Quote). Single quotes should also not be used (except in the extra_parameters parameter in the export/import/report and form methods, which is passed verbatim to Moneyworks) as they are used internally to delimit the parameters passed to the Moneyworks command line.

Included Methods

mwks_register

(registration_key) → Boolean

ParameterTypeDescription
registration_keyStringRegistration key for component

Return value

True if registration_key is valid, otherwise False

Description

Registers the component using the given key string. If the key isn't valid, the component can still be used for an hour before it times out. This method should be called before attempting to use any other component method e.g. in the On Startup database method.

mwks_setup_connection

(p_connect; p_application; p_error; connection; mwks_location

[if connection=1 (Gold local): data_path; doc_username; doc_pass]

[if connection=2 (Gold server): client_license; doc_username; doc_pass; server_ip; server_port]

[if connection=3 (DC server) or 4 (DC REST server):data_path; doc_username; doc_pass; server_ip; server_port; dc_username; dc_pass;dc_os]

{; open_datafile} {; xml_output}) → Boolean

ParameterTypeDescription
p_connectPointer to stringReturned containing the connect string
p_applicationPointer to stringReturned containing the Moneyworks application string
p_errorPointer to stringReturned containing the error string
connectionInteger1=Gold local, 2=Gold server, 3=DC server, 4=DC REST server
mwks_locationStringFull path to Moneyworks executable (not needed if connection=4)
data_pathStringFull path to data file (if connection=1), or document filename (if connection=3 or 4)
doc_usernameStringUsername for data file (ignored if doc_pass is blank)
doc_passStringPassword for data file (may be left blank)
client_keyStringLicense key for client of Gold server
server_ipStringIP address of Gold server/DC server/DC REST server
server_portStringIf left blank, uses default port (6674 for Gold server, 6699 for DC server, 6710 for DC REST server)
dc_usernameStringUsername for DC or DC REST server login (may be left blank if server not running in ASP mode, otherwise it is required)
dc_passStringPassword for DC or DC REST server (may be left blank)
dc_osStringOS of DC server - either 'Windows' or 'Macintosh'
open_datafileStringOptional parameter - if non blank, try to open the data file
xml_outputStringOptional parameter - if non blank, use XML output

Return value

True if the connection string has been setup correctly, otherwise False (in which case p_error is populated with the error message). If the optional open_datafile parameter has been passed and is not an empty string, it will only return True if the data file has been opened successfully.

Description

Sets up the necessary connection parameters for communicating with Moneyworks (p_connect and p_application are then used in most of the other component methods). The first five parameters are common for all connection types, and the remaining parameters depend on the connection type (three for Gold local, five for Gold server, and eight for DC or DC REST server).

The last two parameters (open_datafile and xml_output) are optional. If open_datafile is not an empty string, it will attempt to open the data file, otherwise it will just create the connection string. If xml_output is not an empty string, it will use the -x parameter to call the Moneyworks command-line (rather than -q). This gives more descriptive error messages in many cases e.g. when importing data. Note that if you use XML output, the result string will lose any tab or newline characters that you might have included in the format parameter e.g. when exporting data.

mwks_run_command

(connect_string; command_string; application_string; p_result; p_error {; blob_POST} ) → Boolean

ParameterTypeDescription
connect_stringStringConnect string
command_stringStringMoneyworks command string
application_stringPointer to stringMoneyworks application string
p_resultPointer to stringFor the result string
p_errorPointer to stringFor the error string
blob_POSTBlobOptional - POST data for REST (as XML)

Return value

True if successful, otherwise False (in which case p_error is populated with the error message).

Description

Generic method to run any Moneyworks command (used in the Execute button on the example form). The first two parameters are the connection parameters from mwks_setup_connection (p_connect and p_application). The result of running the command is passed back in p_result. Note that for REST connections, the command must be formatted using the appropriate URL and HTTP escape characters.

mwks_evaluate

(connect_string; application_string; p_result; p_error; expression) → Boolean

ParameterTypeDescription
connect_stringStringConnect string
application_stringStringMoneyworks application string
p_resultPointer to stringFor the result string
p_errorPointer to stringFor the error string
expressionString
Edit this page
Back to top