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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

OnNewRecord trigger with xRec

(0) ShareShare
ReportReport
Posted on by 76

Hello,

I'm on the latest version of Business Central. I extended the Purchase Invoice page. In the OnNewRecord trigger, I am trying to get the record before the blank new record is loaded. In the past in NAV, we used xRec to achieve this. Now, I get another record instead of the one on the page before clicking the new button. Has there been any changes with how xRec is used in Business Central? How do I capture a record that is displayed before pressing the new button on the page? In my case when there are two records No. 1 and 2, when record No. 1 is loaded on the page, and I click the new button to create a new invoice, xRec is No. 2 for some reason, I would expect it to be record No. 1? Any advice would be appreciated. Thanks.

Below is my code

    trigger OnNewRecord(BelowxRec: Boolean)
    var
        recRef: RecordRef;
    begin

        FldSetCurrentScreen();
        recref.GetTable(xRec); //this is now No.2 when the last displayed was No.1 before pressing new plus button
        IndexRecord(recRef);
    end;
I have the same question (0)
  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    dynamicsuser.net/.../developers

    I will open this up to the community in case they have something to add.

    Thanks.

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,556 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,028 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 877 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans