Skip to end of metadata
Go to start of metadata

Version 3.0+ includes a scheduled job (command line script) that allows you to update the cached values for Email Greeting, Postal Greeting and / or Postal Addressee for all contacts. These fields will generally be set to the system default values when records are created or imported. However if you decide to change the default format, or find the the values are not populated for some contacts - you can use this job to populate missing values or force a change to the value for all contacts.

It is strongly recommended that test this script against a TEST COPY of your database first, and that you take a backup of your CiviCRM database prior to running this script on your production database.

If the force=1 argument is passed, greeting data will be updated/overwritten for ALL contacts, overwriting any current values for that data.

Script: bin/cron.php OR bin/cli.php
Syntax: Refer to Managing Scheduled Jobs

Note: You can also run this script from the Manage - Scheduled Jobs page.  Edit the job to set the desired parameters, then run the script by selecting 'more/Execute Now'.
Parameters:

ct

Contact Type

required

"Individual" or "Organization" or "Household"

gt

Greeting or Address Type

required

"email_greeting" or "postal_greeting" or "addressee"

id

Option value for greeting or addressee format

optional

uses default format if this parameter not supplied

limitLimit the number of greetings to updateoptional

numeric, will select that many greetings to update

forceForce change/update of all greetingsoptional0 or 1, 1 forces change/update of all greetings

If too many contacts are in your database and need updating, or if your server is not powerful enough, then this script might timeout. When this happens, no change will be written to the database. If this is the case, use the 'limit' parameter to process a limited number of contacts at a time. A value of 1,000 for the limit parameter is appropriate for an entry-level server, you can fine-tune this value for your particular server and number of contacts.

EXAMPLE: Using curl to run this script to update Postal Greeting format for all Individual contacts to use the default format specified at Administer CiviCRM >> Communications >> Postal Greetings

Note: Syntax only permits one set of parameters at a time. To update all contact types and/or all greetings/addressee fields you must run the script for each contact type and for each greeting/addressee type.  Thus each entry below exhibits an example of FORCEFUL updating all the greeting/addressee types for Individuals, you would substitute Household or Organization to update those as well.  You can simply copy and paste these into the "Command Parameters" box within this Scheduled Job (follow Edit link to locate the box that you place these parameters into).

EACH PARAMETER SET MUST BE RUN ON ITS OWN AND CANNOT BE ENTERED INTO BOX WITHOUT LINE BREAKS

ct=Individual
gt=email_greeting
force=1
limit=1000

ct=Individual
gt=postal_greeting
force=1
limit=1000

ct=Individual
gt=addressee
force=1
limit=1000

Refer to Managing Scheduled Jobs and Running Command-line Scripts via URL for general information about running command-line scripts in CiviCRM.

Labels
  • None