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

Issue regarding RunModal

(0) ShareShare
ReportReport
Posted on by 700

Hi Everyone,

My issue is regarding the RunModal method which I am using on a customized page.

I have written the following code on OnAction trigger of a button. Expectation is that, upon clicking 'YES' on the confirmation dialog box a page with some filters should get opened.

But in my case, when I hit the button for the first time, incorrect page is getting opened (the page on which I am currently) then I close the page and reopen it, this time correct page is there.

I am not able to figure out the reason behind this. Kindly provide me a quick solution to this !

Many Thanks...

code snippet-

                            if IsInProgress then begin
                       
                            if Confirm('Another task is in progress Timesheet no. %1, date %2, Line no. %3', true, TimeSheetNo, periodStart, LineNothen begin
                                T_Tracker_Rec.Reset();
                                Clear(T_Tracker_Rec);
                   
                                T_Tracker_Rec.SetRange("Job No.", "Job No.");
                                T_Tracker_Rec.SetRange("Time Sheet No.", TimeSheetNo);
                                T_Tracker_Rec.SetRange("Line No.", LineNo);
                                T_Tracker_Rec.SetRange(TimeSheetDate, periodStart);
                                T_Tracker_Rec.SetRange(FieldID, ColumnID);
                                if T_Tracker_Rec.FindFirst() then begin
                                    TimeTrackerPage.SetTableView(T_Tracker_Rec);
                                    TimeTrackerPage.SetRecord(T_Tracker_Rec);
                                    if TimeTrackerPage.RunModal() Action::LookupOK then begin
                                        TimeTrackerPage.GetRecord(T_Tracker_Rec);
                                    end;                             
                                end;
  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Issue regarding RunModal

    Still facing the same issue..For the first time, the page from which I am hitting the button is getting opened and when I repeat the process second time, it navigates me to the correct page..

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Issue regarding RunModal

    But what do you want to do? Here you're opening a page in a lookup mode.

    To open the TimeTrackerPage page by passing the filtered records (T_Tracker_Rec variable), you can do simply:

    T_Tracker_Rec.SetRange("Job No.", "Job No.");

    T_Tracker_Rec.SetRange("Time Sheet No.", TimeSheetNo);

    T_Tracker_Rec.SetRange("Line No.", LineNo);

    T_Tracker_Rec.SetRange(TimeSheetDate, periodStart);

    T_Tracker_Rec.SetRange(FieldID, ColumnID);

    TimeTrackerPage.SetTableView(T_Tracker_Rec);

    TimeTrackerPage.RunModal()

  • Dynamics 365 Business Central Profile Picture
    700 on at
    RE: Issue regarding RunModal

    Not lookup, it is written on the onaction trigger of a button..

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at
    RE: Issue regarding RunModal

    Code is not so clear. Are you doing a lookup? If so, this should work:

    T_Tracker_Rec.SetRange("Job No.", "Job No.");

    T_Tracker_Rec.SetRange("Time Sheet No.", TimeSheetNo);

    T_Tracker_Rec.SetRange("Line No.", LineNo);

    T_Tracker_Rec.SetRange(TimeSheetDate, periodStart);

    T_Tracker_Rec.SetRange(FieldID, ColumnID);

    TimeTrackerPage.SetTableView(T_Tracker_Rec);

    if TimeTrackerPage.RunModal() = Action::LookupOK then begin

    TimeTrackerPage.GetRecord(T_Tracker_Rec);

    end;                            

    end;

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 606 Super User 2025 Season 1

#2
Mansi Soni Profile Picture

Mansi Soni 463

#3
Sagar Dangar, MCP Profile Picture

Sagar Dangar, MCP 391

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans