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 Import (Moderator: Yashodha Chaku) »
  • Custom php-filled fields reset to default on import
Pages: [1]

Author Topic: Custom php-filled fields reset to default on import  (Read 1275 times)

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Custom php-filled fields reset to default on import
April 02, 2009, 06:29:17 am
Hello.

I have some fields, value of which is controlled by custom hook on update (two of them are char - I use them for alphabetical directory of contacts with views, another - numeric - result of summation).

I've noticed the following behaviour on importing:

I'm importing custom field data on all a number of contacts in my database from a csv with three fields. For half of the contacts those fields are empty, and they are not updated. Other (updated) contacts loose values in the php-filled fields - result of summation drops to 0, characters drop to empty string. Non-updated contacts do not loose the information in those php-controlled fields.

I've implemented those php updates in two functions - one of them is

mymodule_civicrm_custom where I process data from custom fields,

and

mymodule_civicrm_post where I process data from the last name - to capture first letter, as last name is not available inside mymodule_civicrm_custom.


Could this be caused by import script? I cannot replicate this in sandbox as I do not have a relevant access...

And would it be possible to run those php-update scripts as a cron job somehow?

Regards,
Danila

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 php-filled fields reset to default on import
April 02, 2009, 06:51:37 am

1. does this work when u update  contact individually via the edit form. If so, then the bug is potentially with the sequence of calls that import makes

2. can u cut-n-paste your hook definitions and give us the structure of your custom table so we can try to reproduce on our localhost. alternatively can u give u ssh access and we can debug on your box (if so contact us on IRC)

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

DanilaD

  • I post occasionally
  • **
  • Posts: 93
  • Karma: 11
Re: Custom php-filled fields reset to default on import
April 25, 2009, 03:31:06 am
Hello, Lobo.

I've solved this. In some cases hook_civicrm_post is called with $objectRef containing a lot uninitialized fields. I did not catch those cases, and as a result empty strings got into my custom php-controlled code.

I now filter out these situations using if ( isset ($objectRef->last_name)) {

Regards,
Danila

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Import (Moderator: Yashodha Chaku) »
  • Custom php-filled fields reset to default on import

This forum was archived on 2017-11-26.