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) »
  • id or entity_id?
Pages: [1]

Author Topic: id or entity_id?  (Read 773 times)

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
id or entity_id?
July 19, 2011, 10:49:46 am
in api/v3/CustomValue.php, the create requires $params['id'], while the get requires $params['entity_id']. Which is the standard?
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: id or entity_id?
July 19, 2011, 01:52:19 pm
I think I might have changed create recently?

id for any api should refer to the id of the api entity (in this case the custom value). If it is the id of the entity it relates to (if it is entity_id in the table) it should be entity_id.

Note that when chaining the function says

"if I am calling contribution api AND the entity_table is set to contribution then I will pass the entity_id into the contact api as ID"

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

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: id or entity_id?
August 05, 2011, 01:29:30 pm
So the create should require $params['id'], and the get should require either 'id' or 'entity_id', since both are unique.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: id or entity_id?
August 05, 2011, 01:34:30 pm
I think the create should require entity_id - ie. the create requires the value that is the entity_id in the relevant table doesn't

The verify_mandatory will always skip any other requirements if 'id' is passed in so

civicrm_api3_verify_mandatory ($params,null,array('entity_id'));

will not require entity_id if 'id' is set
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

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: id or entity_id?
August 05, 2011, 01:47:21 pm
Sorry, that was a mistype on my part: $params['entity_id'] is obviously required for create, not $params['id'] which doesn't yet exist.

Thanks!
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

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

This forum was archived on 2017-11-26.