web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

Generate Line Number automatically while importing data through Custom data entity having custom data source in D365 F&O

(0) ShareShare
ReportReport
Posted on by 758

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.

I have the same question (0)
  • André Arnaud de Calavon Profile Picture
    300,911 Super User 2025 Season 2 on at

    Hi Rhushikesh,

    Can you describe in detail what you mean with did not work? Were you able to build your full model without errors? Do you get errors? What is the value after import if you don't have errors? What coding is used in the method 'CustomerRemittanceAdviceLines::lastLineNum'?

  • Rhushikesh R Profile Picture
    758 on at

    Hi Andre, sorry for not putting into detail. But now I am able to generate the line number. Some ISV solution was causing issue because of that I was not able to use Auto-generation functionality in Entity mapping.

    Thank you for your response.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 664 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 522 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 303 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans