Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
4d_moneyworks_component [2016/10/03 15:07] – Adrian Boone | 4d_moneyworks_component [2019/11/15 11:36] (current) – removed lou | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ======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), | ||
- | |||
- | This document is based on the Moneyworks command-line documentation from Cognito ([[http:// | ||
- | |||
- | 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:// | ||
- | |||
- | <wrap hi>Now updated for 4D v15, including support for REST connections to Moneyworks v7</ | ||
- | |||
- | 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 {{: | ||
- | |||
- | Component only (without example database), with unicode switched off, for v11 is available {{: | ||
- | |||
- | Component only (without example database) for v12 (fixed for Moneyworks 7.1.9) is available {{: | ||
- | |||
- | Component only (without example database) for v13 (fixed for Moneyworks 7.1.9) is available {{: | ||
- | |||
- | Component only (without example database) for v14 (fixed for Moneyworks 7.1.9) is available {{: | ||
- | |||
- | Component only (without example database) for v15 (including Moneyworks REST support) is available {{: | ||
- | |||
- | This wiki will always have the latest version of the documentation, | ||
- | |||
- | =====Files and Strings===== | ||
- | |||
- | The full path must be given for any files, as the Moneyworks command line doesn' | ||
- | |||
- | Double quotes within strings should be escaped, or use Char(Double Quote). Single quotes should not be used (except in the // | ||
- | ======Included Methods====== | ||
- | =====mwks_register ===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |registration_key|String|Registration key for component| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====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 ===== | ||
- | // | ||
- | |||
- | //**[if connection=1 (Gold local): data_path; doc_username; | ||
- | |||
- | //**[if connection=2 (Gold server): client_license; | ||
- | |||
- | //**[if connection=3 (DC server) <wrap hi>or 4 (DC REST server)</ | ||
- | |||
- | // | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |p_connect|Pointer to string|**Returned** containing the connect string| | ||
- | |p_application|Pointer to string|**Returned** containing the Moneyworks application string| | ||
- | |p_error|Pointer to string|**Returned** containing the error string| | ||
- | |connection|Integer|1=Gold local, 2=Gold server, 3=DC server, <wrap hi>4=DC REST server</ | ||
- | |mwks_location|String|Full path to Moneyworks executable <wrap hi>(not needed if connection=4)</ | ||
- | |data_path|String|Full path to data file (if connection=1), | ||
- | |doc_username|String|Username for data file (ignored if doc_pass is blank)| | ||
- | |doc_pass|String|Password for data file (may be left blank)| | ||
- | |client_key|String|License key for client of Gold server| | ||
- | |server_ip|String|IP address of Gold server/DC server/< | ||
- | |server_port|String|If left blank, uses default port (6674 for Gold server, 6699 for DC server, <wrap hi>6710 for DC REST server</ | ||
- | |dc_username|String|Username for DC <wrap hi>or DC REST</ | ||
- | |dc_pass|String|Password for DC <wrap hi>or DC REST</ | ||
- | |dc_os|String|OS of DC server - either ' | ||
- | |open_datafile|String|Optional parameter - if non blank, try to open the data file| | ||
- | |xml_output|String|Optional parameter - if non blank, use XML output| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Sets up the necessary connection parameters for communicating with Moneyworks (// | ||
- | |||
- | The last two parameters (// | ||
- | |||
- | |||
- | ========== | ||
- | |||
- | =====mwks_run_command===== | ||
- | //** (connect_string; | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |connect_string|String|Connect string| | ||
- | |command_string|String|Moneyworks command string| | ||
- | |application_string|Pointer to string|Moneyworks application string| | ||
- | |p_result|Pointer to string|For the result string| | ||
- | |p_error|Pointer to string|For the error string| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====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_evaluate ===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |connect_string|String|Connect string| | ||
- | |application_string|String|Moneyworks application string| | ||
- | |p_result|Pointer to string|For the result string| | ||
- | |p_error|Pointer to string|For the error string| | ||
- | |expression|String|Expression to be evaluated| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Evaluate the given expression. The first two parameters are the connection parameters from // | ||
- | |||
- | Note that single quotes should not be used in the // | ||
- | |||
- | < | ||
- | will set the product custom3 field to " | ||
- | |||
- | < | ||
- | |||
- | |||
- | |||
- | |||
- | =====mwks_import_file ===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |||
- | =====mwks_import_text===== | ||
- | // | ||
- | |||
- | |||
- | ========== | ||
- | |||
- | =====mwks_import_arrays===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |connect_string|String|Connect string| | ||
- | |application_string|String|Moneyworks application string| | ||
- | |p_result|Pointer to string|For the result string| | ||
- | |p_error|Pointer to string|For the error string| | ||
- | |import_map|String|Full path to Moneyworks import map| | ||
- | |file_path|String|Full path to file to be imported| | ||
- | |import_text|String|Text to be imported| | ||
- | |p_text_array|Pointer to string array|Array of individual field data values to be imported| | ||
- | |extra_parameters|String|Advanced import options - see below| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Three different ways to import data, depending on whether the data is being imported from a file, a pre-prepared text string, or an array of individual field strings (which are combined internally into a single string) The first two parameters are the connection parameters from // | ||
- | |||
- | There is no metacharacter expansion when importing from text (or from an array of text), so you can't use \t, \n etc.. If you have multiple lines to import, write your data to a temporary file and import from the file instead. Output is a report of number of records created and updated (except for User, Contact and Build files, which will always report zero). Note also that single quotes should not be used in // | ||
- | |||
- | Additional arguments which can be combined into // | ||
- | |||
- | * filename=' | ||
- | |||
- | * update=' | ||
- | |||
- | * return_seq=' | ||
- | |||
- | * post=' | ||
- | |||
- | * post seqnum=' | ||
- | |||
- | |||
- | =====mwks_export ===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |$|**Parameter**|**Type**|**Description**| | ||
- | |1|connect_string|String|Connect string| | ||
- | |2|application_string|String|Moneyworks application string| | ||
- | |3|p_result|Pointer to string|For the result string| | ||
- | |4|p_error|Pointer to string|For the error string| | ||
- | |5|table|String|Moneyworks table name| | ||
- | |6|format|String|Format string (if blank, use default export format)| | ||
- | |7|search|String|Search string (if blank, include all records)| | ||
- | |8|output_file|String|Full path to output file (if blank, return in // | ||
- | |9|extra_parameters|String|Advanced export options - see below| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Export data from the given file (" | ||
- | |||
- | The //table// parameter may// //include a sort specifier (e.g. " | ||
- | |||
- | If the //search// parameter is an empty string, you will get all records, otherwise only those matching the search expression. Using " | ||
- | |||
- | 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, | ||
- | |||
- | Note that single quotes should not be used in the //table//, //format//, or //search// parameters as they are used internally to delimit the corresponding command-line parameters sent to Moneyworks. You can use double quotes instead e.g. $t_search: | ||
- | |||
- | If the // | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | =====mwks_data_to_arrays ===== | ||
- | // | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |result_string|String|Result string from mwks_export()| | ||
- | |p_arrays|Pointer to 2D array|For an array of text arrays to hold results| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Description==== | ||
- | Process exported data from MoneyWorks. Create a 2D array of zero-element text arrays (one for each field to be returned) and pass a pointer to it as // | ||
- | |||
- | |||
- | ========== | ||
- | |||
- | =====mwks_report===== | ||
- | //** (connect_string; | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |connect_string|String|Connect string| | ||
- | |application_string|String|Moneyworks application string| | ||
- | |p_result|Pointer to string|For the result string| | ||
- | |p_error|Pointer to string|For the error string| | ||
- | |report_path|String|Full path to report| | ||
- | |format|String|' | ||
- | |from|String|From date string (may be blank)| | ||
- | |to|String|To date string (may be blank)| | ||
- | |output_file|String|Full path to output file (if blank, return in // | ||
- | |extra_parameters|String|Advanced report options - see below| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Executes the given report. The first two parameters are the connection parameters from // | ||
- | |||
- | You should either supply both //from// and //to// as date strings (e.g. ' | ||
- | |||
- | Note that single quotes should not be used in the //format// parameter, as they are used internally to delimit the command-line parameters sent to Moneyworks. | ||
- | |||
- | If // | ||
- | |||
- | 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 in // | ||
- | |||
- | |||
- | |||
- | |||
- | =====mwks_form===== | ||
- | //** (connect_string; | ||
- | |||
- | |||
- | |||
- | |**Parameter**|**Type**|**Description**| | ||
- | |connect_string|String|Connect string| | ||
- | |application_string|String|Moneyworks application string| | ||
- | |p_result|Pointer to string|For the result string| | ||
- | |p_error|Pointer to string|For the error string| | ||
- | |form_path|String|Full path to form| | ||
- | |format|String|' | ||
- | |search|String|Search string (required unless form type is .rept)| | ||
- | |output_file|String|Full path to output file (if blank, return path in // | ||
- | |extra_parameters|String|Advanced form options - see below| | ||
- | |||
- | |||
- | |||
- | |||
- | ====Return value==== | ||
- | // | ||
- | |||
- | |||
- | ====Description==== | ||
- | Only available in Moneyworks v6. Renders the form to a pdf file. The first two parameters are the connection parameters from // | ||
- | |||
- | For form types other than .rept the //search// parameter must be provided to select the record(s) to use. If multiple records are selected, all output still goes to the same file. | ||
- | |||
- | The only supported //format// at present is " | ||
- | |||
- | Note that single quotes should not be used in the //search// parameter as they are used internally to delimit the command-line parameters sent to Moneyworks. You can use double quotes instead e.g. $t_search: | ||
- | |||
- | 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 in // | ||
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- | ======Migrating from previous Moneyworks 4D plugin====== | ||
- | The main differences are: | ||
- | |||
- | *The connection to Moneyworks is handled differently - most methods take two extra parameters (// | ||
- | *The return value is usually Boolean rather than text - text return values are passed via a string pointer instead (// | ||
- | *There is no separate method (// | ||
- | *There is no equivalent of // | ||
- | Taking into account the extra (four in most cases) parameters, the methods can be mapped as follows: | ||
- | |||
- | *Connecting to Moneyworks: // | ||
- | *Evaluating expressions: | ||
- | *Importing: The // | ||
- | *Exporting: The //table//, //search// and // | ||
- | *Reporting: The // | ||
- | |||
- | |||