Asked by:
Refreshing the form after saving - CRM 2013

Question
-
Hi all
I need to refresh the CRM form after saving successfully an entity, because a picklist will be reloaded depending on changing values. I need to refresh the form to get this working. This can not be done on the onsave method because this is executed before saving, and I need to be sure that the entity has been saved successfully (no plugins raising exceptions). Any ideas about how to do this with CRM 2013?
Thanks in advance
Tuesday, March 11, 2014 7:34 AM
All replies
-
Hi Gabriel,
Once you save an entity record, its form it automatically refreshed. Are you trying to save a related entity and have the parent entity form reloaded?
Tuesday, March 11, 2014 9:32 AM -
You can give this a try
window.location.reload(true);
Tuesday, March 11, 2014 9:52 AM -
http://msdynamicscrmblog.wordpress.com/2013/12/11/get-form-types-and-modes-in-dynamics-crm-2013/
after saving the record the form has been refresh the check the form type or form mode based on that execute ur script
ms crm
- Edited by Reddy A Tuesday, March 11, 2014 11:21 AM
Tuesday, March 11, 2014 11:20 AM -
set the function onChange event of the picklist to refresh the form.
function reloadForm()
{
window.location.reload(true);
}
Mark as answer if it works for you.Tuesday, March 11, 2014 2:01 PM -
Hi Gabriel,
After saving the form, CRM itself refreshes the form. I didn't get you question exactly why you need to refresh it again? Even we refresh it again, the same code executes. What does it makes the difference if we reload once, twice or thrice.
Gopinath
http://mscrmtechie.blogspot.com
- Edited by Gopinath Reddy Wednesday, March 12, 2014 5:33 AM
Wednesday, March 12, 2014 5:32 AM -
I think the form is not reloaded after saving.
Values available for this dropdonw are configured on onload method depending on current value. If I change current value, new values should be available and they are not. I can not use onsave form event because this occurs before saving. If a plugin validation is raises, form status gets inconsistent. So I would need to refresh the form if we are successful. I think business rules has the same refresh problem with plugin validations. Any ideas?
Thanks in advance
Tuesday, March 18, 2014 8:21 AM -
Hi,
Fields (when values have been changed) are disabled ?
If yes, you can try to this :
Xrm.Page.getAttribute("THE ATTRIBUTE NAME WHEN THE VALUE CHANGE").setSubmitMode("always");
Did you try to debug in the onLoad event to be sure after a save that your function is called ?
Is it possible to see the code ?
Regards,
Jean-Michel
Tuesday, March 18, 2014 3:21 PM -
Maybe, you can try to refresh datas by this way :
Xrm.Page.data.refresh();
Window.location... is not supported in MSCRM 2013.
Regards,
Jean-Michel DOS-SANTOS
Tuesday, March 18, 2014 3:28 PM -
I have added an alert when form is loaded and nothing happens after saving. I would need to force form reload.
About this kind of lines:
Xrm.Page.data.refresh();
What I really need is where to place it. The only event I know is onsave, but this happens before saving, and I need to reload after saving if this was successful.
Regards
Wednesday, March 19, 2014 11:08 AM -
Hi Gabriel,
The CRM OOB functionality forces a page to reload automatically after saving. If it's not reloading, can you check if the record is actually being saved at all? That's because it might be an issue where the record is not getting saved at all due to some script error on save, which is why you don't see the reload. Do you have anything wired up on save, plugins, workflows, scripts that might cause it?
Wednesday, March 19, 2014 11:41 AM -
Here is my current approach, still not working
Basically, when the form is saving:
- Stop OOTB save process.
- Launch a saving process programatically
- Add callbacks to take actions on success and on failure.
I have tried this but callbacks are not being fired. Any ideas? Something wrong here?
var counter = 0;
function Case_OnSave(econtext) {
if(counter == 0){
var eventArgs = econtext.getEventArgs();
eventArgs.preventDefault();
counter = counter + 1;
Xrm.Page.data.save().then(
function () {
counter = 0;
//Do your success logic here
},
function (errorCode, message) {
counter = 0;
Xrm.Page.data.refresh();
}
);
}
}Tuesday, March 25, 2014 3:02 PM -
I would try this approach. Add an action on “Save” button using Ribbon Work Bench that triggers the following java script.
RefreshPage = function ()
{
window.top.location.reload(true);
}
- Edited by Anna' Tuesday, March 25, 2014 11:00 PM
Tuesday, March 25, 2014 10:59 PM