Skip to content
Snippets Groups Projects
custom-data.md 1.36 KiB
Newer Older
  • Learn to ignore specific revisions
  • # APIv4 and Custom Data
    
    Custom data attached to entities is referenced in the format of `custom_group_machine_name.custom_field_machine_name`.
    
    To set a custom field, or find entities with custom fields of a particular value, you typically use a parameter like this:
    
    ```php
    $values['custom_field_reference'] = 'value';
    ```
    
    To return custom data for an entity just include the machine name of the custom data in the select array.
    
    
    For setting custom date fields, date format is anything understood by `strtotime`, e.g. "now" or "-1 week" or "2020-12-25"
    
    This is just a brief introduction; each API may have different requirements and allow different formats for accessing the custom data. See the [API function documentation](/api/index.md) and also read the comments and documentation in each API php file (under `civicrm/CRM/api/v3` in your CiviCRM installation) for exact details,
    
    which vary for each API entity and function.
    
    !!! note 
    
        When retrieving custom data from a multiple record custom group set the custom data will be returned as an array of custom fields which contains the value and the id of the row in the custom field table.
    
    Multiple record custom data sets are treated as an entity for the purposes of creating records. So you can just specify the values in the same way as for any other create. e.g.
    
    ```php
    civicrm_api4('Custom_My_Cool_Fields', 'create, $params)
    ```