Data Injection is an advanced feature for integrating with non-Digital-Clay applications. It provides several techniques with which to add or update data records from an external program or web site into Digital-Clay.
External programs may read data directly from the Digital-Clay database, but they are not allowed to write into the database since this would bypass the many integrity checks, automation, auditing and synchronization features of ClayCentral. Data Injection provides write functionality when bi-directional data integration is needed.
No matter which method is used to inject data (Mail, TCP or File), the data must be sent in a specific but simple XML structure (see below).
Data Injection is configured in ClayStudio in Administration/ClayCentral Settings/Data Injection.
Description: XML files are saved inside a specific directory. ClayCentral checks for new XML files in this location periodically and deletes the files as soon as they are read.
Usage:
Details:
Description: ClayCentral listens at a specific TCP port for incoming XML data. Connections may be opened and closed as soon as the data is sent, or connections can be kept open for streaming data.
Usage:
Details:
Description: The XML data is included inside an e-mail. ClayCentral checks the POP account periodically for new e-mails. All E-Mails are deleted as soon as they are retrieved, whether they contain XML data or not.
Usage:
Details:
Sample Clay XML block (for adding/inserting a new Lead):
<ClayData Username='administrator' Password='' TableID='8' SkipErrors='0' AddNewConnected='22' DuplicateHandling='2' UniqueFields='2,9'> <Field ID='2'>John Galt</Field> <Field ID='22' InnerID='2'>Newspaper</Field> <Field ID='9'>02-5866666</Field> </ClayData>
For each field that is being filled, a field tag must be added with the ID as a parameter (see Field Properties for field IDs), and the field value as the tag value. All values will be converted to the best of ClayCentral's ability. This includes dates and numbers.
It is not possible to inject images or attachments.
A Linked Field is set by defining the values in unique identifying fields in the linked record. For example, if a Contact is being added with a link to a Customer, the Customer may be identified by its name, or any other combination of fields like phone number, e-mail and URL.
A Linked Field may be set just like any other field, e.g.:
<Field ID='2'>Newspaper</Field>
By default the unique identifying field is the Name field of the linked record. If you wish to specify which field to use as the identifying field, then add an InnerID attribute which specifies a field ID in the linked record:
<Field ID='2' InnerID='1'>IBM</Field>
To use a combination of multiple identifying fields, add multiple InnerID values:
<Field ID='2' InnerID='1'>IBM</Field> <Field ID='2' InnerID='9'>888-123-4567</Field>
If the linked record is not found, the Linked Field value will be cleared, unless you have specified that missing linked records be added using the AddNewConnected attribute (see above).
Note that Data Injection is designed for adding a single record at a time per XML block. Although linked records may be added on the fly while adding the main record, only the fields you set as the identifying fields may be set in the linked record, which may leave many fields empty. It is therefore recommended that you add the linked records separately first using an additional XML block before adding links to these records.
For setting many-to-many linked fields, the following options are available:
To set a single value in the many-to-many field, simply set it just like regular linked fields.
To set multiple values using any unique identifying fields in the linked record, send multiple XML blocks. For example, to set two Contacts in a Task record:
<ClayData Password='' Username='administrator' TableID='14' SkipErrors='0' AddNewConnected='18' DuplicateHandling='1' > <Field ID='2'>Task123</Field> <Field ID='18' InnerID='7'>Smith</Field> </ClayData>" <ClayData Password='' Username='administrator' TableID='14' SkipErrors='0' AddNewConnected='18' DuplicateHandling='1' > <Field ID='2'>Task123</Field> <Field ID='18' InnerID='7'>Gates</Field> </ClayData>"
The above data (which is sent in a single connection, file or e-mail), will add a single task with two Contacts, one with the Last Name of 'Smith' and another called 'Gates'. If either of these Contacts do not exist, they will be created.
An alternative method of sending a single XML block may be used, but only if the internal IDs of the linked records are known in advance, as follows:
<ClayData Password='' Username='administrator' TableID='14' SkipErrors='0' AddNewConnected='18' DuplicateHandling='1' > <Field ID='2'>Task1234</Field> <Field ID='18' InnerID='0'>-712969534;-675865816</Field> </ClayData>"
This will add two Contacts to the Task:Contacts field having the above IDs.
HTML forms, or web sites, are applications like any other and may use any of the above methods for injecting data into Digital-Clay. A standard method is to submit the HTML form to a formmail CGI that sends the data to a specified e-mail.
The only difficult part in the above scenario is to convert the form values into a Clay XML block. This can be done at the client-side using Javascript, or server-side using PHP/CGI that converts the data before sending the e-mail.
A sample PHP script can be downloaded here. Details:
In addition, a tool for creating HTML forms with client-side conversion is provided in ClayStudio (Data menu):
Each approach has its advantages and disadvantages: