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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Aargh - a loop
Pages: [1]

Author Topic: Aargh - a loop  (Read 1052 times)

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Aargh - a loop
January 15, 2012, 09:40:38 pm
I have been going made figuring out where I was going wrong & have just figured it out but don't know the fix.

Basically I want to update a civicrm_contact custom field based on an address field.

Using the address hook I can set it - but it seems that when I am working off the contact dashboard there is a subsequent save of custom data which over-writes it. I can see it happening in the civicrm_custom hook - but there is no way I can see to prevent it.....

I suppose I could do it at the form layer but then I'd have to figure out all the possible ways that the data could be set (all the forms) which seems like a bit of a pig.

I feel perhaps a civicrm_custom_pre hook would be the answer.
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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: Aargh - a loop
January 16, 2012, 07:51:52 am

One option would be to:

1. remember the info you want to store in the address hook and store it.

2. when u get the custom hook, store the info again (if it does come here again)

not great, but a workaround

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

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: Aargh - a loop
January 16, 2012, 11:49:24 am
Hmm - I could do that if it were a PRE hook. I suppose I still can - like:

1) save custom info
2) custom info gets overwritten
3) in post hook straight after data overwritten call to re-update it
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Aargh - a loop
January 18, 2012, 11:20:46 pm
I have used that structure, storing info in a pre hook and re-update in a postProcess....it works, but is a tad cumbersome :-)
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Aargh - a loop

This forum was archived on 2017-11-26.