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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Get the default values from setup form

(0) ShareShare
ReportReport
Posted on by 67

Hi

I want to Insert some fields in my table from my setup table, as default fields for every new record.

Image

Currently, it is not getting the records from my Setup Table, as soon as I add the source type and move to the next field it gets records on my page.

Image

I have tried both OnInsert() in my table and OnInsertRecord() in my form, but it only works when the record is inserted into the table... when I leave the control that shows the primary key in the form.

// This is the code on my Card Page of above screenshot.
trigger OnInsertRecord(BelowxRec: Boolean): Boolean
var
uerRoyaltyAllocationParm: Record uerRoyaltyAllocationParameters;
begin
uerRoyaltyAllocationParm.Get();
Rec.uerCommLedgerDimensionAccount := uerRoyaltyAllocationParm.uerCommLedgerDimensionAccount;
Rec.uerAllocLedgerDimensionAccount := uerRoyaltyAllocationParm.uerAllocLedgerDimensionAccount;
Rec.uerBatchLedgerDimensionAccount := uerRoyaltyAllocationParm.uerBatchLedgerDimensionAccount;
end;

Is there any way or any other method to initialize the values before I insert the primary key.. as we do with the Init method of D365F&O?

Thanks.

I have the same question (0)
  • Suggested answer
    Amit Baru Profile Picture
    3,037 on at

    Hi,

    Pls write code on Table trigger

    trigger OnInsert()
    var    
    uerRoyaltyAllocationParm: Record uerRoyaltyAllocationParameters;
    begin
           uerRoyaltyAllocationParm.Get();
         Rec.uerCommLedgerDimensionAccount := uerRoyaltyAllocationParm.uerCommLedgerDimensionAccount;
         Rec.uerAllocLedgerDimensionAccount := uerRoyaltyAllocationParm.uerAllocLedgerDimensionAccount;
         Rec.uerBatchLedgerDimensionAccount := uerRoyaltyAllocationParm.uerBatchLedgerDimensionAccount;
       end;
    Regards
    Amit Sharma
    linkedin.com/in/amit-sharma-94542440/
    Press Yes if info is useful.

     

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    You can use the Install codeunit functionality in Business central, it help you insert the default data as you load any company in any of the tenant. Please refer the below link how to use that.

    docs.microsoft.com/.../devenv-extension-install-code

  • peopleeater Profile Picture
    67 on at

    Hi Amit Sharma,

    As I've mentioned in the post I have tried both ways, at first, I tried using the OnInsert() event on my table, but it gives the same result as OnInsertRecord() on my form.

  • Suggested answer
    YUN ZHU Profile Picture
    100,212 Super User 2026 Season 1 on at

    Hi, This looks like a Setup page.

    So I think you can try to use OnOpenPage() trigger of this setup page.

    More details: https://yzhums.com/8924/

    Hope this helps.

    Thanks.

    ZHU

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,012 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 986 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 659 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans