I have an HTML web resource in CRM that is opened as an internal dialog (Xrm.Internal.openDialog).
I need to be able to get the parent entity's ID as well as several attributes for use in the dialog. During testing I noticed some unusual behavior that I have not been able to find a workaround for.
I can open the dialog from an Account and everything works as intended. If I then navigate to a different account and open the dialog I am unable to get the parent Account's ID and receive the following error. TypeError: Unable to get property 'entity' of undefined or null reference. If I press F5 and reload the page the dialog will work as intended and is able to get the parent Account's ID.
I am referencing ClientGlobalContext.js.aspx and creating my context when the page loads and then using the following code to get the parent Account entity reference.
this.Account = window.parent.frames[0].Xrm.Page.data.entity.getEntityReference();
How can I get this to work without the user having to reload the page each time they navigate to a different Account?
*This post is locked for comments