Improve CustomValue API
During the few months of working with CiviCRM, I have often found myself limited working with CustomValue API. Not sure if I am missing something but suggesting the following improvements so it would make life a bit easier
For CustomValue get API
- Remove limitation of retrieving only 1 value for multiple custom data groups for Contact entity.
- This appears not to be the case, but the documentation says only returns 1 row
- Add ability to retrieve values by custom group id/name possibly combined with entity id
- This would make it easier to retrieve all data for a particular custom group, even disregarding entity and entity id
- Add an API parameter like "custom_group_id" perhaps?
- In the api explorer, add a separate parameter to select Entity (a select option perhaps?)
- If the entity is selected, make Entity ID a chain select so it would display drop down list of entity ID's related to that entity
- Add parameter "ID" (custom value id) in the API explorer so we can directly obtain value related to certain row ID coupled with custom group id
- Reformat the way values are returned from the API. Few suggestions:
- group multiple custom values together into a separate array such as: "values":["id": 1, "latest":"first value" ,"custom_values":[23:"first value", 43:"second value"]] make "latest" value display ID rather than actual value, so we can get it from "custom_values" array
- if implementing above (2.), group by entity id etc.
- Make entity_id NOT mandatory instead have separate combinations of 2 or more fields mandatory for eg: as in (5.) above, if custom_value_id is specified, custom_group_id should be mandatory
I think rather than trying to automatically figure out which entities/values to select from, would be better to give more flexibility to the developer via the API and prepare more comprehensive documentation.
Add "delete" method for CustomValue actions
- custom_value_id combined with custom_group_id to delete specific custom value row
- custom_field_id to delete all values for that custom field
- custom_group_id to delete all values for that custom group
- can combine all of the above with entity_id to delete only for that one