Save Data within a Batch

Let's take a look at types of errors you could see when you attempt to save the data from the user interface grid to batch staging tables. Let's also review the relationship between saving data to the batch tables and the Data Form specs associated with the Batch Type spec that used to save the data and support data integrity.

Within the BatchTypeSpec, you will find references to the AddRowDataFormTemplate and EditRowDataFormTemplate XML elements, which point to the IDattribute of an Add Data Form and an Edit Data Form, respectively.

Figure: Add and edit data forms within the BatchTypeSpec

The AddRowDataFormTemplate XML element within the BatchTypeSpec above (yellow highlight) refers to the ID of an Add Data Form that is used to add a new row into batch tables.

Figure: ID attribute of the data form identifies the add data form within the BatchTypeSpec

The EditRowDataFormTemplate XML element within the BatchTypeSpec above (in green) refers to the ID of an Edit Data Form that edits existing rows within batch tables.

Figure: ID attribute of the edit data form identifies the data form within the BatchTypeSpec

Add Data on the Batch UI Grid

These data forms add rows to the batch and edit rows within the batch from the batch user interface grid. We will call the Add Data Form the "Add Batch Row Data Form" and the Edit Data Form the "Edit Batch Row Data Form."

Figure: Data forms save data into the staging table

The figure above provides an overview of how data is entered into batch staging tables from the batch user interface grid. New rows are added through the Add Batch Row Data Form while existing rows are edited by the Edit Batch Row Data Form. Batch staging tables may contain constraints such as unique, required, foreign key, etc. The degree to which constraints are applied to these tables is up to the discretion of the software developer who should consider the source of the data that feeds these tables. If the quality of the data is known to be suspect then you may consider lessening the amount of constraints on these tables. Or you may have an overall data quality policy that only allows for data to be clean and tight prior to entering batch tables. As constraints are encountered within batch tables due to bad data, exceptions will be raised from SQL Server. An ExpectedDBExceptions tag within the data form's SaveImplementation tag provide the Infinity platform with the necessary metadata to gracefully handle such issues. When exceptions occur, the platform logs the messages to the appropriate batch system message table. For details on batch messages, see Batch Messages.

<common:ExpectedDBExceptions>
<common:Constraints>
<common:Constraint Name="CK_USR_BATCHFOODITEMADD_NAME" Field="NAME" Type="Required" />
        </common:Constraints>
</common:ExpectedDBExceptions>

Tip: The degree to which constraints are applied to these tables is up to the discretion of the software developer who should consider the source of the data that feeds these tables.

Add Data through Import

The import process adds rows into staging tables from an import CSV file. The Add Batch Row Data Form is utilized by the import to add the data. Import handlers allow the SDK developer to validate, alter, scrub, and enhance each row of data just before it is added (imported) into a batch staging table. Import bypasses the Batch UI Grid and any associated logic within the batch event handlers.

For details, see Batch Import Handlers Overview.