Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

insert data to data Entity

(0) ShareShare
ReportReport
Posted on by 390

Hello Team,

I'm new to Dynamics 365 Finance and Operation and hence I need help to know that how to add data to the data entity and the underlying data source, staging table through x++ code?

Also I want know the meaning of getbuffer() and setbuffer()?

  • nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: insert data to data Entity

    Could you mark the helpful answer(s) as verified to close the thread and point others to the correct answer? Thanks!

  • skd Profile Picture
    390 on at
    RE: insert data to data Entity

    Yes it is. Thank you

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: insert data to data Entity

    I'm still not sure if I understand. Like I wrote in my first reply, the CRUD operations work just like they do with tables.

    Do you know how to read, insert, update and delete data from tables via x ?

    In my first reply I shared an example on how to insert  data via an entity. It should give you a pretty good idea how to do updates and deletes, too. Read operations are done with a select statement, just like with tables. So, there's your CRUD.

    But, perhaps it's good to clarify it even more:

    MyDataEntity myEntity;
    
    myEntity.clear();
    myEntity.MyField = 'foo';
    myEntity.insert(); // "C"
    
    select firstonly myEntity where myEntity.MyField == 'foo'; // "R"
    
    myEntity.selectForUpdate(true);
    myEntity.MyField = 'bar';
    myEntity.update(); // "U"
    
    myEntity.delete(); // "D"
    
    // That's CRUD!

    Is it clear now?

  • skd Profile Picture
    390 on at
    RE: insert data to data Entity

    what I mean was, could your tell me names of some standard data entities who's x++ code I can refer for CRUD operations on the data entity.

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: insert data to data Entity

    You can use any entities which are not marked as "Read only" in CRUD operations.

    Perhaps I didn't understand what you are asking - in that case could you please explain a bit more what you mean by that question. Thanks!

  • skd Profile Picture
    390 on at
    RE: insert data to data Entity

    Hey Nikolaos,

    Thank you. Can please tell me some standard entity which I can refer to know CRUD operations on entity.

  • Suggested answer
    nmaenpaa Profile Picture
    101,158 Moderator on at
    RE: insert data to data Entity

    getBuffer returns the table buffer of your data source table.

    For example if you have entity MyEntity and it has data source MyTable, then if you call getBuffer method of MyTable data source, you will get table buffer of MyTable.

  • WillWU Profile Picture
    22,352 on at
    RE: insert data to data Entity

    Hi skd,

    HcmPositionDetail positionDetail = _dataSourceCtx.getBuffer() is used to get the run time data source buffer(HcmPositionDetail).

  • skd Profile Picture
    390 on at
    RE: insert data to data Entity

    Hi Will Wu,

    Thank you.

  • skd Profile Picture
    390 on at
    RE: insert data to data Entity

    Hey Martin,

    I just want to add data to my data entity since I wasn't sure how to do it so I mentioned all the tables but now I got it from your reply that how to add data.

    Regarding getbuffer() and serbuffer() I meant was

    Eg: HcmPositionDetail positionDetail = _dataSourceCtx.getBuffer();

    what does this statement exactly mean?

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,283 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,025 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans