Skip to main content

Notifications

Announcements

No record found.

Business Central forum
Suggested answer

API: System Audit Date

Posted on by Microsoft Employee

Hi,

I am developing a custom API to extract vendor and related data using BC 19.1. My API is working fine and I would like to add audit fields such as systemCreatedAt and SystemModifiedAt

I tried adding them using Rec as well xRec but getting compilation error 

                field(systemCreatedAt; Rec.SystemCreatedAt)
                {
                    Caption = 'SystemCreatedAt';
                }
                field(systemModifiedAt; Rec.SystemModifiedAt)
                {
                    Caption = 'SystemModifiedAt';
                }
compilation failed
src/api/manageVendorAPI.al(92,44):
error AL0132: 'Record Vendor' does not contain a definition for 'SystemCreatedAt' src/api/manageVendorAPI.al(96,45): error AL0132: 'Record Vendor' does not contain a definition for 'SystemModifiedAt'
Any idea what can be the best approach to add field such as SystemCreatedAt and SystemModifiedAt in my APIs (Page Type API)
Thanks
Famy
Categories:
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 69,760 Super User 2024 Season 2 on at
    RE: API: System Audit Date

    Hi, Stefano is right.

    More details:

    Data audit system fields are added to every table in Dynamics 365 Business Central 2020 Release Wave 2 (BC17)

    https://yzhums.com/1897/

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Stefano Demiliani Profile Picture
    Stefano Demiliani 37,160 Most Valuable Professional on at
    RE: API: System Audit Date

    Version 16 does not contain these fields. These fields are available starting from BC 17 (October 2020).

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: API: System Audit Date

    I am using version 20.3 and this works fine for me:

    Unfortunately i do not have a version 16 to look at.

    page 50100 vendapi
    {
        APIGroup = 'vendor';
        APIPublisher = 'publisherName';
        APIVersion = 'v1.0';
        Caption = 'vendapi';
        DelayedInsert = true;
        EntityName = 'vendor';
        EntitySetName = 'Vendors';
        PageType = API;
        SourceTable = Vendor;
        
        layout
        {
            area(content)
            {
                repeater(General)
                {
                    field(systemCreatedAt; Rec.SystemCreatedAt)
                    {
                        Caption = 'SystemCreatedAt';
                    }
                    field(systemCreatedBy; Rec.SystemCreatedBy)
                    {
                        Caption = 'SystemCreatedBy';
                    }
                    field(systemId; Rec.SystemId)
                    {
                        Caption = 'SystemId';
                    }
                    field(systemModifiedAt; Rec.SystemModifiedAt)
                    {
                        Caption = 'SystemModifiedAt';
                    }
                    field(systemModifiedBy; Rec.SystemModifiedBy)
                    {
                        Caption = 'SystemModifiedBy';
                    }
                }
            }
        }
    }
    

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 Moderator on at
    RE: API: System Audit Date

    Maybe you can try to use the lastmodifedat field and see if that works.

    I see that is the field MS use in their standard API's.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: API: System Audit Date

    sorry BC version I am using is 16.5

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

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

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 228,520 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans