1

I would like to create 2 smart groups. 1 for members under 18 and one for members over 18. There is no search criteria for age rather only a static date. Any idea?

2

There is a way with the CiviRules extension. It's a similar concept as noted here: https://civicrm.stackexchange.com/a/4873/105

Create two tags: Under 18 and 18+.

Create two Rules:

  1. A generic trigger such as "Individual is changed" or "Individual is added". CiviRules has a condition called "Age Comparison". You can set it to less than 18. Then, for the action, 'add Tag to contact' using Under 18.
  2. Same trigger, Age Comparison condition - greater than or equal to 18. But here have two actions: 'add Tag to contact 18+' as well as 'remove Tag from contact - Under 18' (to catch the people after they have turned 18).

Create two smart group that looks for your respective tags. Any time a contact is updated in some way (if you go the 'Individual is changed' route), the Rules will fire and lead to updated smart groups.

  • I installed the extension and set it up as you described. I'm not getting any results. I set the trigger to individual changed, condition is age > 18 and action to tag contact with "18+". To test, I edited a contact and saved but not result. I tried executing the civirules cronjob. Am I missing anything? – Yossi Jan 19 '16 at 6:23
  • OK. I see. It only adds the tag to the individual that was updated. – Yossi Jan 19 '16 at 6:50
  • Yes, the only 'catch' is that it can only go contact by contact. Depending on your comfort level with the API Explorer, you could update all contacts in some safe way and the rule would take effect on all of them. – Allen Hutchison Jan 19 '16 at 7:13
  • Perhaps there is a field you're not using? Fill it in for all contacts via the API explorer and then use the API a second time to empty the field again. That would update the contacts and get you your groups once the smart groups update themselves (based on cron or manually firing the job). – Allen Hutchison Jan 19 '16 at 7:14
  • So I was able to do it for a group of contacts using the trigger called :"Daily trigger for group members". When cron runs it updates everyone in a group – Yossi Jan 19 '16 at 7:15
4

Although it doesn't help you right now, search by age will be in 4.7 - CRM-16160. You can try it in on the demo: http://dmaster.demo.civicrm.org/

0

Not doable via UI afaik, and I don't recall anyone adding a custom search for this but there was a wiki page about that once upon a time - ah here which may give you or someone else a head start - though it may need updating of course.

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.