1

I have a visualforce page that runs a flow and use a custom controller extension to set the finish location based on the user profile. (Basically it re-directs back to the original opp record, which has a slightly different URL for partner community users.) The visualforce page is being called by a custom button on the opportunity record.

Everything works as expected in the (partial copy) sandbox, but in production, the parameter does not get passed to the controller. Is there an error with the code or anything else that would prevent this from working in production?

Visualforce page:

<apex:page standardController="Opportunity" extensions="My_Controller" tabStyle="Opportunity" >
    <flow:interview name="Resend_Registration_Email" finishLocation="{!OppPage}">
        <apex:param name="var_Opp_Id" value="{!Opportunity.Id}" assignTo="{!oppId}"/>  
    </flow:interview>
</apex:page>

Controller:

public class My_Controller {

public My_Controller(ApexPages.StandardController controller) {

}

public String retURL;
public String oppId {get;set;}

 public String userProfileName {
    get {
        return [
                select Profile.Name
                from User
                where Id = :Userinfo.getUserId()
                ].Profile.Name;
    }
}


public PageReference getOppPage() {

    if(oppId == null){
        oppId = '006';
    }

    if(userProfileName != null && userProfileName.contains('Partner')){
        retURL = '/partner/' + OppId;

    } else {
        retURL = '/' + OppId;
    }
    System.debug('Return URL: ' + retURL);
    return new PageReference(retURL);
}


}
  • 1
    Just a stab, but are you testing with users who have the same FLS permissions in both environments? – David Reed Jun 27 '18 at 22:31
2

Why not check first if the param was passed over? Still defaulting to the tab page in the event that the Opp is empty. Updated the controller code to be a little cleaner without hard coding ids in there. I would perform a check if the value is in the params and not use the assignTo for the parameter, could be the assignTo isn't in fact assigning. See Below:

Page:

<apex:page standardController="Opportunity" extensions="MyController" tabStyle="Opportunity" >
    <flow:interview name="Resend_Registration_Email" finishLocation="{!OppPage}">
        <apex:param name="var_Opp_Id" value="{!Opportunity.Id}" />  
    </flow:interview>
</apex:page>

Controller:

public class MyController {

    Map<String, String> params  { get; set; }
    final String OPP_ID_PARAM = 'var_Opp_Id';
    final String PARTNER = 'Partner';

    public String retUrl { get; set; }
    public String oppId { get; set; }

    public String userProfileName {
        get{
            return [ SELECT Name 
                     FROM Profile 
                     WHERE Id =: UserInfo.getProfileId() 
                     LIMIT 1 ].Name;
        }
    }

    public MyController( ApexPages.StandardController controller ){
         this.params = ApexPages.currentPage().getParameters();

         if( this.params.containsKey( OPP_ID_PARAM )){
             oppId = this.params.get( OPP_ID_PARAM );
         } 
    }

    public PageReference getOppsPage(){


        if( !params.containsKey( OPP_ID_PARAM )){
            oppId = getOppPrefix();
        }

        if( !String.isBlank( userProfileName ) && userProfileName .contains( PARTNER )){
            retUrl = '/partner/' + oppId;
        }
        else {
            retUrl = '/' + oppId;
        }

        return new PageReference( retUrl );
    }

    public String getOppPrefix(){
        return Opportunity.getSObjectType().getDescribe().getKeyPrefix();
    }
}
  • The parameter is not passing over, either in my original version or in the version you posted above. I realize I should add that this VF page is being called from a custom button on the opportunity record. I'll update the original post with that info. Is the custom button perhaps preventing the parameter from being passed? – TheDevAdmin Jun 28 '18 at 16:51
  • Yes that is very likely the case. @TheDevAdmin – Ronnie Jun 29 '18 at 0:23
  • Do you have the code from your button by chance? – Ronnie Jun 29 '18 at 0:24

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.