1

There is an issue with overriding Opportunity view for some particular profile.Currently We are redirecting the profile users to a VF page by default.

we have a button in our VF page, which takes the user to the standard view if he wants. In that case I am sending an url parameter as 'classic' and taking the user to standard page.

so my code is like this :

 public PageReference reDirect(){
         PageReference pr = null;
          if(user has profile1){
             if(ApexPages.currentPage().getParameters().get('type') == 'classic'){
                   pr = new PageReference('/'+opp.id+'?&nooverride=1');
                   pr.setRedirect(true);
             }
             else{
                  pr = new PageReference('/apex/dealwizard?id='+opp.Id);
                  pr.setRedirect(true);
             }
          }
          else if(opp.RecordTypeId==sales){
               pr=new PageReference('/'+opp.id+'?&nooverride=1');
               pr.setRedirect(true);
          }
         return pr;
}

But now the problem is this -- After getting redirected to Standard view , If I try to inline edit some field and click save , it is taking me to my VF page :( I am unable to rectify it.How to make it stay in Standard Page when I edit and save.

My VF page controller has the following logic:

public PageReference goToClassicView() 
{
   if(user has profile1){         
       return new PageReference(Label.SFDC_Server_URL + opportunityObj.Id+'?type=classic&saveUrl=/'+opportunityObj.Id+'&nooverride=1');   
   }else{           
       return new PageReference(Label.SFDC_Server_URL + opportunityObj.Id);                
   } 
}
1
  • have you tried passing in a saveUrl in your parameters when you redirect to the standard page? You can use the saveUrl to specify where the page should go upon saving with this parameter – Chris Duncombe Jan 10 '14 at 12:02
1

This is similar to an earlier question that has an answer. You need to pass the saveURL into the view page, but have the extra info URL encoded. (You probably should include the retURL in this also in case someone in line edits then hits cancel):

URL Hack: Pass additional parameters into the saveURL

return new PageReference('/'+opp.id+'?' + EncodingUtil.urlEncode('saveURL=/'+opp.id+'&nooverride=1'));
0

or try to use retURL

pr = new PageReference('/'+opp.id+'?retURL=/'+opp.id+'&nooverride=1');
2
  • retUrl is for the cancel button. saveUrl is for the save button. This will not work on the save action. – Chris Duncombe Jan 10 '14 at 12:47
  • No saveURL didnt worked. See I have updated my question and the code has saveURl in it.I tried it but it didn't worked. – LoveSalesforce Jan 13 '14 at 9:36

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.