You need to sign in to do that
Don't have an account?
Shane Quiring
Reference the record type field in a visualforce page
Hello Experts,
I am new to APEX coding and Visualforce Pages, but learning. I am having a bit of an issue with a VF page. I am trying to refrence either the record type ID or the record type name in an "IF" statement. Here is what I am trying to do, if the record type id equals a certain ID then show "Supplier Contract" else "Client Contract". I am of course running into an error. Here is the error and the coding:
Error: "Error: Unknown property 'ServiceContractStandardController.RecordType'"
Coding:
<apex:page standardController="ServiceContract" showHeader="true"
tabStyle="servicecontract" >
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!IF(RecordType.Id=='012K00000008w7q',h1,h2)}">
<style>
h1 {
font-size: 20px;
}
</style>
<h1>SUPPLIER ACCOUNT</h1>
<style>
h2 {
font-size: 20px;
}
</style>
<h2>CLIENT CONTRACT</h2>
</apex:outputPanel>
</center>
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails"
id="ServiceAccountTabPanel" tabClass="activeTab"
inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="ServiceAcctDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Approval History" name="ApprovalHistory"
id="tabApprovalHist">
<apex:relatedList subject="{!servicecontract}"
list="ProcessSteps" />
</apex:tab>
<apex:tab label="Notes and Attachments" name="NotesAndAttachments"
id="tabNotesAndAttachments">
<apex:relatedList subject="{!servicecontract}"
list="CombinedAttachments" />
</apex:tab>
<apex:tab label="Field History" name="FieldHistory"
id="fieldhistory">
<apex:outputLink value="https://cs9.salesforce.com/_ui/common/history/ui/EntityHistoryFilterPage?id={!servicecontract.id}">
click to view field history
</apex:outputLink>
</apex:tab>
</apex:tabPanel>
</apex:page>
Any Assistance would greatly apprecitated, thank-you.
v/r
Shane
I am new to APEX coding and Visualforce Pages, but learning. I am having a bit of an issue with a VF page. I am trying to refrence either the record type ID or the record type name in an "IF" statement. Here is what I am trying to do, if the record type id equals a certain ID then show "Supplier Contract" else "Client Contract". I am of course running into an error. Here is the error and the coding:
Error: "Error: Unknown property 'ServiceContractStandardController.RecordType'"
Coding:
<apex:page standardController="ServiceContract" showHeader="true"
tabStyle="servicecontract" >
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!IF(RecordType.Id=='012K00000008w7q',h1,h2)}">
<style>
h1 {
font-size: 20px;
}
</style>
<h1>SUPPLIER ACCOUNT</h1>
<style>
h2 {
font-size: 20px;
}
</style>
<h2>CLIENT CONTRACT</h2>
</apex:outputPanel>
</center>
<style>
.activeTab {background-color: #236FBD; color:white;
background-image:none}
.inactiveTab { background-color: lightgrey; color:black;
background-image:none}
</style>
<apex:tabPanel switchType="client" selectedTab="tabdetails"
id="ServiceAccountTabPanel" tabClass="activeTab"
inactiveTabClass="inactiveTab">
<apex:tab label="Details" name="ServiceAcctDetails" id="tabdetails">
<apex:detail relatedList="false" title="true"/>
</apex:tab>
<apex:tab label="Approval History" name="ApprovalHistory"
id="tabApprovalHist">
<apex:relatedList subject="{!servicecontract}"
list="ProcessSteps" />
</apex:tab>
<apex:tab label="Notes and Attachments" name="NotesAndAttachments"
id="tabNotesAndAttachments">
<apex:relatedList subject="{!servicecontract}"
list="CombinedAttachments" />
</apex:tab>
<apex:tab label="Field History" name="FieldHistory"
id="fieldhistory">
<apex:outputLink value="https://cs9.salesforce.com/_ui/common/history/ui/EntityHistoryFilterPage?id={!servicecontract.id}">
click to view field history
</apex:outputLink>
</apex:tab>
</apex:tabPanel>
</apex:page>
Any Assistance would greatly apprecitated, thank-you.
v/r
Shane
I was able to resolve this another way by creating a formula field (IF Statement) that references the record type id and brings back either "Supplier Contract" or "Client Contract". Here is the coding that I used:
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!ServiceContract.Record_Type_Name__c=='Client Contract'}">
<style>
h1 {
font-size: 20px;
}
</style>
<h1>CLIENT CONTRACT!</h1>
</apex:outputPanel>
</center>
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!ServiceContract.Record_Type_Name__c=='Supplier Contract'}">
<style>
h2 {
font-size: 20px;
}
</style>
<h2>SUPPLIER CONTRACT!</h2>
</apex:outputPanel>
Unfortunately at this time I am not very versed is APEX Triggers or Classes and I was unable to write the Class.
Thank-you for the assistance and actually pointing me another direction.
v/r
Shane
All Answers
Create a property in the controller and assign the record type id , refer the RecordTypeIdString on VF page. Important :
If this is what you were looking for then please mark it as a "SOLUTION" or You can Click on the "Like" Button if this was beneficial for you.
Thank-you for your assistance, just make sure that I am clear, I will need to create a controller, as discussed in the following link: https://www.salesforce.com/us/developer/docs/pages/Content/pages_dynamic_vf_globals_objecttype.htm Is this correct?
v/r
Shane
I was able to resolve this another way by creating a formula field (IF Statement) that references the record type id and brings back either "Supplier Contract" or "Client Contract". Here is the coding that I used:
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!ServiceContract.Record_Type_Name__c=='Client Contract'}">
<style>
h1 {
font-size: 20px;
}
</style>
<h1>CLIENT CONTRACT!</h1>
</apex:outputPanel>
</center>
<center>
<apex:outputPanel style="background-color:red;width:100%;padding:20px;"
rendered="{!ServiceContract.Record_Type_Name__c=='Supplier Contract'}">
<style>
h2 {
font-size: 20px;
}
</style>
<h2>SUPPLIER CONTRACT!</h2>
</apex:outputPanel>
Unfortunately at this time I am not very versed is APEX Triggers or Classes and I was unable to write the Class.
Thank-you for the assistance and actually pointing me another direction.
v/r
Shane