+ Start a Discussion
parasparas 

Popular tags Approach 2

Hi ,
 
I have a requirement as such : i want to to display only those tags on my page which are present for more than two vendors (we have  accounts as vendors ).
 
1.I have taken all the tags in one list
2.then have stored those distinct records in a set (not sure my way is correct or not )
3.created one more list
4.then for each element of the set i am comparing with the elements of set , if i find that element i am incrementing the counter
5. when the counter is greater than 2 , i am storing that tag into list 3 and returning list 2 but
My code goes on like this
 
public List<String> getTags()
{
List<AccountTag> list1= [select Name from AccountTag];
List<AccountTag> list2= new List<AccountTag>();
Set<String> Tags1 = new Set<String>();
List<String> list3 = new List<String>();
for (Integer i=0; i< list1.size(); i++)
{
    Tags1.add(list1[i].name);
}
for(Integer l=0;l<Tags1.size();l++)
{
    list3.add(Tags1[l].name);
}
   for(Integer j=0;j<list3.size();j++)
   {
     for(Integer k=0;k<List1.size();k++)
      {
       if(list1[j]==List3[k])
       count= count+1;
       }
       if(count>=2)
       list2.add(list1[j]);
      }
 
return list2;
}
Unknown property 'String.Name' is the error i am getting
please help : As soon as possible : 


Message Edited by paras on 11-20-2008 08:49 PM

Message Edited by paras on 11-20-2008 08:50 PM
harlequinharlequin

for (Integer i=0; i< list1.size(); i++)
{
    Tags1.add(list1[i].name);
}

for(Integer l=0;l<Tags1.size();l++)
{
     list3.add(Tags1[l].name);
     Tags1[l] doesn't have a 'name' property, it's just a list of strings.
}



Message Edited by harlequin on 11-21-2008 07:48 AM
parasparas

hey ,

Thanks for your reply but how to resolve this issue . can you please give a solution

parasparas
how to convert a List of Sobects to a list of strings