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
suji srinivasansuji srinivasan 

how to display data in vf page based on its recodtype id?

I have two record types Standard Payment & custom payment . 
according to recordtypes i need to display my table values.

thanks in advance
Best Answer chosen by suji srinivasan
mukesh guptamukesh gupta
Hi Suji,

Please use below code:-
 
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
  <apex:pageBlock >
    <apex:form >
     
      <apex:pageBlockTable value="{!accounts}" var="acc" id="list" >
        <apex:column value="{!acc.name}" rendered="{! If(acc.RecordType.Name =='Standard Payment' ,true,false) }"/>
        <apex:column value="{!acc.AccountNumber}" rendered="{! If(acc.RecordType.Name =='custom payment' ,true,false) }" />
      </apex:pageBlockTable>
    </apex:form>
  </apex:pageBlock>
</apex:page>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh

All Answers

mukesh guptamukesh gupta
Hi Suji,

Please follow below code:-
<apex:page controller="StandardAccountDisplayController"> 
	<apex:pageBlock title="Account List"> 
		<apex:pageBlockTable value="{!records}" var="record"> 
			<apex:column > 
				<apex:facet name="header">Account Name</apex:facet> 
				<apex:outputText value="{!record.Name}"/> 
			</apex:column> 
			<apex:column > 
				<apex:facet name="header">Account Number</apex:facet> 
				<apex:outputText value="{!record.AccountNumber}"/> 
			</apex:column> 
		</apex:pageBlockTable> 
	</apex:pageBlock> 
</apex:page>
 
public with sharing class StandardAccountDisplayController{ 
public List<Account> records {get; set;} 
public StandardAccountDisplayController(){ 

Id devRecordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('RecordtypeName').getRecordTypeId();
records = [select RecordType.Name, Name, AccountNumber from Account where RecordTypeId =: devRecordTypeId]; 
} 
}

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh


 
suji srinivasansuji srinivasan
Hi mukesh ,
In single vf page i need to display my table values based on recordtype. I can't use the controller type .is it possible to use if condition?
Thanks
suji
mukesh guptamukesh gupta
Hi Suji,

Please use below code:-
 
<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
  <apex:pageBlock >
    <apex:form >
     
      <apex:pageBlockTable value="{!accounts}" var="acc" id="list" >
        <apex:column value="{!acc.name}" rendered="{! If(acc.RecordType.Name =='Standard Payment' ,true,false) }"/>
        <apex:column value="{!acc.AccountNumber}" rendered="{! If(acc.RecordType.Name =='custom payment' ,true,false) }" />
      </apex:pageBlockTable>
    </apex:form>
  </apex:pageBlock>
</apex:page>

if you need any assistanse, Please let me know!!

Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
This was selected as the best answer