You need to sign in to do that
Don't have an account?
Abhiman Mungal
i want all records from object
<apex:page standardController="Profile__c" extensions="OrdersFromUsers">
<apex:outputPanel id="all">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Orders" columns="1" >
<apex:pageBlockTable value="{!OrdersFromUsers}" var="cont">
<apex:column value="{!cont.Name}"/>
<apex:column value="{!cont.Address__c}"/>
<apex:column value="{!cont.Booking_Date__c}"/>
<apex:column value="{!cont.Customer_Name__c}" />
<apex:column value="{!cont.Event_Name__c}" />
<apex:column value="{!cont.Event_Type__c}"/>
<!-- <apex:column value="{!cont.Location__c}"/>-->
<apex:column value="{!cont.Services__c}"/>
<apex:column value="{!cont.Time__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection title="Customer Information" columns="1" id="info">
<apex:pageBlockTable value="{!ViewCustomerDetail}" var="cust">
<apex:column value="{!cust.Name}"/>
<apex:column value="{!cust.Address__c}"/>
<apex:column value="{!cust.District__c}"/>
<apex:column value="{!cust.Email__c}" />
<apex:column value="{!cust.Mobile_No__c}"/>
<apex:column value="{!cust.Pin_Code__c}"/>
<apex:column value="{!cust.State__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
public with sharing class OrdersFromUsers {
public List<Order__c> OrdersFromUsers{get; set;}
public List<Profile__c> ViewCustomerDetail{get;set;}
public String actualName;
public OrdersFromUsers(ApexPages.StandardController controller) {
List <Order__c> val=[select Customer_Name__c from Order__c where customerName__r.name=:UserInfo.getFirstName()+' '+UserInfo.getLastName()];
for(integer i=0;i<val.size();i++)
{
actualName='%'+val[i].Customer_Name__c+'%';
ViewCustomerDetail=[select name,Address__c,District__c,Email__c,Mobile_No__c,Pin_Code__c,State__c from Profile__c where name like:actualName];
}
actualName='';
OrdersFromUsers=[select name,Address__c,Booking_Date__c,Customer_Name__c,Event_Name__c,Event_Type__c,Services__c,Time__c from Order__c where customerName__r.name=:UserInfo.getName()];
}
}
if i do this its giving me last record of that list but i want all records from this list
so what can i do plz tell me....
<apex:outputPanel id="all">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection title="Orders" columns="1" >
<apex:pageBlockTable value="{!OrdersFromUsers}" var="cont">
<apex:column value="{!cont.Name}"/>
<apex:column value="{!cont.Address__c}"/>
<apex:column value="{!cont.Booking_Date__c}"/>
<apex:column value="{!cont.Customer_Name__c}" />
<apex:column value="{!cont.Event_Name__c}" />
<apex:column value="{!cont.Event_Type__c}"/>
<!-- <apex:column value="{!cont.Location__c}"/>-->
<apex:column value="{!cont.Services__c}"/>
<apex:column value="{!cont.Time__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection title="Customer Information" columns="1" id="info">
<apex:pageBlockTable value="{!ViewCustomerDetail}" var="cust">
<apex:column value="{!cust.Name}"/>
<apex:column value="{!cust.Address__c}"/>
<apex:column value="{!cust.District__c}"/>
<apex:column value="{!cust.Email__c}" />
<apex:column value="{!cust.Mobile_No__c}"/>
<apex:column value="{!cust.Pin_Code__c}"/>
<apex:column value="{!cust.State__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:outputPanel>
</apex:page>
public with sharing class OrdersFromUsers {
public List<Order__c> OrdersFromUsers{get; set;}
public List<Profile__c> ViewCustomerDetail{get;set;}
public String actualName;
public OrdersFromUsers(ApexPages.StandardController controller) {
List <Order__c> val=[select Customer_Name__c from Order__c where customerName__r.name=:UserInfo.getFirstName()+' '+UserInfo.getLastName()];
for(integer i=0;i<val.size();i++)
{
actualName='%'+val[i].Customer_Name__c+'%';
ViewCustomerDetail=[select name,Address__c,District__c,Email__c,Mobile_No__c,Pin_Code__c,State__c from Profile__c where name like:actualName];
}
actualName='';
OrdersFromUsers=[select name,Address__c,Booking_Date__c,Customer_Name__c,Event_Name__c,Event_Type__c,Services__c,Time__c from Order__c where customerName__r.name=:UserInfo.getName()];
}
}
if i do this its giving me last record of that list but i want all records from this list
so what can i do plz tell me....
We have not initialize the ViewCustomerDetail in constructor, so you need to add below line at line number 6
ViewCustomerDetail = new List<Profile__c>();
You can use below sample code:
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta
All Answers
As per your controller class you are overwriting ViewCustomerDetail varibale in for loop, that's why you are getting last record values.
Your code should be look like:
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta
its giving me an error like null pointer Exception
We have not initialize the ViewCustomerDetail in constructor, so you need to add below line at line number 6
ViewCustomerDetail = new List<Profile__c>();
You can use below sample code:
Hope this will help you. Let me know if it helped or you need any more assistance.
Please mark this is as the solution if it solved your purpose.
Thanks,
Sohan Raj Gupta
its working fine