web
You’re offline. This is a read only version of the page.
close
Skip to main content
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()?

I have the same question (0)
  • nmaenpaa Profile Picture
    101,160 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,160 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,160 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,160 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,361 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

Responsible AI policies

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

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

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

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 841 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 566

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans