Query Sets, which are collections of MetaSQL statements, can be created and edited in the Export Data screen (Section 3, “Sending CSV Files”. See the xTuple ERP Reference Guide for full documentation of the Export Data screen.
) and the EDI Form screen as described inxTuple Connect adds a SCHEDULE button to the Export Data screen. This button lets you send the Query Set to the xTuple Connect Batch Manager to be run. All Query Sets are run using the xTupleQuerySetEmail
System EDI Profile.
The xTupleQuerySetEmail
is similar to the xTupleMetaSQLEmail
profile. The primary difference is that the default output format for Query Sets is XML. An XML file containing the results of multiple queries is easier to understand than a CSV file with the same data. This is because the CSV file may not contain header lines and, even if it did, these are easily lost because they are mixed in with the data. XML files, on the other hand, have individual tags for each data field and for each row, so the file describes itself—as long as the names of the query set, queries, and result columns are chosen well.
Here is an example of submitting a Query Set to the xTuple Connect Batch Manager:
Select a Destination Format
Create a Query Set if one does not already exist for your needs
Select the Query Set
Set values for the MetaSQL parameters if necessary
Click SCHEDULE
The Review EDI Before Sending screen should appear
Click ACCEPT
Once submitted, it can be rescheduled to run on a regular basis:
Select the appropriate line from the list of jobs. Look for a line with "EmailXML" in the Action column and "Document: QSET name-of-your-queryset" in the Detail column
Click RESCHEDULE
Set the Recurring properties
Click SAVE
When crafting the queries for recurring execution, keep in mind that the values of the MetaSQL parameters are fixed. They do not change from one run of the query to another. Therefore, write your recurring queries to use as few MetaSQL parameters as possible and to use relative information instead of fixed. Here is an example of a problem and 3 solutions:
Automatically explode Work Orders on a regular basis
SELECT wo_number, explodeWo(wo_id, true) AS explodedStatus FROM wo WHERE wo_number = <? value('wo_number') ?>;
This is a bad solution because the user has to pass a particular Work Order. If this job is set to recur, the same Work Order will be exploded repeatedly. This will work the first time but fail every other.
SELECT wo_number, explodeWo(wo_id, true) AS explodedStatus FROM wo WHERE wo_duedate <= '2010-07-25';
This is a little better, because at least this will explode newly created orders for the first few times it runs. However, it will return one row for every Work Order that is due before July 25, whether it needs to be processed or not, and it will stop doing anything useful at all after that date.
SELECT wo_number, explodeWo(wo_id, true) AS explodedStatus FROM wo WHERE wo_status='O' AND wo_duedate <= CURRENT_DATE + CAST('7 days' AS INTERVAL);
This is a much better solution: it restricts the Work Orders to be checked to just those ready to be exploded and it has a moving seven day window.