Set Focus to First Field on Form in Dynamics 365

Dominic Jarvis, 03 April 2018

Time was, when creating a record  , the first field on the form was the one that the focus was set to. Now, in Dynamics 365 the focus is set to the first mandatory field on the form . For people that are used to using forms as they have been in CRM, this can be quite the annoyance. Fortunately, it’s possible to (in a supported way) set focus to fields through the Xrm.Page api.


Further to that, it’s possible to make this method very generic, so no matter what form this is run on, as long as the first control on the form is a field. This can be very handy for users that are used to older systems, or need to enter data quickly.

This is can be very easily incorporated into an ‘On Load’ function. When creating this method, it’s a good idea to run a generic clear notifications function on the other controls on the form. This will prevent an error from being raised by Dynamics 365 informing the user that the required field must be filled.


The setFocus() function is a handy function, and can be used to improve user experience when used well. Used in conjunction with effective notifications and error handling, it can help to control and optimise the flow of the application.