I may be blind but I can't see any api call to delete a custom value?!

CustomValue entity is missing a delete action.

What am I missing?

  • Please let me know what version of Civicrm are you using Commented Jan 28, 2016 at 9:13
  • sorry. current drupal 7, civi 4.6.10
    – nielo
    Commented Jan 28, 2016 at 10:53

4 Answers 4


If you have the ID of the row you want to delete and the custom group ID you can use CRM_Core_BAO_CustomValue::deleteCustomValue

$dao = CRM_Core_BAO_CustomGroup::class;
$groupID = CRM_Core_DAO::getFieldValue($dao, 'Emergency_Contacts', 'id', 'name');
CRM_Core_BAO_CustomValue::deleteCustomValue($id, $groupID);

Which deletes an entire row from the custom value table for this custom group.

  • It's not really what you asked for (an API call) but I couldn't find anything else and this helped me anyway.
    – mickadoo
    Commented Nov 9, 2017 at 21:07
  • 1
    Yeah, this could be useful. Too sad I don't remember for what exact reason I did ask this question :D But I know, it will be beneficious some day.
    – nielo
    Commented Nov 10, 2017 at 20:17

Currently, you can't do this. If you try, you will get the notice:

API (CustomValue, delete) does not exist (join the API team and implement it!)

This is true for CiviCRM version 4.7.7, which is current at time of writing.

  • I just checked the latest version and you do have replace option in this version - just replace the custom value to the new value - you dont have to delete the row Commented May 26, 2016 at 14:53
  • Replace is not the same as delete. Delete implies there is no new value.
    – moopet
    Commented May 26, 2016 at 15:36
  • If that is the case - please create a new issue for the same which will get fixed in the future release - thanks Commented May 26, 2016 at 15:48
  • I don't have a separate question - I am answering the question here.
    – moopet
    Commented May 26, 2016 at 16:00

API delete option for Custom value is missing in this version Please upgrade your Civicrm version to the latest version of Civicrm

please give a quick test http://d46.demo.civicrm.org/civicrm/api/explorer#explorer where you will find the delete action

  • Thank you. Although there is no such option in the linked demo-civicrm, I assume you're right and it's a version problem. Hope 4.7 will fix it – I'll upgrade in the next days.
    – nielo
    Commented Jan 29, 2016 at 8:49
  • 1
    That link is out of date. Also version 4.7.7 does not have the option to delete either, so this answer is wrong.
    – moopet
    Commented May 26, 2016 at 13:56
  • @moopet the answer was give to version civi 4.6.10 - if you need the same option for the latest if it is missing then please raise a issue Commented May 26, 2016 at 14:46
  • 1
    Your answer doesn't say anything about whether it appears in a newer version or not - your link is broken and from the look of it (d46.*) it's for the same version in the question comments.
    – moopet
    Commented May 26, 2016 at 15:34
  • Sorry, had to accept another answer.
    – nielo
    Commented Nov 10, 2017 at 20:18

Do you mean the value entered in a custom field, or an available option?

If the former, you should enter an empty string using custom_value.create api.

For the latter, use option_value.delete api.

  • Thanks. It's the former. But your solution does not make the contact to "not-have" that custom value. I meant, if I attach a set of a multiple records custom dataset to an entity, how to delete and detach this dataset, so that the contact appears as if it never had such custom data. At the moment a contact which gets such a dataset will forever be found when searching for contacts holding such datasets.
    – nielo
    Commented Oct 25, 2016 at 19:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.