Still Using Xrm.Page in Dynamics 365 CRM? ๐Ÿค”

If your answer is yes… you should know that Microsoft now recommends using formContext instead of Xrm.Page.

So what’s the difference?

  • ๐Ÿ”น Xrm.Page: the old (Legacy) way. It worked directly on the whole form. It might still work in some scenarios, but it’s not the right choice for new projects.
  • ๐Ÿ”น formContext: the modern way. It lets you work with the current form only. It works well with Main Forms, Quick Create, and Editable Grid. This is the approach Microsoft recommends.

๐Ÿค” So why do we check for executionContext?

You need to make sure the Parameter is actually being passed to the function, avoid an Error showing up if someone forgot to enable “Pass execution context as first parameter”, and keep the code stable and future-proof with the form. Best Practice: always use formContext, always pass execution context as the first parameter, and always check before using it.

Leave a Reply