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.

  • Suggested answer
    YUN ZHU Profile Picture
    81,849 Super User 2025 Season 1 on at
    RE: Get the default values from setup form

    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

  • peopleeater Profile Picture
    67 on at
    RE: Get the default values from setup form

    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
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: Get the default values from setup form

    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

  • Suggested answer
    Amit Baru Profile Picture
    3,029 on at
    RE: Get the default values from setup form

    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.

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,283 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,019 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans