Documentation

MatchOption.php

Implement the "match" and "match-mandatory" options. If the submitted record doesn't have an ID but a "match" key is specified, then we will automatically search for pre-existing record and fill-in the missing ID. The "match" or "match-mandatory" can specified as a string (the name of the key to match on) or array (the names of several keys to match on).

Note that "match" and "match-mandatory" behave the same in the case where one matching record exists (ie they update the record). They also behave the same if there are multiple matching records (ie they throw an error). However, if there is no matching record, they differ:

  • "match-mandatory" will generate an error
  • "match" will allow action to proceed -- thus inserting a new record
$result = civicrm_api('contact', 'create', array(
  'options' => array(
    'match' => array('last_name', 'first_name')
  ),
  'first_name' => 'Jeffrey',
  'last_name' => 'Lebowski',
  'nick_name' => 'The Dude',
));
Tags
copyright

CiviCRM LLC https://civicrm.org/licensing

Table of Contents

Classes

CRM_Utils_API_MatchOption
Class CRM_Utils_API_MatchOption

        
On this page

Search results