Issue with creating a new record when filters are set on a page - Business central

AdrianM
Member Posts: 1
Hello,
I have noticed a problem in Business Central in that when I want to insert a new record on the page, there is a "reload" and the first record is selected/highlighted instead of a new blank record in which I can put the new values. The problem appears in BC15 and higher when there is a filter set on the date type field. When I click on the new record again, the “reload” doesn’t take place.
This happens when I click "New" action or when I click on the last empty row.

I have created a simple case where I could test this behavior.
I added new "Date" field to the customer table:
And I have created new page that contains only one action and onOpenPage trigger:
I have a global data type variable - "G_RefDate" that I use to filter the "New Date" field. On the onOpenPage trigger I set a default value of the G_RefDate and filter records using SetRange. The action decreases G_RefDate by one month and sets the filter again.
I noticed that after removing Rec.SetRange("New Date", G_RefDate); from the trigger, the problem doesn't occur but then I obviously don't have filtered records when I open the page.
Has anyone had a similar problem and know a possible solution? thanks in advance
I have noticed a problem in Business Central in that when I want to insert a new record on the page, there is a "reload" and the first record is selected/highlighted instead of a new blank record in which I can put the new values. The problem appears in BC15 and higher when there is a filter set on the date type field. When I click on the new record again, the “reload” doesn’t take place.
This happens when I click "New" action or when I click on the last empty row.

I have created a simple case where I could test this behavior.
I added new "Date" field to the customer table:
tableextension 5001 "cust Ext" extends Customer { fields { field(9010; "New Date"; Date) { Caption = 'New Date'; DataClassification = ToBeClassified; Editable = true; } } }
And I have created new page that contains only one action and onOpenPage trigger:
page 5001 "test new rec customer2" { ApplicationArea = All; Caption = 'test new rec customer2'; PageType = List; SourceTable = Customer; UsageCategory = Lists; layout { area(content) { repeater(General) { field("No."; Rec."No.") { ApplicationArea = All; ToolTip = 'Specifies the number of the customer. The field is either filled automatically from a defined number series, or you enter the number manually because you have enabled manual number entry in the number-series setup.'; } field("Location Code"; Rec."Location Code") { ApplicationArea = All; ToolTip = 'Specifies from which location sales to this customer will be processed by default.'; } field(Name; Rec.Name) { ApplicationArea = All; ToolTip = 'Specifies the customer''s name.'; } field(Contact; Rec.Contact) { ApplicationArea = All; ToolTip = 'Specifies the name of the person you regularly contact when you do business with this customer.'; } field("Currency Code"; Rec."Currency Code") { ApplicationArea = All; } field("New Date"; "New Date") { ApplicationArea = All; Editable = true; } } } } actions { area(processing) { action("FilterDate") { ApplicationArea = All; Caption = 'Filter Date'; Promoted = true; PromotedCategory = Process; PromotedIsBig = true; trigger OnAction() begin G_RefDate := CalcDate('<-1M>', G_RefDate); Rec.SetRange("New Date", G_RefDate); end; } } } trigger OnOpenPage() begin // Filter Date G_RefDate := DMY2Date(6, 10, 2023); Rec.SetRange("New Date", G_RefDate); // this makes problem end; var G_RefDate: Date; }
I have a global data type variable - "G_RefDate" that I use to filter the "New Date" field. On the onOpenPage trigger I set a default value of the G_RefDate and filter records using SetRange. The action decreases G_RefDate by one month and sets the filter again.
I noticed that after removing Rec.SetRange("New Date", G_RefDate); from the trigger, the problem doesn't occur but then I obviously don't have filtered records when I open the page.
Has anyone had a similar problem and know a possible solution? thanks in advance
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions