How to refresh or navigate to Entity View

In some scenarios we all have to refresh or navigate to specific entity view after a particular action performed. We can use a method called navigateTo() for this requirement. This method is available under new Namespace Navigate.

Syntax:

Xrm.Navigation.navigateTo({ pageType, entityName, viewId, viewType }).then(successFunction, errorFunction);

  1. pageType: Specify “entitylist”.
  2. entityName: Provide the logical name of the entity.
  3. viewId (Optional): Provide the Guid of the view to load. If you don’t provide it, it will navigate to the default view of an entity.
  4. viewType (Optional): Provide the Type of the view to load. For ex: “savedquery” or “userquery”. It is required only if you want to navigate to a specific view.

Example:

  • Without View Id:

Xrm.Navigation.navigateTo({ pageType: “entitylist”, entityName: “account” }).then(
function (result) {
//Success code
},
function (error) {
//Error code
}
);

  • With View Id:

Xrm.Navigation.navigateTo({ pageType: “entitylist”, entityName: “account”, viewId: “4ec687fd-9858-4e8c-b267-63add9769d77”, viewType: “savedquery” }).then(
function (result) {
//Success code
},
function (error) {
//Error code
}
);

Note: At the moment, this method is supported only on the Unified Interface

Hope it is helpful…..