1

When I try to open Contacts of some Smart Groups, CiviCRM gives me error:

Expected one CustomField but found 0

enter image description here

All parent Smart Groups that include faulty Smart Groups are also rendering the same error (can't open contacts).

If I try to delete these Smart Groups, I get Network Error. enter image description here

When in Groups tab of Contact profile I open Smart Groups subsection, it remains empty (no Smart groups are listed). Not sure if for all contacts or only those that are included in faulty smart groups.

How can I fix this error?

CiviCRM 4.7.14 on Drupal 7.59

DEBUG INFO (sample 1)

CiviCRM_API3_Exception: "Expected one CustomField but found 0"

#0 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4491): civicrm_api3("CustomField", "getvalue", (Array:3))
#1 sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(452): CRM_Contact_BAO_Query::isCustomDateField("custom_52")
#2 sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(111): CRM_Contact_BAO_SavedSearch::decodeRelativeFields((Array:11), "custom_52", ">=", "35")
#3 sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(197): CRM_Contact_BAO_SavedSearch::getFormValues("custom_52")
#4 sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(590): CRM_Contact_BAO_SavedSearch::getSearchParams("88")
#5 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(3054): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
#6 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2947): CRM_Contact_BAO_Query->addGroupContactCache("132", NULL, "contact_a", "=")
#7 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query->group((Array:5))
#8 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query->whereClauseSingle((Array:5), NULL)
#9 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query->whereClause(NULL)
#10 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query->initialize(NULL)
#11 sites/all/modules/civicrm/CRM/Contact/Selector.php(236): CRM_Contact_BAO_Query->__construct((Array:1), (Array:9), (Array:16), FALSE, FALSE, 1, FALSE, TRUE, FALSE, NULL, 1)
#12 sites/all/modules/civicrm/CRM/Contact/Form/Search.php(832): CRM_Contact_Selector->__construct(NULL, (Array:5), (Array:1), (Array:9), 256, FALSE, TRUE, "smog", (Array:9))
#13 sites/all/modules/civicrm/CRM/Contact/Form/Search/Basic.php(188): CRM_Contact_Form_Search->postProcess()
#14 sites/all/modules/civicrm/CRM/Contact/Form/Search.php(718): CRM_Contact_Form_Search_Basic->postProcess()
#15 sites/all/modules/civicrm/CRM/Contact/Form/Search/Basic.php(134): CRM_Contact_Form_Search->preProcess()
#16 sites/all/modules/civicrm/CRM/Core/Form.php(531): CRM_Contact_Form_Search_Basic->preProcess()
#17 sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Display.php(92): CRM_Core_Form->buildForm()
#18 sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Contact_Form_Search_Basic), "display")
#19 sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Contact_Form_Search_Basic), "display")
#20 sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("display")
#21 sites/all/modules/civicrm/CRM/Core/Invoke.php(310): CRM_Core_Controller->run((Array:3), (Array:0))
#22 sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#23 sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))
#24 sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:3))
#25 /includes/menu.inc(527): civicrm_invoke("group", "search")
#26 /index.php(21): menu_execute_active_handler()
#27 {main}

DEBUG INFO (sample 2)

CiviCRM_API3_Exception: "Expected one CustomField but found 0"

#0 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4491): civicrm_api3("CustomField", "getvalue", (Array:3))
#1 /sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(452): CRM_Contact_BAO_Query::isCustomDateField("custom_21")
#2 /sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(111): CRM_Contact_BAO_SavedSearch::decodeRelativeFields((Array:10), "custom_21", "BETWEEN", (Array:2))
#3 /sites/all/modules/civicrm/CRM/Contact/BAO/SavedSearch.php(197): CRM_Contact_BAO_SavedSearch::getFormValues("custom_21")
#4 /sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(590): CRM_Contact_BAO_SavedSearch::getSearchParams("54")
#5 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(3054): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
#6 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2947): CRM_Contact_BAO_Query->addGroupContactCache("89", NULL, "contact_a", "=")
#7 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query->group((Array:5))
#8 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query->whereClauseSingle((Array:5), NULL)
#9 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query->whereClause(NULL)
#10 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query->initialize(NULL)
#11 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query->__construct((Array:1), (Array:1), (Array:16), TRUE, FALSE, 1, TRUE, TRUE, FALSE, NULL, "AND", NULL)
#12 /sites/all/modules/civicrm/CRM/Contact/BAO/Group.php(200): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
#13 /sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(704): CRM_Contact_BAO_Group::getMember("89", FALSE)
#14 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(3054): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
#15 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2947): CRM_Contact_BAO_Query->addGroupContactCache("77", NULL, "contact_a", "=")
#16 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query->group((Array:5))
#17 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query->whereClauseSingle((Array:5), NULL)
#18 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query->whereClause(NULL)
#19 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query->initialize(NULL)
#20 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query->__construct((Array:1), (Array:1), (Array:16), TRUE, FALSE, 1, TRUE, TRUE, FALSE, NULL, "AND", NULL)
#21 /sites/all/modules/civicrm/CRM/Contact/BAO/Group.php(200): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
#22 /sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(704): CRM_Contact_BAO_Group::getMember("77", FALSE)
#23 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(3054): CRM_Contact_BAO_GroupContactCache::load(Object(CRM_Core_DAO))
#24 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2947): CRM_Contact_BAO_Query->addGroupContactCache((Array:1), NULL, "contact_a", "IN")
#25 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query->group((Array:5))
#26 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query->whereClauseSingle((Array:5), NULL)
#27 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query->whereClause(NULL)
#28 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query->initialize(NULL)
#29 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query->__construct((Array:1), (Array:1), (Array:16), TRUE, FALSE, 1, TRUE, TRUE, FALSE, NULL, "AND", NULL)
#30 /sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(229): CRM_Contact_BAO_Query::apiQuery((Array:1), (Array:1), NULL, NULL, 0, 0, FALSE)
#31 /sites/all/modules/civicrm/CRM/Contact/BAO/GroupContactCache.php(208): CRM_Contact_BAO_GroupContactCache::add((Array:206))
#32 /sites/all/modules/civicrm/CRM/Group/Page/Group.php(144): CRM_Contact_BAO_GroupContactCache::loadAll()
#33 /sites/all/modules/civicrm/CRM/Core/Page/Basic.php(172): CRM_Group_Page_Group->browse(NULL, NULL)
#34 /sites/all/modules/civicrm/CRM/Core/Invoke.php(310): CRM_Core_Page_Basic->run((Array:2), NULL)
#35 /sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#36 /sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:2))
#37 /sites/all/modules/civicrm/drupal/civicrm.module(448): CRM_Core_Invoke::invoke((Array:2))
#38 /includes/menu.inc(527): civicrm_invoke("group")
#39 /index.php(21): menu_execute_active_handler()
#40 {main}

Could it be connected with some Summary Fields extension that has somehow messed up some custom fields? In any case, disabling Summary Fields, changing its settings or updating to newest version does not solve the issue.

  • 1
    Can you reach the Manage group listings? And then see the search criteria for any of the affected smart groups? (Settings> Edit Smart Group Criteria). Might give you a clue as to the fields the smart groups are based on. – Craig Almond Feb 28 at 20:22
  • there have been some issues with 'on hold' showing up in Smart Groups so check that when you 'edit' the saved search – petednz - fuzion Feb 28 at 21:58
  • 1
    We can better answer this question if you post the debugging and backtrace info. Go to Administer menu » System Settings » Debugging and Error Handling and turn on debugging and backtrace. Repeat the steps that lead to this error and you should get a much more detailed error message. Please edit your question to include the expanded error + backtrace as text (i.e. not a screenshot). – Jon G - Megaphone Tech Mar 1 at 3:47
  • @CraigAlmond I'm afraid that Edit Smart Group Criteria renders the same error: Expected one CustomField but found 0 – Aivars Mar 1 at 8:31
  • @JonG-MegaphoneTech Thank you! I added one instance of error with debug / backtrace enabled. – Aivars Mar 1 at 8:39
1

These smart groups include custom fields that no longer exist. In the first case, it's the custom field with id of 52; in the second the id is 21. These smart groups should have their criteria modified to reflect the fact that these groups no longer exist.

  • How can I do it, if the standard way - Edit Smart Group Criteria - produces the same error? – Aivars Mar 2 at 10:28
1

@junglebird on https://chat.civicrm.org/civicrm provided a solution to delete such groups via API Explorer.

Smart groups also have an entry in civicrm_saved_search. I think it would be safer to make a list of the group IDs, go to Support >> Developer >> API Explorer and select Entity of Group, Action of Delete, and set the ID accordingly.

  • This is me - I should try harder to consolidate my CiviCRM usernames :) – Jon G - Megaphone Tech Apr 1 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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