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

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
    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

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 3,010

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,270 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,085 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans