In D365FO for a new data entity
development, sometimes we required to build an inbound integration/data import
solution where source data doesn’t have any unique index which mean the data
entity needs to build without primary index.
For example, third parties want to
send data for a placeholder table where every import will be considered as data
insert and there is no update scenario.
In such a case below steps can be
followed while creating a new data entity
1. Since data entity wizard doesn't
allow to create a data entity for a table which doesn’t have any unique index,
duplicate any existing data entity and rename it accordingly and change/add
respective table in data source
2. Go to Keys>EntityKey and
add a field manually by setting the data field property to 'RecId'
Note:
i) This field will not be available from the lookup; you have to type it.
ii) You don't need to add 'RecId' field on the data entity fields section
3. Override data entity defaultRow()
method by defaulting the RecId value to zero
/// <summary>
/// Set the
recId value to zero to make data import process for data insert only
/// </summary>
public void defaultRow()
{
this.RecId
= 0;
super();
}
Note: Since entity key is added manually, make sure your staging table shows below fields in the index section
| <Indexes> | |
| <AxTableIndex> | |
| <Name>StagingIdx</Name> | |
| <AlternateKey>Yes</AlternateKey> | |
| <IsManuallyUpdated>Yes</IsManuallyUpdated> | |
| <IsSystemGenerated>Yes</IsSystemGenerated> | |
| <Fields> | |
| <AxTableIndexField> | |
| <DataField>DefinitionGroup</DataField> | |
| </AxTableIndexField> | |
| <AxTableIndexField> | |
| <DataField>ExecutionId</DataField> | |
| </AxTableIndexField> | |
| <AxTableIndexField> | |
| <DataField>RecId</DataField> | |
| </AxTableIndexField> | |
| </Fields> | |
| </AxTableIndex> | |
| </Indexes> |
