
Hi,
I have an iframe which needs the current record id when it's saved initially. So to get the id, I've written a script to refresh the form so iframe gets reloaded and retrieves the saved record id. This script gets triggered on 'onsave' event. This works well but the only con is it pops this below message box sometimes not always though.
"Your changes have not been savd. To stay on the page so that you can save your changes, click Cancel."
Here is the script:
function formRefresh()
{
setTimeout(function () {
// Call the Open Entity Form method and pass through the current entity name and ID to force CRM to reload the record
Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
}, 500);
}
So I've registered the same script to trigger on 'onchange' of modifiedon field instead of 'onsave'.
This is also working great without any popup messages. But the script runs on every update on the form. It loads the form when save is hit for every update.
So, I would like to know your suggestions on which route to take. I would like to go with second approach but visually it always loads the whole form which I am not sure how inconvenient to the users. Or is there any other best approach if you have implemented in your projects.. please let me know.
Thanks for any help.
*This post is locked for comments
I have the same question (0)You can check if the id of the record was available on form load or not. If it was available then you don't need to refresh the page as the iFrame already has the ID. If doesn't, then refresh the page.