Hi guys!
This week I went through a really interesting problem, one of my clients was tired of having to use the recalculate button in Quotes and Orders, so he asked if we could automatize that process.
After several weeks of analysis, thousands of papers in the bin and millions of coffees… I came up with a solution, to be honest it was 1 hour, 1 coffee and 1 paper but I need to let them think that it was really complicated 😉
I saw that when the users click on the recalculate button, the form reloads, so I added a new product to a Quote and I press F5 to see what happens. Good News it got recalculated, so the only thing I needed to do was to refresh the Quote Form when something happens in the quote products.
My first approach was to create a JavaScript in the Quote Product Form to refresh the parent window (The Quote Form) on Save of the product.
Something like this:
This easy script worked perfectly when I added a new product line to the Quote or when I modified a product line. But when I deleted the line, the Quote form was not refreshed. That was a problem!!
So I went back to the critical moments of coffee, pen and paper, after doing a deep search using Bing (J) I found the following blog:
http://joegilldotcom.blogspot.co.uk/2011/06/crm-2011-how-to-refresh-form-after.html
It was the perfect solution so I quickly implemented it and tested….but it didn’t work….
The code was failing in the following line when loading the form:
function ContactLoad()
{
var grid = document.getElementById(“ExamResults”);
grid.attachEvent(“onrefresh”, ReLoadContact);
}
function ReLoadContact()
{
window.location.reload(true);
}
Grid was always null so it couldn’t attached anything. That was weird, because I saw the same solutions in different blogs. Until I realised the obvious, the solution was correct but out of date.
In Roll Up 5, Microsoft made some changes to the way the sub grids load in the form, I investigated that and I found that the grid was null because the control was not loaded yet.
So what is the solution?? PATIENCE!
Let’s make it wait a little bit and see what happens 😉 This is the final solution for the problem, tested with Roll Up 10:
Hope it solves someone’s life 😉
Cheers,
Mario
Hello,
Have you luck to use this code within rollup 12?
Do you have any solution for?
Update to be notified by e-mail.
Hi Diego,
No I haven’t tried this code in Rollup 12, but it should work, can you please give me more details about your problem, maybe we can solve it here 😉 What do you exactly want to achieve?
Cheers,
Mc
Hi there, I’m trying several options for crm 2013, more specifically for invoice products subgrid.
I’m having several problems when aplying the code to new invoices or when deleting products. Have you tested this code for this case?
Here’ s my code:
//inside onload event and only if it’s an update form!!! Not for new invoice
setTimeout(“SubGridRefresh();”, 2500);
function SubGridRefresh() {
var grid = document.getElementById(“invoicedetailsGrid”);
if (grid) {
grid.control.add_onRefresh(ReLoadForm);
}
}
function ReLoadForm() {
window.location.reload(true);
}
Cheers,
Pedro
Hello Pedro,
I haven’t tested this code in CRM 2013 but you have made me curious now. Let me give it a try during the weekend and I will come back to you 😀
Thanks,
Mario
This does not seem to work when you “remove” a record from a N:N view. I have a Many to Many relationship, where the user (from the parent entity) clicks on the N:N link in the left navigation, then selects the button “Add and Existing ….”. It works great on that, but if they decide to go back to the view and click the check box to remove it, the code doesn’t run. CRM does pop up a message confirming that I want to delete the record, but other than that… nothing. In fact, the form doesn’t even postback. I click on the Tab at the top to carry back to the Parent entity and nothing has changed in the grid. Thoughts?
We’re running CRM 2011