This project has moved. For the latest updates, please go here.

Refresh After Create New Question

Apr 14, 2016 at 3:21 PM
Hi! Thanks for creating a great product. I think it will be very useful for a lot of applications.

I have a situation where I am creating some child records for an entity using a workflow on the entity create. The records are being created properly, but they don't display in the editable grid until I refresh the form. Is there a way to have the grid display automatically?

I do have the "Refresh after create new" checkbox created.

Thanks!

Mark
Coordinator
Apr 15, 2016 at 6:53 PM
Hi,

Please add the following function (using a web resource) to the entity's form on save. After a new record is saved, a timer will refresh the grid which should display the data.
function FormOnSaveHandler() {
      // If the record is new and being saved
    if(Xrm.Page.ui.getFormType() == 1) {
      // Set up a timer to refresh the grid
        setTimeout(function() {
     // Replace webresourcename with the name of the web resource (grid)
            var wrControl = Xrm.Page.ui.controls.get("webresourcename");
            wrControl.setSrc(wrControl.getSrc());
     // 1.5 seconds delay, you may need to increase the timer delay
        }, 1500);
    }
}
BTW, "Refresh after create new" only applies to records created using the grid new button (+) and not the parent form. For example, you have a workflow that fires when a new record is created which performs some calculations/... and then updates the new record's field(s). In this case, you want the grid to refresh after creating the record to display the result of the workflow.

Thank you
Sep 12, 2016 at 5:25 AM
I have tried to use the script you provided. But it doesn't work.
Developer
Sep 19, 2016 at 6:25 AM
Which version of CRM are you working on? The above script works as specified and i have been using that for sometime now
Sep 21, 2016 at 3:43 PM
Edited Sep 21, 2016 at 3:45 PM
CRM 2016 8.1.0.512

Second, I hit the error of code: 2147220991 Message : Invalid XML.

what is it about?
Developer
Sep 22, 2016 at 7:30 AM
Can you increase the timeout duration in the script and check again, Also Require more details on the error, so please help to get developer tools using f12 key and copy the screen where this error is shown in console window and post it here
Coordinator
Oct 26, 2016 at 7:22 PM
Hi,

As of v1.0.5.0, I have added a fix that should refresh the grid when a new form is saved.

Thank you,
Mehrdad