Hi,
We are using a HTML webresource to show some the attribute values of the CRM record on the entity form.
In CRM 2011, when ever we save the record the form used to reload and webresource also refreshes and get the latest data. But in CRM 2013 and later, on the save of the record the form won't reload and as a result the values on the HTML resources were not getting refreshed.
The solution is to refresh the webresource using JavaScript on the Save Event of the form.
function refreshHTMLWebResource() {
var webResourceControl = Xrm.Page.getControl("WebresourceName");
var src = webResourceControl.getSrc();
webResourceControl.setSrc(null);
webResourceControl.setSrc(src);
}
Hope this helps.
--
Happy CRM'ing
Gopinath.
We are using a HTML webresource to show some the attribute values of the CRM record on the entity form.
In CRM 2011, when ever we save the record the form used to reload and webresource also refreshes and get the latest data. But in CRM 2013 and later, on the save of the record the form won't reload and as a result the values on the HTML resources were not getting refreshed.
The solution is to refresh the webresource using JavaScript on the Save Event of the form.
function refreshHTMLWebResource() {
var webResourceControl = Xrm.Page.getControl("WebresourceName");
var src = webResourceControl.getSrc();
webResourceControl.setSrc(null);
webResourceControl.setSrc(src);
}
If you are on Dynamics 365, check this link for refreshing Iframe.
Hope this helps.
--
Happy CRM'ing
Gopinath.
Thanks. But on CRM 2015, this technique doesn't work anymore for me. when you need the record id (by Xrm.Page.data.entity.getId()), it only works with a setTimeout. Do you know an another way to get the record id in the OnSave handler?
ReplyDeleteThanks. But on CRM 2015, this technique doesn't work anymore for me. when you need the record id (by Xrm.Page.data.entity.getId()), it only works with a setTimeout. Do you know an another way to get the record id in the OnSave handler?
ReplyDeleteI didn't get the correct question, can you please explain in detail.
ReplyDeleteIf you create a new record, and onsave you want to refresh your webresource. If your webresource needs to access Xrm.Page.data.entity.getId(), on CRM 7.0 it will return "". There are 2 ways to fix this, setTimeOut in the onsave handler (-> not clean), add modified on on the form and onChange of this field, apply your code, in the onChange handler I have access to Xrm.Page.data.entity.getId() without having to use a setTimeOut
ReplyDeleteI found in CRM 2015 that if you modify the string returned by the getSrc by adding a dummy parameter, then the setSrc will force a refresh of the HTML web resource:
ReplyDeletevar webResourceControl = Xrm.Page.ui.controls.get(WebResourceNm);
var websrc = webResourceControl.getSrc();
websrc = websrc + "%26reload%3dyes";
webResourceControl.setSrc(websrc);
This works from the onchange event of a field in the parent form.
Thanks for posting it here.
DeleteHi Patrick Bodayle,
DeleteThis is a clean solution.
In our case we have Silverlight webresource on entity form which needs to be refreshed on form save. We have used the above logic but it dint refresh. Andy idea here to guide.
Thank you.
Try this:
Deletefunction refreshIframe(name) {
var webResourceControl = Xrm.Page.getControl(name);
var src = webResourceControl.getSrc();
webResourceControl.setSrc(null);
webResourceControl.setSrc(src);
}
Thank you for commenting Navas, updated the post accordingly.
DeletePatrick - You sir. Just made my day.
ReplyDeletewe tried to refresh the webresource using both ways setSrc(null) - setSrc(getSrc) or add new parameter to src. However we cannot then save the record.
ReplyDeleteError:
Can't execute code from a freed script
Please help
Are you able to solve the issue?
DeleteThanx for the code.It works perfect
ReplyDeletesuper its working
ReplyDeleteHey Hi, I have a similar requirement, please help me out.
ReplyDeleteI have a customl html page on a form. If entity is updated then plugin will fired ,and it will calls the webservice and gets the data, through plugin creating the new records. This new records, I have to stamp on the html grid, without refreshing the crm form.
When page is refreshed ,its html querying crm and stamping the data, but at a time plugin exexution completez,its not binding the data, everytime aftr plugin execution ,once refresh its load otherwise its not loading.
I would like to use this for refreshing a webresource that we have in the header, particularly the CRM2013 Horizontal Headers HTML. Does anyone know if it can be done? I am currently trying the below, but I am told it is undefined as the error.
ReplyDeletefunction refreshHTMLWebResource() {
var webResourceControl = Xrm.Page.getControl("header_Webresource_Name");
var src = webResourceControl.getSrc();
webResourceControl.setSrc(null);
webResourceControl.setSrc(src);
}