CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Expanding functionality of UpdateGreeting.php
Pages: [1]

Author Topic: Expanding functionality of UpdateGreeting.php  (Read 1454 times)

kmarkley

  • I post frequently
  • ***
  • Posts: 178
  • Karma: 14
  • CiviCRM version: 4.4.3
  • CMS version: Drupal 7.24
  • MySQL version: 5.1.56
  • PHP version: 5.3.27
Expanding functionality of UpdateGreeting.php
March 01, 2010, 08:57:28 am
I had completely incorrect expectations of how UpdateGreeting.php should work. 

As discussed in this thread, contacts that are imported, created by event registration, or created by drupal registration have all their greetings set to NULL.  Currently in my DB, 95% of all contacts have NULL greetings.

I thought I could use UpdateGreeting.php to populate these fields in advance of sending out a snail mailing.  Unfortunately, I have just (finally) come to realize that the script ignores NULL greetings by design. (see this thread).

It is possible to update NULL greetings by setting the force=1 flag in the URL.  The downside to this approach is that it will also overwrite the handful of contacts that have had their greetings changed from the default.

So I wold like to propose that UpdateGreeting.php be expanded to include the use case of populating empty greeting fields.  Perhaps by setting force=2, the script could update ONLY those contacts with for which no greeting has been set.  This would also make the script useful as a cron job to periodically 'clean up' by creating default greetings for contacts recently created via event or drupal registration.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Expanding functionality of UpdateGreeting.php
March 03, 2010, 06:51:26 pm
Kirk - I agree that the script needs a 'mode' where it updates NULL greetings only (to the default) - and doesn't change greetings that are set. I'll be posting an issue / fix for this shortly. Will add the link here.

We'll also be looking at the possibility of setting greetings / addressee values when contacts are created via profiles.
Protect your investment in CiviCRM by  becoming a Member!

kmarkley

  • I post frequently
  • ***
  • Posts: 178
  • Karma: 14
  • CiviCRM version: 4.4.3
  • CMS version: Drupal 7.24
  • MySQL version: 5.1.56
  • PHP version: 5.3.27
Re: Expanding functionality of UpdateGreeting.php
March 05, 2010, 08:25:51 am
Cool.  I have actually made a patch for this to solve my immediate needs, but I haven't had time to test it thoroughly.  Also, I wasn't sure if setting force=2 was really the right approach for telling the script to process null greetings.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Expanding functionality of UpdateGreeting.php
March 06, 2010, 01:43:17 pm
I've filed an issue for fixing the 'holes' in the UpdateGreeting.php script at:

http://issues.civicrm.org/jira/browse/CRM-5921

I will be discussing it w/ Kurund on Monday to get his feedback on the proposed changes. If you have thoughts on how the proposed new behavior fits your use cases - please post here or comment directly on the issue.
Protect your investment in CiviCRM by  becoming a Member!

kmarkley

  • I post frequently
  • ***
  • Posts: 178
  • Karma: 14
  • CiviCRM version: 4.4.3
  • CMS version: Drupal 7.24
  • MySQL version: 5.1.56
  • PHP version: 5.3.27
Re: Expanding functionality of UpdateGreeting.php
March 06, 2010, 02:47:37 pm
Contacts have greetings that are default (D), custom (C), or null (N).

Curent configuration is:
force=0D
force=1DCN

There are at least 3 approaches to extend this. 

Either add to the values that force can take:
force=0D
force=1DCN
force=2N
which has the advantage of not changing anyone's current use of the script.

Add dimensions for each greeting state:
force=1C
default=1D
null=1N
used in any combination.

Or explicitly define which greeting states get updated on each run:
proc=default, 0, or absentD
proc=custom or 1C
proc=null or 2N
just like the way contact_type (ct) and greeting_type (gt) are defined now.  force=1 could still be interpreted as process all states (effectively overriding proc= if set)


My use case is satisfied as long as there is some combination of flags that process null greetings only.  That said, the third approach seems most consistent with current usage.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Expanding functionality of UpdateGreeting.php
March 08, 2010, 03:16:04 pm
The 3.1.4 implementation as spec'd in the issue tracker will process NULL greetings only by default (i.e. when no force=N is passed). This seems to be the most common use case, so we've made it the default behavior. It handles contacts created w/ NULL *_greeting_id OR address_id, as well as contacts who haviing a value for the _id, but don't have the _display value set. This second condition can happen during contact IMPORT (since the import code doesn't set the _display (evaluated) value.

We also are hoping to get the 'profiles do not set greeting / addressee data' problem fixed in 3.1.4:
http://issues.civicrm.org/jira/browse/CRM-5922
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Feature Requests and Suggestions (Moderator: Dave Greenberg) »
  • Expanding functionality of UpdateGreeting.php

This forum was archived on 2017-11-26.