Ok so I have successfully created a before_save hook on the contacts module to update 2 custom fields from birthdate. Custom fields are ‘dob_month’ and ‘dob_day’. I use these for reports etc.
All works fine.
However I have several thousand records in contacts, so I don’t want to go through and save each contact to trigger the update. I’m a bit stumped as to how best to go about this and would appreciate some help to get me on the way.
I assume some kind of function to loop through each contact.
you could add a scheduled job. they aren’t triggered by events, but by a pre-set schedule. When your method is invoked, you load the first 50 contacts without a birthday and initiate the save(), as soon as no contacts are left, you can disable the job or reduce its frequency.
Option b is a manual one: have you tried to go to the contacts ListView, select the whole page (or even all records) and do a mass-update on them (depending on your hook, this could take a while)?
Thanks pgr, that did the trick nicely.
I coded a function to run from the scheduler, but for some reason it just refused to run. Given that I should never need to do this again, your solution was muh easier.