How to create a Macro to find Specific Text in Contact Group Name

SHANE EBERT asked on December 29, 2017 21:34

Image Text

Hello, I want to create a contact group that takes all contacts from contact groups with the name "Events" in the title.

I do not know code and am running Kentico 10.

Thanks

Recent Answers


Trevor Fayas answered on December 30, 2017 06:58

Very Lengthy, but try this one!

GlobalObjects.Contacts.Where("ContactID = '"+Contact.ContactID+"' and ContactID in (Select ContactGroupMemberRelatedID from OM_ContactGroupMember where ContactGroupMemberContactGroupID in (Select ContactGroupID from OM_ContactGroup where ContactGroupName like '%Event%'))").Count > 0

Performance may be...so so. It may be better to make a custom macro method gets a list of all the Contact IDs for all the groups given the name, caches that, then does the comparison so it really only does 1 query, and checks any contact ID against that list.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.