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
CiviCRM Stack Exchange is a question and answer site for administrators and users of the CiviCRM Constituent Relationship Management software. It only takes a minute to sign up.Sign up to join this community
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.
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