Running Job.update_greeting without updating customized greetings
Overview
For the scheduled job update_greeting
there are two options for the parameter force
which are explained by the documentation as follows:
-
0
only contacts with null values are updated (default) -
1
update all contacts
There is no explanation about what happens with customized greetings when using force = 1
.
It turns out that all customized greetings will be overridden by the standard greeting. I did not expect this.
It would be great to have another option
-
2
update all contacts excluding customized greetings
If this is not possible, then a more detailed documentation could be helpful.
This issue has also been described on stackexchange.
Work around
Use API v4 to set all greetings that are not customized greetings to NULL. Here an example for individuals and email greeting:
$contacts = civicrm_api4('Contact', 'get', [
'where' => [
['email_greeting_custom', 'IS EMPTY'],
['contact_type', '=', 'Individual'],
],
'chain' => [
'name_me_0' => ['Contact', 'update', ['values' => ['id' => '$id', 'custom_greeting_display' => NULL]]],
],
]);
Afterwards, the greetings are not NULL but already contain the new standard greeting. There is no need to run the job update_greeting
with force = 0
.
Environment information
- CiviCRM: 5.63.2
- PHP: 8.1
- CMS: Drupal 9