Skip to content
Snippets Groups Projects
Commit 479311a1 authored by Seamus Lee's avatar Seamus Lee
Browse files

Update custom data for apiv4 mentioning the class used for OOP coding format...

Update custom data for apiv4 mentioning the class used for OOP coding format for Multi Record Custom data sets
parent 605aa762
No related branches found
No related tags found
No related merge requests found
...@@ -10,12 +10,32 @@ For setting custom date fields, date format is anything understood by `strtotime ...@@ -10,12 +10,32 @@ For setting custom date fields, date format is anything understood by `strtotime
## Multi-Record Custom Data ## Multi-Record Custom Data
Multiple record custom data sets are treated by the API as entities, which work similarly to other entities attached to contacts (Phone, Email, Address, etc.). For example, creating a multi-record set named "Work_History" could then be accessed via the API as an entity named "Custom_Work_History". Creating a record would be done like so: Multiple record custom data sets are treated by the API as entities, which work similarly to other entities attached to contacts (Phone, Email, Address, etc.). For example, creating a multi-record set named "Work_History" could then be accessed via the API as an entity named "Custom_Work_History" when accessing it via all forms except for in the PHP Object Oriented format, in that format the class you will be accessing is `CustomValue`. Creating a record would be done like so:
Object Oriented format:
```php
$results = \Civi\Api4\CustomValue::create('Test_Multi_record_custom_fields')
->addValue('entity_id', 202)
->addValue('Test_Field', 555)
->execute();
```
Traditional:
```php ```php
civicrm_api4('Custom_Work_history', 'create', $params); civicrm_api4('Custom_Work_history', 'create', $params);
``` ```
```javascript
CRM.api4('Custom_Test_Multi_record_custom_fields', 'create', {
values: {"entity_id":202, "Test_Field":555}
}).then(function(results) {
// do something with results array
}, function(failure) {
// handle failure
});
```
## Try It Out ## Try It Out
Once you have created some custom data in your system, look for it in the API explorer. Single-record data will appear as fields on the entities they extend, and multi-record data will appear in the list of entities (look under "C" alphabetically as they all start with the prefix "Custom_". Once you have created some custom data in your system, look for it in the API explorer. Single-record data will appear as fields on the entities they extend, and multi-record data will appear in the list of entities (look under "C" alphabetically as they all start with the prefix "Custom_".
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment