How to get all Leads/Contact from a TAG using the API?
I tried "Tags/#{sugar_tag_id}/link/leads" but it doesn't work. How do I get all Leads which have a certaing Tag? I also tried to setup a Filter in the Leads Module but it also didn't work:
How to get all Leads/Contact from a TAG using the API?
I tried "Tags/#{sugar_tag_id}/link/leads" but it doesn't work. How do I get all Leads which have a certaing Tag? I also tried to setup a Filter in the Leads Module but it also didn't work:
We don't use Tags, but Tags have a flex-relate field to the Leads/Contacts etc
Based on the Tags vardef it looks like there is a link <module>_link generated for each module that has a Tag (all but the Tags module itself). See:
modules/Tags/vardefs.php
modules/Tags/TagsRelatedModulesUtilities.php
Which would imply that you could use /Tags/:record/link/:link_name
but the link name is <module>_link so perhaps something like:
Tags/#{sugar_tag_id}/link/leads_link
Again, I've not verified that you get results because we don't have any tags, but when I tested it I did get an empty set which seems to suggest it will work:
object(stdClass)#2 (2) { ["next_offset"]=> int(-1) ["records"]=> array(0) { } }
HTH
FrancescaS
I tested it and can confirm it works exactly like this:
GET - Contacts with specific tag
/rest/v10/Tags/#{tag_id}/link/contacts_link
GET - Leads with specific tag
/rest/v10/Tags/#{tag_id}/link/leads_link
Another way to accomplish this is through the search in the Contacts or Leads, there you don't even need the Tag ID:
POST
/rest/v10/Contacts/filter
body = {
"filter":[
{
"tag_link.name" : "tag_name"
}
]
}