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) »
  • set communication preferences through the api
Pages: [1]

Author Topic: set communication preferences through the api  (Read 1430 times)

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
set communication preferences through the api
December 13, 2009, 10:45:49 am
Howdie,

Can I set communication preferences through the api?

They are in the civicrm_contact so I thought that I might be able to retreive it with

Code: [Select]
$params=array(
'contact_id' => '999',
'postal_greeting_custom' => '%',
);
civicrm_contact_get($params);

But nope.

I am guessing that maybe this isn't in the api yet because the communication preference improvements are pretty new.

Is it trivial to add these to the API (something I could have a shot at?) or should I try and do a work around.

All I am using the API for is to update these once during an import. 

I'm thinking that a workaround would be kind of safe because we'll just need to update the two fields in that table postal_greeting_id to 4 and postal_greeting_custom to the text.

Is that all I need to do?

Cheers,
Michael
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: set communication preferences through the api
December 14, 2009, 01:26:11 pm
OK, so all I really want to know at the moment is if I've forgetten any FK contstraints / I'm going to corrupt my database if I run SQL statements like this:

UPDATE civicrm_contact SET
postal_greeting_id=4,
postal_greeting_custom='Dear Gavin and Stacey',
postal_greeting_custom='Dear Gavin and Stacey'
WHERE external_identifier='123';

Being pretty cautious here remembering the after effects of reckless SQL before :'(
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Michael McAndrew

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1274
  • Karma: 55
    • Third Sector Design
  • CiviCRM version: various
  • CMS version: Nearly always Drupal
  • MySQL version: 5.5
  • PHP version: 5.3
Re: set communication preferences through the api
December 14, 2009, 02:08:28 pm
From IRC
Quote
You rejoined the room.
[21:26] michaelmcandrew: howdie, anyone able to give me a steer on this forum post? http://forum.civicrm.org/index.php/topic,11276.0.html
[21:27] davidstrauss joined the chat room.
[21:29] dlobo: hey michaelmcandrew
[21:29] dlobo: yeah, the only FK u r using in there is postal_greeting_id
[21:29] michaelmcandrew: hi lobo - how's it going?
[21:29] dlobo: so u might want to check that and make sure thats valid and has a value of 4
[21:33] michaelmcandrew: ok - i'm not 100% sure how to do that.  i am looking in civicrm_option_value
[21:33] dlobo: yeah
[21:33] dlobo: check the value of the custom_greeting label/name
[21:38] michaelmcandrew: SELECT * FROM civicrm_option_group
[21:38] michaelmcandrew: JOIN civicrm_option_value ON civicrm_option_group.id=civicrm_option_value.option_group_id
[21:38] michaelmcandrew: WHERE civicrm_option_group.name='postal_greeting'
[21:39] michaelmcandrew: this gives me what i want.  4 is the value for when it is customised.  OK - thanks - so it isn't in the api yet, right? and that is because it is new, right?
[21:41] michaelmcandrew: is there any other caching, etc. as far as you know? - i need to add this data to any other tables?
[21:42] ekiczek left the chat room.
[21:44] dlobo: michaelmcandrew: i dont think so
[21:44] dlobo: but i did not work on that code, so not 100% sure
[21:45] michaelmcandrew: thanks lobo - i'll post this to the forum and if no one yells, I'm cross my fingers and hold my breath
Service providers: Grow your business, build your reputation and support CiviCRM. Become a partner today

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • set communication preferences through the api

This forum was archived on 2017-11-26.