Hi Experts,
I have created one custom table which has unique index of combination of 2 fields, LineNumber & DocumentId. On table level, index properties, I have set Allow Duplicates to No.
I have created one custom data entity for same. The requirement is to not add LineNumber field in Entity as well as staging table. My client wants that, the line number should be auto generated based on last record available for specific DocumentId in the table.
I observed SalesOrderLinesV2 entity, and tried to implement similar kind of logic. I wrote insertEntityDataSource on custom entity. But it did not work.
public boolean insertEntityDataSource(DataEntityRuntimeContext _entityCtx, DataEntityDataSourceRuntimeContext _dataSourceCtx)
{
boolean ret;
CustomerRemittanceAdviceLines customerRemittanceAdviceLines = _dataSourceCtx.getBuffer();
customerRemittanceAdviceLines.LineNumber = customerRemittanceAdviceLines.LineNumber ? customerRemittanceAdviceLines.LineNumber : CustomerRemittanceAdviceLines::lastLineNum(this.PaymentDocumentNumber) 1;
ret = super(_entityCtx, _dataSourceCtx);
return ret;
}
On SalesOrderLinesV2 entity, LineNumber field is also being mapped in insertEntityDataSource method and that field is not a part of data entity. On staging table of SalesLine entity, InventoryLotId field has been added as Staging index.
And during import of data the field InventoryLotId we usually set it to AutoGenerated to Yes and allow blank value to Yes in entity mapping.
Can anyone please guide, what all steps I should follow, to auto populate Line number in my custom table without including it in Data entity & staging table ? Do I need to add any similar field like InventoryLotId to mainatin unique index on Staging table?
Thank you in advance.