You can develop a custom staging journal table setup. If you have set up a custom staging journal table in the right way, you can select it on the staging document header.
The base staging journal table is 'BisStagingJournal'. All customized staging journal tables must be an extension of this table.
Several predefined staging journal tables are available for Connectivity studio.
For EDI, several predefined staging journal tables are available:
- BisEdiStagingTransferOrder
- BisEdiStagingPurchOrder
- BisEdiStagingSalesOrder
- BisEdiStagingInventoryOrder
Predefined generic staging journal table
One predefined generic staging journal table is available for Connectivity studio: 'BisStagingBufferOrderJournal'. Usually, you only use this generic table if you have a limited number of simple integrations. So, integrations that integrate one smaller table.
If you want to use staging for integrations with multiple tables or bigger tables, you are advised to develop a custom staging journal table instead of using the generic staging journal table.
Staging journal table structure
A staging journal setup has these components:
- Staging journal table: This is the main table.
- Staging journal data tables: These tables hold the data and are linked to the main table. These can be header tables and, if desired, line tables or other sub tables.
Custom staging journal table
To create a custom staging journal table, extend the BisStagingJournal base table. If you do so, the custom table gets the same status flow and filtering options as the base table.
Make sure, the custom staging journal table has these fields:
- Journal ID: The journal ID is automatically created based on number sequence that is defined on the applicable staging document header.
- Journal status: The journal status indicates the status of the whole staging journal.
- Journal type: The journal type is a self-definable name to easily identify staging journals. It is defined on the applicable staging document header.
- Approved by: The user who approved the staging journal. If the message that imports the data in the staging journal is run in batch, this is the user who created the batch job.
- Approved date: The date on which the staging journal is approved.
For the staging journal table, no validations are required.
Custom staging journal data table
To create a customized staging data journal table, copy the BisBaseStagingTable table. Give the table a unique descriptive name, for example, BisStagingSalesLine. Add the desired fields to the table. Also add the relations that are used on the form.
Make sure, the custom staging journal data table has at least these fields:
- Journal ID
- Record ID
- Parent record ID
For a staging journal data table, you must develop the desired validations.
Note: If an imported field value (often) must be changed in the staging journal before you process it to D365 FO, you can choose to store both the original value and the to-be-processed value. To do so, add the field twice to the staging journal data table with different names. For example, if the imported item number must be changed, you add these fields: OriginalItemId and ItemId. In the staging journal data table, make the original value field non-editable. Doing so, you can always trace the original value. Use the message field mapping to define which values must be entered in the original value field and the to-be-processed value field.
Form
Develop a form to view the data in the custom staging journal table and custom staging journal data tables.
To develop the form, use a predefined staging journal form as a guideline.
Validations
On approval of a staging journal, you can apply data validations to the staging journal data tables. You can, for example, validate an address or an EAN code. To develop a validation, extend the BisEdiStagingValidationBase class. Give the class a unique name in this format: BisCheck[custom staging journal data table name]. Example: BisCheckBisStagingSalesLine.
In the custom validation class, at least, customize these methods:
- check: Use this method to run the check for your class and return true or false.
- getDefaultText: Use this method to define the default error message if the check returns false. Change the default error message as desired. In the message, you can use variables like %1 or %2.
Example:
public BisEdiValidationText getDefaultText()
{
return 'The price %2 for Line %1 differs from the original price %3';
}
- getValidationNumber: Use this method to define the validation number which can be replied to another application.
- getValidationText: Use this method to get the error text, replacing the variables with the actual value. Make sure, that the custom validation class knows the applicable table is for the validations.
Example:
public void new (Common _record, BisEdiTmpValidationTable _tmpValidationTable)
{
super (_record, _tmpValidationTable);
mEdiPurchaseLine = _record;
}
public BisEdiValidationText getValidationText()
{
return strFmt(mTmpValidationTable.Text, mEdiPurchaseLine.LineNumber, mEdiPurchaseLine.PurchPrice, mEdiPurchaseLine.displayOriginalPrice());
}
How to apply validations differs:
- Connectivity studio: The custom validations must be called from the staging journal data tables. So, on each staging journal data table, develop which validation methods are applicable. All validation methods that are defined on a staging journal data table are applied when data is imported to the table.
- EDI studio: You can apply the custom validations in the validation rules.