function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Markey1Markey1 

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:

 

 

http://testing.somesite.cs3.force.com/aeskseenroll?RecordTypeId=012Q00000004So4

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

 

http://testing.somesite.cs3.force.com/aeskseenroll

 My Controller:

 

public class AESK_Enroll {
  
    
    /*Variables*/
    public AESK_Enrollment__c skEnroll;
    
    /*Controller*/
    /*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 {             
            /*Issuer*/
            if(pagert == '012Q00000004So4') {
                skEnroll.RecordTypeId = '012Q00000004So4';
                skEnroll.AESK_Account_Type__c = 'Issuer';        
            }
            /*Merchant*/
            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) {            
            ApexPages.addMessages(e);            
            return null;            
        }
        return page.aeskenrollconfirm; 
    }        
}

 

 

 

 

 

 

Richie DRichie D

Hi,

 

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).

 

Cheers,

Rich.