You need to sign in to do that
Don't have an account?
Ricardo Aguilar 4
Redirect edit button to visualforce pages
Hello,
What change do I need to do in the following codes, in order to make the "Edit" standard button redirect to a Visualforce Pages based on record type for a custom object?
The user should edit the record on the Visualforce Page.
Apex Class and VF page works properly when creating a new record with the "New" standard button, configurated with the following codes:
VF code
<apex:page standardController="ADELTESurvey__c" extensions="NewSurveyExtension" action="{!redirectToNewVFPage}"> </apex:page>
Apex Class
public class NewSurveyExtension { public String recordTypeId; public NewSurveyExtension(ApexPages.StandardController std) { } public Pagereference redirectToNewVFPage(){ Pagereference pg = null; if(ApexPages.CurrentPage().getParameters().get('RecordType') != null){ recordTypeId = ApexPages.CurrentPage().getParameters().get('RecordType'); if(recordTypeId == Schema.SObjectType.ADELTESurvey__c.getRecordTypeInfosByName().get('Delivery').getRecordTypeId()){ pg = new Pagereference('/apex/Satisfaction_Survey_Delivery'); // Add Parameters to Page if Needed }else if(recordTypeId == Schema.SObjectType.ADELTESurvey__c.getRecordTypeInfosByName().get('Operation').getRecordTypeId()){ pg = new Pagereference('/apex/Satisfaction_Survey_Operation'); // Add Parameters to Page if Needed } pg.setRedirect(true); return pg; } return null; } }
Any help would be appreciated,
Regards
What change do I need to do in the following codes, in order to make the "Edit" standard button redirect to a Visualforce Pages based on record type for a custom object?
The user should edit the record on the Visualforce Page.
Apex Class and VF page works properly when creating a new record with the "New" standard button, configurated with the following codes:
VF code
<apex:page standardController="ADELTESurvey__c" extensions="NewSurveyExtension" action="{!redirectToNewVFPage}"> </apex:page>
Apex Class
public class NewSurveyExtension { public String recordTypeId; public NewSurveyExtension(ApexPages.StandardController std) { } public Pagereference redirectToNewVFPage(){ Pagereference pg = null; if(ApexPages.CurrentPage().getParameters().get('RecordType') != null){ recordTypeId = ApexPages.CurrentPage().getParameters().get('RecordType'); if(recordTypeId == Schema.SObjectType.ADELTESurvey__c.getRecordTypeInfosByName().get('Delivery').getRecordTypeId()){ pg = new Pagereference('/apex/Satisfaction_Survey_Delivery'); // Add Parameters to Page if Needed }else if(recordTypeId == Schema.SObjectType.ADELTESurvey__c.getRecordTypeInfosByName().get('Operation').getRecordTypeId()){ pg = new Pagereference('/apex/Satisfaction_Survey_Operation'); // Add Parameters to Page if Needed } pg.setRedirect(true); return pg; } return null; } }
Any help would be appreciated,
Regards
Greetings to you!
Please refer to the below links which might help you further with the above requirement.
https://sfdssoru.blogspot.com/2018/08/redirecting-user-to-different.html
https://salesforce.stackexchange.com/questions/63203/override-standard-edit-button-based-on-recordtype
https://salesforce.stackexchange.com/questions/33192/how-to-override-edit-button-for-custom-visualforce-page-based-on-recordid
I hope it helps you.
Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.
Thanks and Regards,
Khan Anas
Actually, I triy using the third link to create the following VF:
<apex:page standardController="ADELTESurvey__c" action="{!URLFOR(CASE(ADELTESurvey__c.RecordType.Name, 'Delivery', '/apex/Satisfaction_Survey_Delivery' ,'Operation','/apex/Satisfaction_Survey_Operation', '/apex/vfp3'))}" >
<apex:variable value="{!ADELTESurvey__c.RecordType.Name}" var="recTypeName"/>
</apex:page>
But, when clicking edit button, the visualforce page shows up but without any data recorded for editing. It is like creating a new record.
Thanks in advance for your help.
Regards,
You don't seem to be passing any Id in your URLFOR or Pagereference. How would it know what record to edit without it. Also you need to add /e to the end or the URL after the ID to get it into edit mode.
/xxxxxxxxxSFDCIDxxx/e