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

Notifications

Announcements

No record found.

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,708 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
    95,750 Super User 2025 Season 2 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,092

#2
YUN ZHU Profile Picture

YUN ZHU 663 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 515

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans