0

Can anyone tell me how to fetch the records based on the topic name.. Like I have 20 contacts ..10 contacts are associated with the topic name test1 and others are test2

Wanna fetch the records associated with the topic name test1 Please Help!

  • It will be great if you elaborate question a bit, You want SOQL Query for fetching such records ? – Salesforce Steps Sep 16 '14 at 7:40
  • @NileshMendhe: Yep.. I need a soql query for fetching those records – user3332076 Sep 16 '14 at 7:45
  • You need to retrieve records which are topic field set to test1 or test2 and then do some work based on the topic is it? – highfive Sep 16 '14 at 7:59
  • NileshMendhe : Hy @Nilesh Mendhe: I don't want to create any custom field for that object. Just add the topic to that record .. like help.salesforce.com/… – user3332076 Sep 16 '14 at 8:06
  • @NileshMendhe : please help – user3332076 Sep 16 '14 at 8:20
0

I assume that you have created a Custom Field on Contact for saving your Topic Names, Lets take its API as topic_name__c

then your possible SOQL query will be -

select id,Name from Contact where topic_name__c='test1'

See how I have used it to get my records in List -

List<Contact> lstContact = new List<Contact>();

    lstContact=[select id,Name from Contact where topic_name__c='test1'];   
    //here you got you got your records of topic=test1 in List lstContact, now use for loop to access them - like

    for(Contact objContact:lstContact){
        /* you have got each record in **objContact** who's having topic_name=test1, you access fields as per your requirement*/  
      System.Debug('---Name---'+objContact.Name);
    }
  • Hy @Nilesh Mendhe: I don't want to create any custom field for that object. Just add the topic to that record .. like help.salesforce.com/… – user3332076 Sep 16 '14 at 7:59
  • hey are you there? – user3332076 Sep 16 '14 at 8:22
  • @user3332076 : Ohh, I didn't got enough time to search for the answer, but I'll get back on this, ASAP. – Salesforce Steps Sep 17 '14 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.