Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

use of Table.InitValue()

Posted on by 5,901

Dear All,

I saw in many standard code that when they insert records in table. So, they called Table.InitValue() then Table. insert().

Example :

TTsbegin;

Table.InitValue()

// to do

Table.Insert();

TTScommit;

Can you please let me know when we called Table.initValue() what impact will happened before insert records in table? 

TTSbegin and TTScommit is mandatory to write on Table.insert().

Please give me more shed on this.

Thanks!
Arpan Sen

  • Suggested answer
    Vilmos Kintera Profile Picture
    Vilmos Kintera 46,147 on at
    RE: use of Table.InitValue()

    Specifically calling initValue() is a good idea, but there are more detailed explanations in the linked topics.

    They usually initialize values which should be populated with a default value, like for SalesTable's Sales status you do not want to have None, but rather the enumeration value which belongs to Open sales order, which is not the first entry for the SalesStatus enum. In that case you'd want to initialize it, and that is done in initValue() call as the first step after the .create() operation on the record buffer. You can also find buffer-based initalization which can be seen as initFromTableName(), to copy over values, like from SalesTable to SalesLine.

    TTS block is not required for insert operations, unless you have business logic there that is not for that table in question. TTS block should only be used if you want to roll back the entire section that happens in there in case anything raises an error, so is typically used if you have postings, multiple table inserts, and so on, so you do not leave behind half-baked transactions.

  • Pravasti AK Profile Picture
    Pravasti AK 2,985 on at
    RE: use of Table.InitValue()

    Hi,

    Please refer the below link:

    https://community.dynamics.com/ax/f/33/t/161489

  • @rp@n Profile Picture
    @rp@n 5,901 on at
    RE: use of Table.InitValue()

    Thanks Sefa

  • Suggested answer
    Sefa Duman Profile Picture
    Sefa Duman 1,167 on at
    RE: use of Table.InitValue()

    Hi Arpan,

    See this topic for detailed information:

    [View:https://community.dynamics.com/ax/f/33/t/161489]

Helpful resources

Quick Links

Dynamics 365 Community Update – Sep 16th

Welcome to the next edition of the Community Platform Update. This is a weekly…

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,353 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,251 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans