Answers.Body: <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-02T10:28:17.040Z
Answers.Text: How can I do it, if the standard way - **Edit Smart Group Criteria** - produces the same error?
Answers.UserDisplayName: Aivars
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-02T08:21:38.617Z
Answers.LastActivityDate: 2019-03-02T08:21:38.617Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>@junglebird on <a href="https://chat.civicrm.org/civicrm" rel="nofollow noreferrer">https://chat.civicrm.org/civicrm</a> provided a solution to delete such groups via API Explorer.</p>
  
  <p>Smart groups also have an entry in <strong>civicrm_saved_search</strong>.  I think it would be safer to make a list of the group IDs, go to <strong>Support >> Developer >> API Explorer</strong> and select Entity of <strong>Group</strong>, Action of <strong>Delete</strong>, and set the ID accordingly.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-01T15:42:01.583Z
Answers.Text: This is me - I should try harder to consolidate my CiviCRM usernames :)
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-29T12:19:29.360Z
Answers.LastActivityDate: 2019-03-29T12:19:29.360Z
Answers.UserDisplayName: Aivars
Body: <p>When I try to open <strong>Contacts</strong> of some Smart Groups, CiviCRM gives me error:</p>
  
  <p><strong>Expected one CustomField but found 0</strong></p>
  
  <p><a href="https://i.sstatic.net/29dxs.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/29dxs.png" alt="enter image description here"></a></p>
  
  <p>All parent Smart Groups that include faulty Smart Groups are also rendering the same error (can't open contacts).</p>
  
  <p>If I try to delete these Smart Groups, I get Network Error.
  <a href="https://i.sstatic.net/SJmOt.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SJmOt.png" alt="enter image description here"></a></p>
  
  <p>When in <strong>Groups tab of Contact profile</strong> 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.</p>
  
  <p>How can I fix this error?</p>
  
  <p>CiviCRM 4.7.14 on Drupal 7.59</p>
  
  <h1>DEBUG INFO (sample 1)</h1>
  
  <p>CiviCRM_API3_Exception: "Expected one CustomField but found 0"</p>
  
  <pre><code>#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", "&gt;=", "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-&gt;addGroupContactCache("132", NULL, "contact_a", "=")
  #7 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query-&gt;group((Array:5))
  #8 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5), NULL)
  #9 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query-&gt;whereClause(NULL)
  #10 sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query-&gt;initialize(NULL)
  #11 sites/all/modules/civicrm/CRM/Contact/Selector.php(236): CRM_Contact_BAO_Query-&gt;__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-&gt;__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-&gt;postProcess()
  #14 sites/all/modules/civicrm/CRM/Contact/Form/Search.php(718): CRM_Contact_Form_Search_Basic-&gt;postProcess()
  #15 sites/all/modules/civicrm/CRM/Contact/Form/Search/Basic.php(134): CRM_Contact_Form_Search-&gt;preProcess()
  #16 sites/all/modules/civicrm/CRM/Core/Form.php(531): CRM_Contact_Form_Search_Basic-&gt;preProcess()
  #17 sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Display.php(92): CRM_Core_Form-&gt;buildForm()
  #18 sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display-&gt;perform(Object(CRM_Contact_Form_Search_Basic), "display")
  #19 sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller-&gt;handle(Object(CRM_Contact_Form_Search_Basic), "display")
  #20 sites/all/modules/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page-&gt;handle("display")
  #21 sites/all/modules/civicrm/CRM/Core/Invoke.php(310): CRM_Core_Controller-&gt;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}
  </code></pre>
  
  <h1>DEBUG INFO (sample 2)</h1>
  
  <p>CiviCRM_API3_Exception: "Expected one CustomField but found 0"</p>
  
  <pre><code>#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-&gt;addGroupContactCache("89", NULL, "contact_a", "=")
  #7 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query-&gt;group((Array:5))
  #8 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5), NULL)
  #9 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query-&gt;whereClause(NULL)
  #10 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query-&gt;initialize(NULL)
  #11 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query-&gt;__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-&gt;addGroupContactCache("77", NULL, "contact_a", "=")
  #16 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query-&gt;group((Array:5))
  #17 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5), NULL)
  #18 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query-&gt;whereClause(NULL)
  #19 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query-&gt;initialize(NULL)
  #20 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query-&gt;__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-&gt;addGroupContactCache((Array:1), NULL, "contact_a", "IN")
  #25 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(1794): CRM_Contact_BAO_Query-&gt;group((Array:5))
  #26 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(2021): CRM_Contact_BAO_Query-&gt;whereClauseSingle((Array:5), NULL)
  #27 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(502): CRM_Contact_BAO_Query-&gt;whereClause(NULL)
  #28 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(466): CRM_Contact_BAO_Query-&gt;initialize(NULL)
  #29 /sites/all/modules/civicrm/CRM/Contact/BAO/Query.php(4330): CRM_Contact_BAO_Query-&gt;__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-&gt;browse(NULL, NULL)
  #34 /sites/all/modules/civicrm/CRM/Core/Invoke.php(310): CRM_Core_Page_Basic-&gt;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}
  </code></pre>
  
  <p>Could it be connected with some <strong>Summary Fields extension</strong> that has somehow messed up some custom fields? In any case, disabling <strong>Summary Fields</strong>, changing its settings or updating to newest version <strong>does not</strong> solve the issue.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-28T20:22:20.073Z
Comments.Text: 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.
Comments.UserDisplayName: Craig Almond
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-02-28T21:58:57.847Z
Comments.Text: there have been some issues with 'on hold' showing up in Smart Groups so check that when you 'edit' the saved search
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-01T03:47:31.997Z
Comments.Text: 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).
Comments.UserDisplayName: Jon G - Megaphone Tech
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-01T08:31:54.923Z
Comments.Text: @CraigAlmond I'm afraid that **Edit Smart Group Criteria** renders the same error: *Expected one CustomField but found 0*
Comments.UserDisplayName: Aivars
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2019-03-01T08:39:05.507Z
Comments.Text: @JonG-MegaphoneTech Thank you! I added one instance of error with debug / backtrace enabled.
Comments.UserDisplayName: Aivars
Tags: <custom-fields><error>
Title: How to troubleshoot "Expected one CustomField but found 0" error?
ThreadText: # How to troubleshoot "Expected one CustomField but found 0" error?
  
  (Asked by: username_0 on 2019-02-28)
  
  When I try to open **Contacts** of some Smart Groups, CiviCRM gives me error:
  
  **Expected one CustomField but found 0**
  
  [![enter image description here](https://i.sstatic.net/29dxs.png)](https://i.sstatic.net/29dxs.png)
  
  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](https://i.sstatic.net/SJmOt.png)](https://i.sstatic.net/SJmOt.png)
  
  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.
  
  **Tags:** custom-fields, error
  
  > **Comments:**
  > **username_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.  
  > **username_2**: there have been some issues with 'on hold' showing up in Smart Groups so check that when you 'edit' the saved search  
  > **username_3**: 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).  
  > **username_0**: @username_1 I'm afraid that **Edit Smart Group Criteria** renders the same error: *Expected one CustomField but found 0*  
  > **username_0**: @username_3 Thank you! I added one instance of error with debug / backtrace enabled.  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_3 on 2019-03-02. Score: 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.
  
  > **Comments:**
  > **username_0**: How can I do it, if the standard way - **Edit Smart Group Criteria** - produces the same error?  
  
  ---
  
  ### Answer by username_0 on 2019-03-29. Score: 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.
  
  > **Comments:**
  > **username_3**: This is me - I should try harder to consolidate my CiviCRM usernames :)  
  
  ---
  
  