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) »
  • Custom address fields with Shared Address - tokens not working
Pages: [1]

Author Topic: Custom address fields with Shared Address - tokens not working  (Read 729 times)

linkx

  • I post occasionally
  • **
  • Posts: 86
  • Karma: 7
Custom address fields with Shared Address - tokens not working
October 02, 2014, 07:34:45 am
I created a set of custom fields 'Used For: Addresses' containing two custom alphanumeric text fields.

I inserted the tokens for my custom fields under Administer > Localization > Address settings

Many of my contacts use a "Shared Address" as their Primary address (shared with employer). This models our data perfectly.

Problem: when I run mailing labels for a group of contacts, the custom address fields do not appear on the labels for contacts that use a Shared Address as their Primary address—I would like to see the custom field values from the shared address (their employer's address) appear on the label.

The custom address field values work for the contacts that do not use Shared Address.

I understand that this is probably due to custom address field tokens not supporting Shared Addresses. How can we change this?

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 07:45:40 am
Hi Linkx,

I agree that probably this is something that core CiviCRM should address - but I had to deal with this in a rush about 2 weeks ago, so I wrote an extension for this.  Because it was a rush job, it's not very robust - it deals with syncing a single custom field, and it's set up with a couple of hard-coded values.  It's on a private git repo, but if you're interested in adapting it to your needs, I can put it on Github.

Jon
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

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: Custom address fields with Shared Address - tokens not working
October 02, 2014, 07:45:59 am
Would be great if you can hire / sponsor a developer to add custom field support in shared address. I suspect this is a 15-25 hour project. Based on Jon's reply, might be great just to hire palante-tech to generalize their solution and add it to core

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

linkx

  • I post occasionally
  • **
  • Posts: 86
  • Karma: 7
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 08:23:10 am
Thanks Jon,

Yes, please post it on GitHub or even https://gist.github.com/ - I plan to also deal with it "in a rush". I'm sure that with your starting point I can put together what I need.

@lobo I will consider proposing to management that we sponsor the development of this in core.

Thanks!

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 08:28:58 am
linkx,

Here you go:
https://gist.github.com/PalanteJon/e5983d7b88a70119488c

Note that I tried writing this with hook_civicrm_post and hook_civicrm_pre before settling on this as the best approach, though YMMV.
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

linkx

  • I post occasionally
  • **
  • Posts: 86
  • Karma: 7
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 08:44:58 am
Thanks Jon!

I don't have experience with Civi extensions, so (1) What is the file sharedaddressstatussync.civix.php that is required? and (2) where to I put the file(s) in my CiviCRM (4.5, D7) installation?

Yah, I know, read the docs ... http://wiki.civicrm.org/confluence/display/CRMDOC/Create+an+Extension

;)

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: Custom address fields with Shared Address - tokens not working
October 02, 2014, 09:03:53 am

@linkx: thanx. hopefully u r successful in convincing folks to get this in core and avoid more people walking down the hack-it-together path

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

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 11:24:42 am
Hi linkx,

If you don't have experience with extensions, my gist won't help you!  I just published the full extension, which SHOULD work if you drop it into your extensions directory, go to Administer menu > System Settings > Manage Extensions, then install/enable it.  Though be forewarned, I just changed the namespace from my client's org to coop.palantetech, so hopefully I didn't break anything.

You already said "read the docs" - I'll say that this is the page you want: http://wiki.civicrm.org/confluence/display/CRMDOC/Create+a+Module+Extension

If you end up improving my extension, please submit the code back, and I'll of course credit you appropriately.

Oh, almost forgot: https://github.com/PalanteJon/coop.palantetech.module.sharedaddressstatussync
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

linkx

  • I post occasionally
  • **
  • Posts: 86
  • Karma: 7
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 01:13:36 pm
Thanks Jon! I do have some basic PHP abilities and a good understanding of CiviCRM so I am not totally hopeless; just haven't used an extension before.

I'll be able to change up the namespace and the groupID and custom field ID to suit my deployment.

You are too nice to be providing this! Cheers  8)

linkx

linkx

  • I post occasionally
  • **
  • Posts: 86
  • Karma: 7
Re: Custom address fields with Shared Address - tokens not working
October 02, 2014, 03:17:47 pm
I got it to work ;)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • Custom address fields with Shared Address - tokens not working

This forum was archived on 2017-11-26.