You need to sign in to do that
Don't have an account?
Leadforce
How can I override Record Type Page Layout for a Visualforce Page??
I'm making a simple Visualforce page to be used for a button on an Account detail. The purpose of this page is to override the limited page layout of the account Record type and open a detailed Account view with all fields, not the limited page layout determined by record type.
This is the script I am using;
<apex:page standardController="Account">
<b> Hello {!$User.FirstName}! </b> <br/> <br/>
<apex:detail />
</apex:page>
When I use this, the same page layout is displaying as with the Record type of this Account record. I want a different, detailed or master page layout to be displayed when the Visualforce page is opened. Is this Possible? Thank YOU for any input!!
This is the script I am using;
<apex:page standardController="Account">
<b> Hello {!$User.FirstName}! </b> <br/> <br/>
<apex:detail />
</apex:page>
When I use this, the same page layout is displaying as with the Record type of this Account record. I want a different, detailed or master page layout to be displayed when the Visualforce page is opened. Is this Possible? Thank YOU for any input!!
VF page code
Apex controller code
All Answers
VF page code
Apex controller code
public class LoadRecordType {
Account a;
public LoadRecordType(ApexPages.StandardController controller) { a=(Account)controller.getRecord();
}
public PageReference setRecordType(){
a.RecordTypeId=[Select Id,SobjectType,Name From RecordType where Name ='VCHospital' and SobjectType ='Account' limit 1].id; update a; return null;
}
}
And reference this as extension in Account Visualforce page, I get this error.
System.QueryException: List has no rows for assignment to SObject
Error is in expression '{!setRecordType}' in component <apex:page> in page accountdetailbutton: Class.LoadRecordType.setRecordType: line 10, column 1
Class.LoadRecordType.setRecordType: line 10, column 1
Im kind of a visualforce Newb. Can you help me figure out why this is happening?