I have a web resource which is essentially an HTML page with a drop down list box on it.
This is displayed in a CRM form and looks very much like a native control.
When the CRM form is first loaded (always from a parent record) the Web Resource takes the ID value from a hidden Lookup (the parent):
var parentid = window.parent.Xrm.Page.getAttribute('new_myentitylookupid').getValue()[0].id;
It uses this to make decisions about what to display in the drop down.
Unfortunately, if a user choses to save and then clicks on the "New" button direct from the form this line fails to get an ID.
If the user Saves and Closes and then re-opens the form, all is well.
By the looks of it the related Lookup field is not populated when the New button is pressed. I should clarify that this form gets the ID the first time because we are adding a record to a parent entity "new_myentitylookup". I am surprised that this automation stops as soon as "New" button is used in this context.
Any ideas on what I can do here?