• SfDc@123.ax1389
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

hi every one,
     I am trying to implement a google chart using group by post code and status. my requirement is to group it by postcode where i do have a lot of post codes and its firing an error "Too Many Soql Queries-101".code error is indicated in red.

my code goes like this:-
 
public class columntest {
 public String getChartData()
{
 return chartData;
}
 public columntest()
{
userid = userinfo.getuserid();
       u = [Select ContactId, Id, Name from User u  where Id =: userid];
       System.Debug('ContactId :' +u.ContactId);
       ctid = u.ContactId;            
       c = [select Account.Id, Id  from Contact where id =: ctid];       
       acct = [Select id, Corporate_Customer__c from account where id =: c.Account.Id];       
       aid = c.Account.Id;       
       corporateid = acct.Corporate_Customer__c;
for(Custom_report__c r:[SELECT id,Postcode__c FROM Custom_report__c where Postcode__c != null and Account_LandLord_Id__c=:corporateid])
 {
   string test1 = string.valueof(r.Postcode__c);
    if(citymap.get(test1)==null)
    {
      list1.add(r);
      citymap.put(test1,test1);
     }
  }     
 //obtain a list of picklist values
 Schema.DescribeFieldResult F = Custom_report__c.status__c.getDescribe();
 List<Schema.PicklistEntry> P = F.getPicklistValues();
 //where chart data should be stored.
 List<ChartDataItem> items = new List<ChartDataItem>();
 //iterate through each picklist value and get number of accounts
integer k=0;
for(Custom_report__c c: list1)
{
 st[k]= c.postcode__c;
 k++;
}
for(integer m=0; m<st.size();m++)
{
 if(st[m]!=null)
 size++;
}
 for(integer i=0; i<size;i++)
 {
  post = st[i];
 postCount = [select count() from Custom_report__c  where Account_LandLord_Id__c =: corporateid and Postcode__c =: post ];
 if (postcount>0)
 postsize +=1;
 }
 for(Schema.PicklistEntry pValue : P)
 {
    if(corporateid != null)
  {
    for(integer i=0; i<postsize;i++)
 {
  post = st[i];
    Count = [select count() from Custom_report__c  where status__c = :pValue.getValue() and Account_LandLord_Id__c =: corporateid and Postcode__c =: post];   
     if (Count > 0)
      items.add(new ChartDataItem(pValue.getValue() , Count.format()));
   else
     items.add(new ChartDataItem(pValue.getValue() , Count.format()));
  }
  }
    else
    {
    Count = [select count() from Custom_report__c where status__c = :pValue.getValue() and AccountId__c =: aid  ];
    if (Count > 0)
      items.add(new ChartDataItem(pValue.getValue() , Count.format()));
    else
     items.add(new ChartDataItem(pValue.getValue() , Count.format()));
    }  
 }
 
Thanks in Advance,
Newbie

Hi Force.com board,

 

                                       My requirement is creation of a formula field for the existing  auto number field. In detail If the auto number is 1 Formula field should retain the value 'A'.If it is 2 formula field should give 'B' and similarly upto 26 'Z'.And after that It should be given as 'AA' and should continue.I cant find a solution for this, So help in any form would be really appreciated.

 

Thanks in Advance,

Developer

hi every one,
     I am trying to implement a google chart using group by post code and status. my requirement is to group it by postcode where i do have a lot of post codes and its firing an error "Too Many Soql Queries-101".code error is indicated in red.

my code goes like this:-
 
public class columntest {
 public String getChartData()
{
 return chartData;
}
 public columntest()
{
userid = userinfo.getuserid();
       u = [Select ContactId, Id, Name from User u  where Id =: userid];
       System.Debug('ContactId :' +u.ContactId);
       ctid = u.ContactId;            
       c = [select Account.Id, Id  from Contact where id =: ctid];       
       acct = [Select id, Corporate_Customer__c from account where id =: c.Account.Id];       
       aid = c.Account.Id;       
       corporateid = acct.Corporate_Customer__c;
for(Custom_report__c r:[SELECT id,Postcode__c FROM Custom_report__c where Postcode__c != null and Account_LandLord_Id__c=:corporateid])
 {
   string test1 = string.valueof(r.Postcode__c);
    if(citymap.get(test1)==null)
    {
      list1.add(r);
      citymap.put(test1,test1);
     }
  }     
 //obtain a list of picklist values
 Schema.DescribeFieldResult F = Custom_report__c.status__c.getDescribe();
 List<Schema.PicklistEntry> P = F.getPicklistValues();
 //where chart data should be stored.
 List<ChartDataItem> items = new List<ChartDataItem>();
 //iterate through each picklist value and get number of accounts
integer k=0;
for(Custom_report__c c: list1)
{
 st[k]= c.postcode__c;
 k++;
}
for(integer m=0; m<st.size();m++)
{
 if(st[m]!=null)
 size++;
}
 for(integer i=0; i<size;i++)
 {
  post = st[i];
 postCount = [select count() from Custom_report__c  where Account_LandLord_Id__c =: corporateid and Postcode__c =: post ];
 if (postcount>0)
 postsize +=1;
 }
 for(Schema.PicklistEntry pValue : P)
 {
    if(corporateid != null)
  {
    for(integer i=0; i<postsize;i++)
 {
  post = st[i];
    Count = [select count() from Custom_report__c  where status__c = :pValue.getValue() and Account_LandLord_Id__c =: corporateid and Postcode__c =: post];   
     if (Count > 0)
      items.add(new ChartDataItem(pValue.getValue() , Count.format()));
   else
     items.add(new ChartDataItem(pValue.getValue() , Count.format()));
  }
  }
    else
    {
    Count = [select count() from Custom_report__c where status__c = :pValue.getValue() and AccountId__c =: aid  ];
    if (Count > 0)
      items.add(new ChartDataItem(pValue.getValue() , Count.format()));
    else
     items.add(new ChartDataItem(pValue.getValue() , Count.format()));
    }  
 }
 
Thanks in Advance,
Newbie

Can anyone help me out with the furmula to create a workflow that sends an happy birthday email according to the DOB filed of my client?

Hi Force.com board,

 

                                       My requirement is creation of a formula field for the existing  auto number field. In detail If the auto number is 1 Formula field should retain the value 'A'.If it is 2 formula field should give 'B' and similarly upto 26 'Z'.And after that It should be given as 'AA' and should continue.I cant find a solution for this, So help in any form would be really appreciated.

 

Thanks in Advance,

Developer