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."?