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;
  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: OnNewRecord trigger with xRec

    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
YUN ZHU Profile Picture

YUN ZHU 505 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 400

#3
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 384

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans