+ Start a Discussion
uniuni 

count of an record

I am having 3 custom objects
cuo1,cuo2,cuo3
cuo2 and 3 are master for cuo1

now i need here is

i need to retrive in VF page that cuo2 field and cuo3 field with their cuo1 field count

explanation
1st record
cuo2=harish {record} 
cuo3= choclates{record}
cou1= 3{field}
as one record

2nd record
cuo2=harish
cuo3=choclates
cuo3=4{field}



here harish is having choclates 7{record1+record2} in number
i need to get this retrival in vf page

Help me out

Best Answer chosen by Admin (Salesforce Developers) 
souvik9086souvik9086

Hi,

 

public List<cou1__c> cou1List = new List<cou1__c>();
cou1List = [select id,name,LookupField__c,NumberField__c from cou1__c where LookupField__c =: cou2.id];
public Integer count = 0;
if(cou1List.size()>0){
for(cou1__c cou1Obj:cou1List){
count += cou1Obj.NumberField__c;
}
}

 

You can use this count variable in VF.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

All Answers

Yoganand GadekarYoganand Gadekar

Can you post more details in simplified form ? May be u need to use lookup summary field.. 

 

 

Thanks,

salesforce knowledge sharing  and examples @ my blog:

Cloudforce4u 

 

 

souvik9086souvik9086

Hi,

 

public List<cou1__c> cou1List = new List<cou1__c>();
cou1List = [select id,name,LookupField__c,NumberField__c from cou1__c where LookupField__c =: cou2.id];
public Integer count = 0;
if(cou1List.size()>0){
for(cou1__c cou1Obj:cou1List){
count += cou1Obj.NumberField__c;
}
}

 

You can use this count variable in VF.

 

If this post is helpful please throw Kudos.If this post solves your problem kindly mark it as solution.

Thanks

This was selected as the best answer
uniuni

Thanq