= CiviCRM API - Adding Custom Values to Case Get Getting entities filtered by the value of custom field is only available for Contacts. Below is a deconstruction of the get API function for Contacts. Hopefully it'll show where the custom field magic happens. Each method gets a section (with the file it is in parenthesis) which contains a list of the functions that it calls. Hopefully I'll add some explanations of the processes that occurs in each later on. == [=#civicrm_api3_contact_get civicrm_api3_contact_get (api/v2/Contact.php)] The API function. 1. [#_civicrm_api3_contact_get_supportanomalies _civicrm_api3_contact_get_supportanomalies (api/v3/Contact.php)] 1. [#_civicrm_api3_get_using_query_object _civicrm_api3_get_using_query_object (api\v3\utils.php)] 1. [#civicrm_api3_create_success civicrm_api3_create_success (api\v3\utils.php)] == [=#_civicrm_api3_contact_get_supportanomalies _civicrm_api3_contact_get_supportanomalies (api/v2/Contact.php)] Changes a few of the parameters around for consistency and convenience. //No functions called// == [=#_civicrm_api3_get_using_query_object _civicrm_api3_get_using_query_object (api\v3\utils.php)] The comment for this function says that it is a general function for more complex //get// requests that is only used currently for Contacts, but can, and should, be extended for use by other entities. However, there is explicit use of the Contact BAO object in the method, so that aint gonna work is it? 1. [#_civicrm_api3_get_options_from_params _civicrm_api3_get_options_from_params (api\v3\utils.php)] 1. civicrm_api($entity, 'getfields', array('version' => 3, 'action' => 'get')); 1. [#CRM_Contact_BAO_Query::convertFormValues CRM_Contact_BAO_Query::convertFormValues (CRM/Contact/BAO/Query.php)] 1. [#CRM_Core_DAO::createSqlFilter CRM_Core_DAO::createSqlFilter (CRM\Core\DAO.php)] 1. [#CRM_Contact_BAO_Query::apiQuery CRM_Contact_BAO_Query::apiQuery (CRM/Contact/BAO/Query.php)] == [=#civicrm_api3_create_success civicrm_api3_create_success (api\v3\utils.php)] This wraps the the values created from the specific API request with things like count and is_error, etc. It also does some legacy shenanigans. Calls nothing else of importance. == [=#_civicrm_api3_get_options_from_params _civicrm_api3_get_options_from_params (api\v3\utils.php)] This function extracts the common API options from the parameters. It also extracts and standardises the 'return' properties. It calls nothing else of importance. == [=#CRM_Contact_BAO_Query::convertFormValues CRM_Contact_BAO_Query::convertFormValues (CRM/Contact/BAO/Query.php)] Converts some of parameters from one format (presumably that used to display them on a form) to another (presumably one used by the database). 1. [#CRM_Contact_BAO_Query::fixDateValues CRM_Contact_BAO_Query::fixDateValues (CRM/Contact/BAO/Query.php)] 1. [#CRM_Contact_BAO_Query::fixWhereValues CRM_Contact_BAO_Query::fixWhereValues (CRM/Contact/BAO/Query.php)] == [=#CRM_Contact_BAO_Query::fixDateValues CRM_Contact_BAO_Query::fixDateValues (CRM/Contact/BAO/Query.php)] Splits a date range into a //to// and //from// parts. Calls no other methods of interest. == [=#CRM_Contact_BAO_Query::fixWhereValues CRM_Contact_BAO_Query::fixWhereValues (CRM/Contact/BAO/Query.php)] Converts a filter to a parameter into an array representing what type of where clause it should be. Calls no other methods of interest. == [=#CRM_Core_DAO::createSqlFilter CRM_Core_DAO::createSqlFilter (CRM\Core\DAO.php)] Converts where clause arrays into the actual where clause strings. Calls nothing else of importance. == [=#CRM_Contact_BAO_Query::apiQuery CRM_Contact_BAO_Query::apiQuery (CRM/Contact/BAO/Query.php)] This function build up the query string. It makes use of a CRM_Contact_BAO_Query object called {{{query}}}. 1. [#query._construct query._construct (CRM/contact/BAO/Query.php)] 1. [#query.generatePermissionClause query.generatePermissionClause (CRM/contact/BAO/Query.php)] 1. [#query.includePseudoFieldsJoin query.includePseudoFieldsJoin (CRM/contact/BAO/Query.php)] 1. [#query.query query.query (CRM/contact/BAO/Query.php)] 1. [#CRM_Core_DAO::executeQuery CRM_Core_DAO::executeQuery (CRM/Core/DAO.php)] 1. [#query.store query.store (CRM/contact/BAO/Query.php)] 1. [#query.convertToPseudoNames query.convertToPseudoNames (CRM/contact/BAO/Query.php)] == [=#query._construct query._construct (CRM/contact/BAO/Query.php)] The constructor refers to {{{self}}} (the current class) and {{{this}}} (the current object). 1. [#self.defaultReturnProperties self.defaultReturnProperties (CRM/contact/BAO/Query.php)] 1. [#this.setOperator this.setOperator (CRM/contact/BAO/Query.php)] 1. [#CRM_Contact_BAO_Contact::exportableFields CRM_Contact_BAO_Contact::exportableFields (CRM/contact/BAO/Query.php)] 1. [#CRM_Core_Component::getQueryFields CRM_Core_Component::getQueryFields (CRM/Core/Component.php)] 1. [#CRM_Activity_BAO_Activity::exportableFields CRM_Activity_BAO_Activity::exportableFields (CRM/Activity/BAO/Activity.php)] 1. [#CRM_Contact_BAO_Query_Hook::singleton.getFields CRM_Contact_BAO_Query_Hook::singleton.getFields (CRM/Contact/BAO/Query/Hook.php)] 1. [#this.initialize this.initialize (CRM/contact/BAO/Query.php)] == [=#self.defaultReturnProperties self.defaultReturnProperties (CRM/contact/BAO/Query.php)] Returns a set of the fields to be returned for the get request. 1. [#CRM_Activity_BAO_Query::defaultReturnProperties CRM_Activity_BAO_Query::defaultReturnProperties (CRM/Activity/BAO/Query.php)] 1. [#CRM_Core_Component::defaultReturnProperties CRM_Core_Component::defaultReturnProperties (CRM/Core/Component.php)] == [=#CRM_Activity_BAO_Query::defaultReturnProperties CRM_Activity_BAO_Query::defaultReturnProperties (CRM/Activity/BAO/Query.php)] Returns a list of activity fields to be returned for the get request. 1. [#CRM_Core_BAO_CustomField::getFieldsForImport CRM_Core_BAO_CustomField::getFieldsForImport (CRM/Core/BAO/CustomField.php)] == [=#CRM_Core_BAO_CustomField::getFieldsForImport CRM_Core_BAO_CustomField::getFieldsForImport (CRM/Core/BAO/CustomField.php)] Returns a list of details about the custom fields for the specified entity. 1. [#self::getFields self::getFields (CRM/Core/BAO/CustomField.php)] == [=#self::getFields self::getFields (CRM/Core/BAO/CustomField.php)] 1. CRM_Contact_BAO_ContactType::subTypes (CRM/Contact/BAO/ContactType.php) - get the subtypes of the class. 1. CRM_Contact_BAO_ContactType::getBasicType (CRM/Contact/BAO/ContactType.php)] - get the basic (parent?) contact type given the subtype. 1. CRM_Core_SelectValues::customGroupExtends (CRM/Core/SelectValues.php)] - gets a list of entity types (i think) 1. CRM_Core_Permission::customGroupClause - Get permission stuff 1. self::getTableName - gets the table name 1. [#CRM_Core_DAO::executeQuery CRM_Core_DAO::executeQuery (CRM/Core/DAO.php)] == [=#CRM_Core_DAO::executeQuery CRM_Core_DAO::executeQuery (CRM/Core/DAO.php)] Instantiates a DAO object and passes it the query to run. The DAO object is by default of type CRM_Core_DAO, but can be of whatever name you pass in. 1. [#self::composeQuery self::composeQuery (CRM/Core/DAO.php)] 1. [#CRM_Core_DAO._constructor CRM_Core_DAO._constructor (CRM/Core/DAO.php)] 1. [#CRM_Core_DAO.query CRM_Core_DAO.query (CRM/Core/DAO.php)] == [=#CRM_Core_DAO.query CRM_Core_DAO.query (CRM/Core/DAO.php)] Runs the query, I think. 1. DB_DataObject.query (DB/DataObject.php) - i think this may be a in a library. == [=#CRM_Core_DAO._constructor CRM_Core_DAO._constructor (CRM/Core/DAO.php)] 1. [#this.initialize this.initialize (CRM/Core/DAO.php)] 1. this->getTableName - dependent on the entity. == [=#this.initialize this.initialize (CRM/Core/DAO.php)] 1. this._connect - from the library parent. == [=#self::composeQuery self::composeQuery (CRM/Core/DAO.php)] Seems to reformat the value for the where clause based on its type. == [=#CRM_Core_Component::defaultReturnProperties CRM_Core_Component::defaultReturnProperties (CRM/Core/Component.php)] // Not Checked// == [=#this.setOperator this.setOperator (CRM/contact/BAO/Query.php)] //Not Checked// == [=#CRM_Contact_BAO_Contact::exportableFields CRM_Contact_BAO_Contact::exportableFields (CRM/contact/BAO/Query.php)] //Not Checked// == [=#CRM_Core_Component::getQueryFields CRM_Core_Component::getQueryFields (CRM/contact/BAO/Query.php)] //Not Checked// == [=#CRM_Activity_BAO_Activity::exportableFields CRM_Activity_BAO_Activity::exportableFields (CRM/Activity/BAO/Activity.php)] //Not Checked// == [=#CRM_Contact_BAO_Query_Hook::singleton.getFields CRM_Contact_BAO_Query_Hook::singleton.getFields (CRM/Contact/BAO/Query/Hook.php)] //Not Checked// == [=#this.initialize this.initialize (CRM/contact/BAO/Query.php)] //Not Checked// == [=#query.generatePermissionClause query.generatePermissionClause (CRM/contact/BAO/Query.php)] //Not Checked// == [=#query.includePseudoFieldsJoin query.includePseudoFieldsJoin (CRM/contact/BAO/Query.php)] //Not Checked// == [=#query.query query.query (CRM/contact/BAO/Query.php)] //Not Checked// == [=#CRM_Core_DAO::executeQuery CRM_Core_DAO::executeQuery (CRM/Core/DAO.php)] //Not Checked// == [=#query.store query.store (CRM/contact/BAO/Query.php)] //Not Checked// == [=#query.convertToPseudoNames query.convertToPseudoNames (CRM/contact/BAO/Query.php)] //Not Checked//