1

I'm just wondering how can I update a group in CiviCRM using a smart group. Would it be possible to do this via a scheduled job.

Any thoughts would be highly appreciated

  • Could you ask your question slightly differently? I don't think it's clear what you're trying to do. – Jon G - Megaphone Tech Nov 3 '17 at 18:46
  • Hi John What I'm trying to do is show CiviCRM group data in Drupal views however there's no clear way of doing this using a smart group. That's why I would like to update the group of contacts using the smart group – Gayan Rodrigo Nov 6 '17 at 9:20
  • In that case, your question is actually, "How do I display smart group data in a View?" That has a different answer. See below. – Jon G - Megaphone Tech Nov 6 '17 at 16:21
0

There are a couple of ways to accomplish what you want. First - since your end goal is displaying smart group data in a View, you can instead just install the civicrm_views_smartgroup module. See this question: Can Drupal Views filter contacts based on Smart Groups

Another way to accomplish what you're trying to do is to add members to the static group using the CiviRules extension and remove the smart group entirely. If CiviRules has the correct triggers/rules to accomplish this for your use case, I recommend this approach for performance reasons.

Finally - I might be tempted to try to write some SQL that runs on a timer - either through cron or the Scheduled SQL Tasks extension. This is a bit risky - I'm not 100% sure how to guarantee that the smart group cache is populated at the moment your SQL runs. This is the closest to what you're requesting, but is a risky move that could put your database in an unusable state if you don't know what you're doing.

  • Thank you so much. I think 2nd method might be the most suitable option. – Gayan Rodrigo Nov 7 '17 at 15:30
0

The only time I had to replace a smart group by a "normal" group was for performance reason when we started to have more than a million contacts.

Otherwise, I'd suggest to use the smart groups as you would use a normal group, and if you have performances issues, start by increasing the smart cache duration and enable the cronjob that automatically re-build them

  • Hi Xavier What I'm trying to do is show CiviCRM group data in Drupal views however there's no clear way of doing this using smart groups. That's why I would like to update the group of contacts using the smart group – Gayan Rodrigo Nov 6 '17 at 9:20

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.