1

SEE SOLUTION AT BOTTOM OF QUESTION SINCE I WAS ABLE TO ANSWER IT ON MY OWN

I have a VF page that overrides the Opportunity view page, this is so that I can implement my own product related list. The related list has a Delete link that fires a delete of the opportunity line and also fires a trigger that calls a class method to perform an summary calculation up to the opportunity for some fields.

My problem comes because the Delete link fires this delete action but yet the page reloads BEFORE the opportunity update is completed. This causes the end user to see the "old" opportunity values even though they are being updated. This is true since a second refresh will show the updated opportunity values. What I need is for the Opportunity to be displayed AFTER it is updated and not before. See code below:

Opportunity View Override VF page code:

<apex:column headerValue="Action" style="text-align:center;width:50px;">
            <apex:outputLink target="_blank" title="Click to view record details (new tab/page)" value="/{!oli.id}">
                View  
            </apex:outputLink>
            <apex:commandLink title="Click to delete record" action="{!del}" styleClass="DelBTN" >
                Delete
                 <apex:param name="delname" value="{!oli.id}" assignTo="{!delOLIid}"/> 
            </apex:commandLink>
        </apex:column>

Controller:

 public PageReference Del () {
    if(delOLI!= null) {
    Delete delOLI;
    getOppFieldAndHistory(opp);
    queryOLIs(opp.id);
    }
    return null;
}

Please let me know if you have any input into this issue...

UPDATED SOLUTION:

I found the solution so posting in hope that it may help some other lost soul. Basically I added a Page reference to the view of the Opportunity (see updated code below), whereas before I was simply letting the page refresh by not providing any rerender attribute.

public PageReference Del () {

    if(delOLI!= null) {
    Delete delOLI;
    getOppFieldAndHistory(opp);
    queryOLIs(opp.id);
    }
    PageReference oppPage = new ApexPages.StandardController(opp).view();
    oppPage.setRedirect(true);
    return oppPage;
}
2
  • not too sure if this would work can u try adding oncomplete()="window.location.reload();" that way instead or redirecting the user to the old page you can do the refresh for the user ? – Rao May 22 '13 at 20:25
  • Post the solution above in a reply as the answer to your question, wait a few days and then mark it as the answer. That will give you some points to increase your reputation and also show your question as having an answer that's been accepted. :) – crmprogdev May 28 '13 at 5:06
1

SOLUTION:

I found the solution so posting in hope that it may help some other lost soul. Basically I added a Page reference to the view of the Opportunity (see updated code below), whereas before I was simply letting the page refresh by not providing any rerender attribute.

public PageReference Del () {

    if(delOLI!= null) {
    Delete delOLI;
    getOppFieldAndHistory(opp);
    queryOLIs(opp.id);
    }
    PageReference oppPage = new ApexPages.StandardController(opp).view();
    oppPage.setRedirect(true);
    return oppPage;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.