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

Focus is not set to first field in card page

(1) ShareShare
ReportReport
Posted on by 70

LS,

I created a simple table and card page.

I would have expected the first visible field (First name) to receive focus, but in stead the field Preferred language receives focus.

Looking for an answer I found that D365BC now puts the focus on the first mandatory field, but the field Preferred language is not mandatory.

Setting ShowMandatory on the card page for the First name field didn't help as well.

The 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;
        }
    }
}

This is the 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;
                }
            }
        }
    }
}
pastedimage1585303201264v1.png

How can I set the focus on the field First Name when the card page opens?

Kind regards,

Clemens Linders

I have the same question (0)
  • Suggested answer
    Andy Sather 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.

     

    https://www.yammer.com/dynamicsnavdev#/home

    https://dynamicsuser.net/nav/f/developers

     

    I will open this up to the community in case they have something to add.

  • Clemens Linders Profile Picture
    70 on at

    Hi Andy,

    I tried subscribing at both forums without any luck. I do not get the email to which I can reply and thus complete my subscription.

    We are part of a German multi-national and our network (although we are in the Netherlands) goes through Germany.

    Perhaps they see a discrepancy between the countries, also our mother company has some very strict filters and many spam doesn't even arrive in our spam box.

    I also have a personal yahoo account, which I tried to register from home, but no luck there as well. Perhaps these forums block yahoo accounts??

    As mentioned I tried this for both forums. With 99,9% of all other forums, I have no problems registering.

    Last but not least I tried to email admin@dynamicsusers.net but I got no reply.

    Searching the internet I found more people had this problem.

    Perhaps you can be of some assistance.

    Kind regards,

    Clemens Linders

  • Community Member Profile Picture
    on at

    You can also try jQuery based method:

    $(document).ready(function() {

       $('form:first *:input[type!=hidden]:first').focus();

    });

  • Clemens Linders Profile Picture
    70 on at

    Hi Lewis,

    Can you tell me where exactly I would put this code. I assume you mean the card page, but where.

    It will not let me insert this code (without errors) in the OnInsert trigger.

    Kind regards,

    Clemens Linders

  • Clemens Linders Profile Picture
    70 on at

    Hi Lewis,

    I created a controlAddin: AjaxAddIn:

    controladdin AjaxAddIn
    {
        RequestedHeight = 300;
        MinimumHeight = 300;
        MaximumHeight = 300;
        RequestedWidth = 700;
        MinimumWidth = 700;
        MaximumWidth = 700;
        VerticalStretch = true;
        VerticalShrink = true;
        HorizontalStretch = true;
        HorizontalShrink = true;
        Scripts = 'ajax.aspnetcdn.com/.../jquery-3.4.1.js';
        StartupScript = 'startupScript.js';
        event MyEvent()
        procedure MyProcedure()
    }
    After that I created a file startupScript.js:
    $(document).ready(function() {
        $('form:first *:input[type!=hidden]:first').focus();
     });
    Both files are located in the root.
    When I publish this, it didn't work.
    What am I doing wrong.
    Kind regards,
    Clemens Linders
  • Community Member Profile Picture
    on at

    You can also try jQuery based method:

    $(document).ready(function() {

       $('form:first *:input[type!=hidden]:first').focus();

    });

  • Clemens Linders Profile Picture
    70 on at

    Hi Lewis,

    I did try to use your jquery based method.

    But apparently I am using it in the wrong place or whatever.

    Can you please give me a small complete example of a card page where you use this.

    Kind regards,

    Clemens Linders

  • Meik Cremer Profile Picture
    5 on at

    Hi Clemens,

    did you solve this problem? I am struggling with this problem too and would appreciate any help.

    Kind regards,

    Meik Cremer

  • Clemens Linders Profile Picture
    70 on at

    Hi Meik,

    Unfortunately I was not able to solve this. We more or less had to lurn to live with this.

    So if you ever find a way to solve this, please let me know.

    Kind regards,

    Clemens Linders

  • Community Member Profile Picture
    on at

    Just thought i'd check if anyone has had any further luck? I'm doing a factory floor BC worksheet page and i need focus to be in a particular field so they can use a scanner to input a value. Its proving to be much more difficult than expected. I have tried quick entry and similar properties but no luck. I'm on BC 17.6

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 2,990

#2
Jainam M. Kothari Profile Picture

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

#3
YUN ZHU Profile Picture

YUN ZHU 1,028 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans