Skip to main content

Notifications

Announcements

No record found.

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

  • Suggested answer
    Focus is not set to first field in card page
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Focus is not set to first field in card page

    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

  • Clemens Linders Profile Picture
    Clemens Linders 70 on at
    RE: Focus is not set to first field in card page

    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

  • Meik Cremer Profile Picture
    Meik Cremer 5 on at
    RE: Focus is not set to first field in card page

    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
    Clemens Linders 70 on at
    RE: Focus is not set to first field in card page

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Focus is not set to first field in card page

    You can also try jQuery based method:

    $(document).ready(function() {

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

    });

  • Clemens Linders Profile Picture
    Clemens Linders 70 on at
    RE: Focus is not set to first field in card page

    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
  • Clemens Linders Profile Picture
    Clemens Linders 70 on at
    RE: Focus is not set to first field in card page

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Focus is not set to first field in card page

    You can also try jQuery based method:

    $(document).ready(function() {

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

    });

  • Clemens Linders Profile Picture
    Clemens Linders 70 on at
    RE: Focus is not set to first field in card page

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans