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

SetFocus > working solution! But not for all fields!? (BC 19)

(0) ShareShare
ReportReport
Posted on by 144

Our users sometimes have to enter hundreds of order items. To optimize the input, I was asked whether the cursor should positioned on the "No."-field for each New Record.

The following solution seems to work without any problems - but unfortunately not for every field. And I can't find out why.

Javascript:

Microsoft.Dynamics.NAV.InvokeExtensibilityMethod('Ready','');

function SetFocusOnField(fieldNo)
{
    window.parent.document.querySelector(`[controlname^='${fieldNo}'] input`).focus()
}

PageExtension:

PageExtension 50323 "SalesOrderSubformEXT_HAL" extends "Sales Order Subform" //46
{
    layout
    {
        addlast(content)
        {
            usercontrol(SetFieldFocus; SetFieldFocus)
            {
                ApplicationArea = All;
                trigger Ready()
                begin
                    CurrPage.SetFieldFocus.SetFocusOnField('No.');
                end;
            }
        }
    }
    trigger OnNewRecord(BelowxRec: Boolean)
    begin
        CurrPage.SetFieldFocus.SetFocusOnField('No.');              // didn't work
        //CurrPage.SetFieldFocus.SetFocusOnField('Type');           // didn't work also
        //CurrPage.SetFieldFocus.SetFocusOnField('Quantity');       // but this works
        //CurrPage.SetFieldFocus.SetFocusOnField('Location Code'); // this - and many other fiels - working also
    end;
}


I can use SetFocus with many fields (e.g. "Location Code" and "Quantity")
But for the two fields "Type" and "No." it didn't work.

Does anyone have any idea how I can successfully move the cursor to the field "No."?

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.

    www.yammer.com/dynamicsnavdev

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

  • neckit Profile Picture
    144 on at

    Thanks for the hint but I can't find a way to use Yammer with dynamicsnavdev!

    When I go to the address, I'm on a login page. I can register there - but I don't receive an announced email confirmation (not even as spam). Or I can login with our company data and only get directly to our own yammer-pages but not to www.yammer.com/dynamicsnavdev.

  • BrianDev Profile Picture
    105 on at

    This sounds like a training issue. Normally when you used the tab key instead of the arrow keys the new new record parks the cursor in the correct field.

  • neckit Profile Picture
    144 on at

    Hi Brian,

    this is true for the last possible quick entry field. However, it is often not necessary to enter or change all the data in a data set. Then the down key is used, because otherwise you would have to press even more keys. Unfortunately, that doesn't solve our problem.

  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    Hi

    Just want to make sure I understand the challenge. Your team receive a SO with 100 items in it and they need to enter those order in BC. Hence, you are looking for faster "entry method" to enter these orders. 

    1) Is Edit in Excel and option? Like those orders have your part number or cross reference? This way your team can use Edit in Excel and copy and past. 

    2) Does your team only enter Item No and QTY? or something else. if it is only Item No and QTY is it possible to put the Item No as a first field and QTY as second. Then Exclude all other fields from Quick Entry? 

    pastedimage1656441529913v2.png

    pastedimage1656441474936v1.png

  • neckit Profile Picture
    144 on at

    For your understanding: there can be 5 item or 20 items or 10 items or 30 items per order. We have already created import pages for individual orders with even more items.

    We can't use Edit in Excel - but unfortunately it wouldn't speed up the input either.

    Often only a few fields are required for input, but unfortunately more fields are just as often required (e.g. the description + Price + other fields sometimes has to be changed and sometimes not).

    I don't think I have a chance with standard BC funds. In NAV 2013 we were able to solve this via WshShell and I was hoping that we could also do it via JS. And it would almost work - just not with No.

  • Suggested answer
    MahGah Profile Picture
    15,529 on at

    Hi

    Thanks for info and that gave me a better idea. I cannot think about any solution. But that just reminded me of two customization that I saw before. I just share them here but I am sure they are not useful.

    1) I saw a company that added a second No field to remove the drop/down function of base field. Then made the No base field populate from this new field. they wanted to enter the number and not system shows them. Maybe you can use this method if new field let you focus on the new field No.

    2) I saw another company that they designed their own Lines sub page to do some development but then let that new Line subform populate bc base lines.

    Thanks

  • BrianDev Profile Picture
    105 on at

    There is a property on the fields QuickEntry.  They default to true on all fields.

    You can set the properties to false and then the page will skip them when tabbing thru fields.

    Not sure if this helps.

  • neckit Profile Picture
    144 on at

    I'm still looking for a simpler solution or hoping someone can figure out why the JS solution doesn't work with "No.". But I'll keep your first adjustment in mind as a workaround. Thank you for the ideas.

  • Community member Profile Picture
    2 on at
    Maybe it's way too late for this reply, but in case you or someone visiting this page still need(s) a suggestion:

    I can't be sure, but maybe the problem is that you do not use the precise controlname referenced by 
     
    function SetFocusOnField(fieldNo)
    {
        window.parent.document.querySelector(`[controlname^='${fieldNo}'] input`).focus()
    }
    As you can see, the method above references some controlname. This, I believe has to be exactly the controlname as it appears in the HTML document loaded in the browser.

    In case of field "No.", try to leave out the "." which abbreviates the word. So simply try "No" - it's probable that the HTML document leaves out the "." in this case.

    In case of field "Type", I believe that it is once again a question of getting the right controlname. Maybe try "FilteredTypeField", as this is the name used in the Sales Order Subform for the most commonly used "Type" field - the one that is usually filled in by users. But you would have to verify that.

    Bottom line is you have to specify the precise controlname as it is present in the HTML document and from experience I can tell that in most cases this controlname is the name of the control as defined on the Page object (the first name you specify when you declare a field in a Page object). And that the HTML document usually drops the "." if this symbol is present in the name of the control in the Page object. 

    For example:

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,468

#2
YUN ZHU Profile Picture

YUN ZHU 923 Super User 2025 Season 2

#3
Sumit Singh Profile Picture

Sumit Singh 607

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans