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) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Using new address location = OldAddress as way of dealing with old address
Pages: [1]

Author Topic: Using new address location = OldAddress as way of dealing with old address  (Read 832 times)

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Using new address location = OldAddress as way of dealing with old address
January 30, 2010, 09:28:41 pm
When someone is known to have moved, eg envelope returned 'gone no address' one approach we have used it so copy old address to Notes and insert GNA (Gone No Address) in to Address field.

Wondering if there might be a better approach that would use a new Location Type of 'Former Home Address'

Then when someone is known to have moved we could just reset the Location - but of course this can't work if there is no other address that can be set to Primary Address.

So wondering if in the long term schema there would be any option to add a 'expired' address checkbox that could override Primary? Ie the person would have no Primary Address since they have none that can be used for mailing purposes.

Meanwhile a hybrid of the above, ie put GNA in the new 'home' address and make that Primary, and keep the old adress as a 'FormerHome' will work for this exercise
« Last Edit: January 30, 2010, 09:36:01 pm by peterd »
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

Sean Madsen

  • I post occasionally
  • **
  • Posts: 98
  • Karma: 5
  • CiviCRM implementer/developer
    • Bikes Not Bombs
  • CiviCRM version: 4.6
  • CMS version: Drupal 7
Re: Using new address location = OldAddress as way of dealing with old address
February 12, 2010, 07:07:34 am
Yes, I have been wanting this functionality too. It's very useful for us to keep track of people's invalid addresses because a lot of times people will donate using checks that have old addresses (and we don't want to enter those addresses in again only to have them deleted again).

What I have done is created a new location type called "NoLongerValid". When we get our returned mail, a volunteer goes through it and marks all the addresses as the location "NoLongerValid" (as opposed to "Home", "Work", etc). Then I have a sql script that runs from the nightly cron that takes these NoLongerValid addresses and moves them in to the notes. Here is the script:

Code: [Select]
/* put NoLongerValid addresses into the notes */

set @invalid_location_prefix = 'NoLongerValid';
insert into civicrm_note
select
  NULL as id,
  'civicrm_contact' as entity_table,
  a.contact_id as entity_id,
  a.note as note,
  coalesce(min(log.modified_id), a.contact_id) as contact_id,
  a.log_date as modified_date,
  'Bad Address' as subject
from (
  select
    addr.id as address_id,
    addr.contact_id as contact_id,
    concat_ws(', ', street_address, supplemental_address_1,
      supplemental_address_2, supplemental_address_3,
      city, state.abbreviation, postal_code) as note,
    max(log.modified_date) as log_date
  from civicrm_address addr
  left join civicrm_state_province state
    on state.id = addr.state_province_id
  join civicrm_location_type loc
    on addr.location_type_id = loc.id
  left join civicrm_log log
    on log.entity_table = 'civicrm_contact' and log.entity_id = addr.contact_id
  where loc.name like concat(@invalid_location_prefix,'%')
  group by addr.id
  ) a
left join civicrm_log log
  on log.modified_date = a.log_date and a.contact_id = log.entity_id
  and log.entity_table = 'civicrm_contact'
group by a.address_id;

delete addr from civicrm_address addr
join civicrm_location_type loc
  on addr.location_type_id = loc.id
where loc.name like concat(@invalid_location_prefix,'%');

It's definitely a work-around for the missing functionality of being able to set an address as invalid though

(Also as a side note, I'd like to be able to attach a note to an address, see when an address was last updated, and check boxes for each address about whether that address should be used in bulk mailings.)

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Using new address location = OldAddress as way of dealing with old address
February 12, 2010, 11:15:15 am

Adding a user extensible status (statii) field to an address along with a note field has come up a few times and would make a great community contribtuion :). This has come up a couple of times in the recent past

contact us on IRC if u'd like to work on it and submit a patch

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Using new address location = OldAddress as way of dealing with old address

This forum was archived on 2017-11-26.