+ Start a Discussion

Set Redirect URL on Page Refresh

I have a site with a sidebar which populates the URL using the Query String Parameter. This allows me to set the RecordType upon save etc. My issue is when the validation rules fire, the page refreshes and the Query String Parameter values are lost. The Query String Parameters are used for validation purposes which means the record can not save until I figure out how to resolve this issue.


Visualforce Page Code which populates Query String Parameter:


<apex:outputlink value="{!URLFOR($Page.aeskisenroll) + '?RecordTypeId=012Q00000004So4'}">Enrollment</apex:outputlink>

Which makes the site URL look like this:




 When a validation rule fires, the URL looks like this:



 My Controller:


public class AESK_Enroll {
    public AESK_Enrollment__c skEnroll;
    /*ApexPages.StandardController controller;*/
    public AESK_Enroll(ApexPages.StandardController con){
        ApexPages.StandardController controller;         
        controller = con;        
        skEnroll = (AESK_Enrollment__c)controller.getRecord();                         


    /*Validate, save, and return page*/
    public PageReference save() {
    String pagert = ApexPages.currentPage().getParameters().get('RecordTypeId'); 
            try {             
            if(pagert == '012Q00000004So4') {
                skEnroll.RecordTypeId = '012Q00000004So4';
                skEnroll.AESK_Account_Type__c = 'Issuer';        
            else if(pagert == '012Q00000004So9') {
                skEnroll.RecordTypeId = '012Q00000004So9';
                skEnroll.AESK_Account_Type__c = 'Merchant';        
            /*ACS Vendor*/             
            else if(pagert == '012Q00000004SoE') {
                skEnroll.RecordTypeId = '012Q00000004SoE';
                skEnroll.AESK_Account_Type__c = 'ACS Vendor';        
            /*MPI Vendor*/        
            else if(pagert == '012Q00000004SoJ') {
                skEnroll.RecordTypeId = '012Q00000004SoJ';
                skEnroll.AESK_Account_Type__c = 'MPI Vendor';        
            else {
                return null;
            insert skEnroll;
        catch (DMLException e) {            
            return null;            
        return page.aeskenrollconfirm; 







Richie DRichie D



If you get your parameter in the constructor and save to a local variable then you can get them in your save method later on and not need to worry about the validation rules firing (or not).