function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
veeru_pariveeru_pari 

tag search

Hi,
Can i please get the code how tow develop search functionality based on tags in salesforce.(tag search functionality).the user should be able to search the question and answer based on tags.like stackoverflow.


Thanks
Veeru
Peter_sfdcPeter_sfdc
By "tags" do you mean topics? 

Or do you mean the legacy tags feature on objects like Case? 
veeru_pariveeru_pari
yes I mean topics.example in stackoverflow app we search using tags also like that kind . Thaks veeraiah
Peter_sfdcPeter_sfdc
There are two ways I know of doing this currently, and I'm afraid they are both a bit clunky as of now. 

SOQL
Normally for a text-based search like this, you would use SOSL. But SOSL doesn't look for related records, and currently : 

    Select Id from Topic where Name = 'topic-name'

Take those IDs bundle them up into a list or set and turn around and query TopicAssignment. 

    SELECT EntityId, TopicId FROM TopicAssignment where TopicId in : myListOfTopicIds

You can then use the EntityId values to work with the specific records that are assigned to that topic. 

ConnectApi
There is an alternative which is to use the ConnectApi classes. In this instance, you would use this: 

    ConnectApi.Feed topicFeed = ConnectApi.Feed.getFeed(null, ConnectApi.FeedType.Topics , <the topic Id> , null); 

You'd then have to cycle through the feed and get feed items, and use those to detect what kind of feed items they are. 


My wish is that some day in the future you can just throw a topic at SOSL, and then have SOSL return a bunch of records/feeds/etc that are being used by that topic...but as of today, that is just a dream. 
veeru_pariveeru_pari
so peter what would be answer to my question?
Peter_sfdcPeter_sfdc
Try one. If you don't like it try the other.

Topics is a very new part of the application right now, so there is no settled opinion on best practice for what you want to do yet. 

You are a trailblazer, my friend. :-)
veeru_pariveeru_pari
Thanks and will try both...
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=-q83q0e-hxn5ax45-3z&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776471112658944&sharedKey=qqjA1SbM You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=-q83q0e-hxn5ax45-3z&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=-q83q0e-hxn5ax45-3z&email=0-3ixyshiemvs8mx%2En22cigzw2vrz9yga%40tto32fzxdw8goqpj%2Eakwrckz%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=-q83q0e-hxn5ax45-3z&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=-rmtnba-hxn5axh9-4e&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776478582714368&sharedKey=ec_f2orK You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=-rmtnba-hxn5axh9-4e&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=-rmtnba-hxn5axh9-4e&email=19ck3b5mcx4emyc3%2Ec1mvbgmz8usg5szk%40qa1vxlkku4aqpvo7%2Eu4yvw%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=-rmtnba-hxn5axh9-4e&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA
veeru_pariveeru_pari
Hi , I'd like to add you to my professional network on LinkedIn. - veeraiah Accept: https://www.linkedin.com/e/v2?e=-3xa547-hxn5ax5b-4x&a=preRegInvite&tracking=eml-guest-invite-cta&ek=invite_guest&invitationID=5894776470642896896&sharedKey=5iApbbIo You are receiving Invitation emails. Unsubscribe here: https://www.linkedin.com/e/v2?e=-3xa547-hxn5ax5b-4x&t=uns&tracking=eml-guest-invite-unsubscribe&ek=invite_guest&id=20061∣=-1&aid=iuehc9r3r0sm6r3&eid=-3xa547-hxn5ax5b-4x&email=3cp9gbgmpt6si936%2Eznwi5k1xsdn34ixw%407wwrcqlzowr1a82s%2Efp1fx%2Ef-55kkmai%2Ena10%2Echatter%2Esalesforce%2Ecom Learn why we included this at the following link: http://www.linkedin.com/e/v2?e=-3xa547-hxn5ax5b-4x&a=customerServiceUrl&ek=invite_guest&articleId=4788 © 2014, LinkedIn Corporation. 2029 Stierlin Ct. Mountain View, CA 94043, USA