How to implement Post / Redirect / Get a template in a custom CRM 2011 window

I created a custom "Resolve Case" window that replaces the CRM default permission resolution window. I did that I replaced the Resolve Case ribbon button with my own button, which opens a custom HTML page when clicked. Then, when the user clicks the Resolve button on this page, a SOAP message is generated to resolve this particular case. After the SOAP message, I call window.close () to close the Allow Case window. After that, I call location.reload (), so that the main form reloads and the feed is updated. This way it works (in a user perspective), as does the default permission window.

Now here is the problem. If the user, after resolving the case, reactivates it, and then resolves it again, I get the following message (pop-up warning from the browser):

"To display the web page again, the browser needs to resend the information that you previously sent. If you made a purchase, you must click Cancel to avoid duplicate transactions. Otherwise, click Retry to display the web page again . "

I found that the problem is that I used location.reload () to reload the main form and thus the form is duplicated. I tried using window.location = window.location, location.href = location.href, etc. Instead of location.reload (), but none of them work for me. They seemed to update the main form (at least it blinked), but the tape did not update. I also tried using Xrm.Page.ui.refreshRibbon (), but that didn't matter either.

I was looking for a solution from the Internet and people are talking about the Post / Redirect / Get pattern. I could not find clear examples of how to implement it, although I was hoping that if you help me understand this and how to use it in this particular case.

If necessary, additional information and code samples will be provided.

+3
1

, ( ):

// Open form with same record.
var newWindow = Xrm.Utility.openEntityForm(entityName, entityId);

// After rollup 12, this function returns a boolean instead of
// the window object.
if (typeof newWindow === 'boolean') {
    // The name of the window, when the record is not new, is equal to the record GUID,
    // without {, } or - characters. When it is equal, were done. Otherwise, close
    // the current window.
    if (window.top.name.toLowerCase() === entityId.replace(/[\{\}\-]/gi, "").toLowerCase()) {
        return;
    }

    Xrm.Page.ui.close();
    return;
}

// Before rollup 12, the function returns a window object. Compare the window objects.
// When they're not equal, close the current window.
if (newWindow.top !== window.top) {
    Xrm.Page.ui.close();
    return;
}

, .

0

All Articles