Details
Sometimes we have requirement to open entity form or I will say refresh complete form from a custom dialog. Normally while we want to refresh complete form, we use Xrm.Navigation.openForm to open entity form. We can use following code to open entity form.
function OpenEntityForm(entityname,entityid)
{
var entityFormOptions = {};
entityFormOptions["entityName"] = entityname;
entityFormOptions["entityId"] = entityid;
// Open the form.
Xrm.Navigation.openForm(entityFormOptions).then(
function (success) {
console.log(success);
},
function (error) {
console.log(error);
});
}
In above code we can pass entity name and entity id, it will open entity records, this option works fine if we want to open entity form using command botton/ribbon button. But let’s say we have requirement to open entity form from a custom dialog? Let’s say we have custom dialog created using html web resource and when we will use this method to open entity form, it will show you below prompt.

Normally we get this prompt when there is any field dirty in the form and we are trying to navigate without saving form but in this case even though there is not field dirty we will get this dialog. To avoid this issue, we used following code to open entity form.
window.top.location.href = url;
While this is working fine to open entity form but it replaces the current navigation history so we can’t go back to it. Let me know if anyone have a better options.
Hope it will help someone !!
Keep learning and Keep Sharing !!