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

Notifications

Announcements

Community site session details

Community site session details

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

Setting focus to first field on card page

(0) ShareShare
ReportReport
Posted on by 70

LS,

I created a simple card page and table. When I run this in D365BC the focus is set to the fifth visible field (Preferred language).

No fields are mandatory (I understood D365BC sets the focus to the first mandatory field).

I tried seting the first field as mandatory, but that didn't help.

In this forum there is a solution that uses Xrm.Page.getControl(controlName).setFocus();

But Xrm has bee depreciated plus it uses a function and I cannot create a function in D365BC.

Can anybody tell me how I can get D365BC to set the first field as focused?

My card page:

page 50144 "Staff Card NED"
{
    PageType = Card;
    ApplicationArea = All;
    UsageCategory = Administration;
    SourceTable = StaffNED;

    layout
    {
        area(Content)
        {
            group(General)
            {
                Caption = 'Naam:';
                field(RecordNumber; RecordNumber)
                {
                    ApplicationArea = Basic;
                    Importance = Promoted;
                    Visible = false;
                }

                field(FirstName; FirstName)
                {
                    ApplicationArea = Basic;
                }

                field(LastName; LastName)
                {
                    ApplicationArea = Basic;
                }

                field(FullName; FullName)
                {
                    ApplicationArea = Basic;
                    Editable = false;
                }

            }
            group(etc)
            {
                Caption = 'Overige gegevens:';
                field(Email; Email)
                {
                    ApplicationArea = Basic;
                }

                field(PreferredLanguage; PreferredLanguage)
                {
                    ApplicationArea = Basic;
                }

                field(Department; Department)
                {
                    ApplicationArea = Basic;
                }
            }
        }
    }

    trigger OnOpenPage()
    begin

    end;

}

My table:

table 50124 StaffNED
{
    DataClassification = ToBeClassified;

    fields
    {
        field(1; RecordNumber; Integer)
        {
            AutoIncrement = true;
            DataClassification = ToBeClassified;
        }

        field(5; FirstName; Text[50])
        {
            Caption = 'First name';
            DataClassification = ToBeClassified;

            trigger OnValidate()
            var
            begin
                FullName := FirstName + ' ' + LastName;
            end;
        }

        field(10; LastName; Text[50])
        {
            Caption = 'Last name';
            DataClassification = ToBeClassified;

            trigger OnValidate()
            var
            begin
                FullName := FirstName + ' ' + LastName;
            end;
        }

        field(15; FullName; Text[101])
        {
            Caption = 'Full name';
            DataClassification = ToBeClassified;
        }

        field(20; Email; Text[50])
        {
            Caption = 'E-mail';
            DataClassification = ToBeClassified;
        }

        field(25; PreferredLanguage; Text[2])
        {
            Caption = 'Preferred language';
            DataClassification = ToBeClassified;
            TableRelation = AwsLanguage.ShortName;
        }

        field(30; Department; Text[50])
        {
            Caption = 'Department';
            DataClassification = ToBeClassified;
            TableRelation = if (PreferredLanguage = const('NL'))
                                SelectionListNL.SelectionContent where(SelectionGroupName = Const('Department'), ApplicationName = Const('KIP'))
            else
            if (PreferredLanguage = const('DE'))
                                SelectionListDE.SelectionContent where(SelectionGroupName = Const('Department'), ApplicationName = Const('KIP'))
            else
            if (PreferredLanguage = const('EN'))
                                SelectionListEN.SelectionContent where(SelectionGroupName = Const('Department'), ApplicationName = Const('KIP'));
        }
    }

    keys
    {
        key(PK; RecordNumber, FullName, PreferredLanguage)
        {
            Clustered = true;
        }
    }

    var
        myInt: Integer;
        PageLanguage: Record AwsLanguage;

    trigger OnInsert()
    begin
        PageLanguage.SetFilter(ShortName, 'NL');
        if (PageLanguage.FindFirst()) then
            PreferredLanguage := PageLanguage.ShortName;
    end;

    trigger OnModify()
    begin

    end;

    trigger OnDelete()
    begin

    end;

    trigger OnRename()
    begin

    end;
}

I hope someone is able to help me.

Kind regards,

Clemens Linders

I have the same question (0)
  • Clemens Linders Profile Picture
    70 on at

    Hi Ebramhana,

    I am afraid you responded to the wrong topic, I cannot place your question with regards to this topic.

    Kind regards,

    Clemens Linders

  • Ebramhana Profile Picture
    on at

    Hello,

    Let me start by saying how great your work is I really learn a lot from you. 

    If you don't mind me asking this error appears to one of our users and one only, how come this error relates to bad data and only one user is getting the error?

    would you be able to provide any tips or tricks on how I can start troubleshooting the error for this specific user?

  • Suggested answer
    THE Italian Profile Picture
    on at

    This is currently not possible.

    Just FYI, first time I have heard this request was dated back to EMEA Directions in Prague (in 2016, probably) where partner was asking the same in relation of universal app (phone client). Actually this was not possible because some devices, when setting the focus anywhere in the app were throwing the keyboard automatically.

    That is why it has never been implemented up to now.

    This is a good candidate for IDEAS site. You could vote for some existing ones that have this problem in different flavors

    experience.dynamics.com/.../

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

News and Announcements

Season of Giving Solutions is Here!

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 1,513

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 742 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 706 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans