Answers.Body: <p>So this all boiled down to <a href="https://lab.civicrm.org/dev/core/issues/337" rel="nofollow noreferrer">this issue</a>, which has to do specifically with custom fields that are integer selects, and it was impacting both the custom fields and the relationships sections of the advanced search since I was using the same custom field on a custom relationship.</p>
  
  <p>The short-term fix is I went into the database and made the custom field in question not searchable and set is_search_range to 0 as well, which resolved the issue with the relationships section on advanced search throwing an error. </p>
  
  <p>That does mean that for the time being I can't search by that custom field, which is unfortunate since it's kind of a key piece of what I might want to sort/filter by, but I'll keep an eye on the bug and if push comes to shove I can always change that custom field into a text field and rework things since in this case although the data is integers it doesn't have to be since I'm not running math on it or anything, it's essentially just a numeric label.</p>
  
  <p>Hope that helps someone else who runs into this with some thought process or at least raises awareness about the bug.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-26T21:32:11.087Z
Answers.LastActivityDate: 2018-10-26T21:32:11.087Z
Answers.UserDisplayName: Matt Woodward
Body: <p>I'm on CiviCRM 5.6.0 on WordPress 4.9.8, and I have created some custom relationships, all with contact type A of individual, and contact type B of organization.</p>
  
  <p>When I go to Search -> Advanced Search and expand the Relationships section, I get this notice:
  Network Error
  Unable to reach the server. Please refresh this page in your browser and try again.</p>
  
  <p>When I check the logs, this is the full error message that occurs when I expand the Relationships section:</p>
  
  <p><code>[Wed Oct 24 15:42:05.499499 2018] [proxy_fcgi:error] [pid 32638:tid 140566905980672] [client X.X.X.X:56697] AH01071: Got error 'PHP message: PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contact/Form/Search.php on line 301\nPHP message: PHP Warning:  array_key_exists(): The first argument should be either a string or an integer in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contact/Form/Search.php on line 301\n', referer: https://XXXX/wp-admin/admin.php?page=CiviCRM&amp;q=civicrm%2Fcontact%2Fsearch%2Fadvanced&amp;reset=1</code></p>
  
  <p>On another instance of CiviCRM 5.5.2, also on WordPress, on which I have not created any custom relationship types, I do not get this error. I tried disabling all the custom relationships I created in the instance on which I'm having issues but the error still occurs.</p>
  
  <p>Anyone have any ideas on what might be going on? Thanks.</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-25T05:52:53.103Z
Comments.Text: so are you saying this is not happening when you do anything else either in Adv Search or eg on a Contact Record - seems odd it would relate to custom Relationship Types (assuming you didn't somehow get away with naming two the same)
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-25T05:53:30.280Z
Comments.Text: and are both systems on bitnami?
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-25T16:49:24.623Z
Comments.Text: Thanks for the responses -- yes both systems are on Bitnami on Amazon Lightsail. And correct, I don't see errors when I expand any of the other sections in advanced search, only the relationships. I added a couple of test relationships in the system that IS working and that didn't seem to break it. I'll take a look at the relationship records directly in the database to see if anything looks amiss there.
Comments.UserDisplayName: Matt Woodward
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T17:31:56.863Z
Comments.Text: Bit more info on this, I have a dev copy of this exact same site on another Lightsail instance, just with older data, and it doesn't have this issue. On the instance that's throwing the error I deleted all the relationship types I created thinking maybe there was some data related to one of them that was throwing things off, and I still get the error. Is there some way to turn on more verbose debugging so I can see more details when the error occurs?
Comments.UserDisplayName: Matt Woodward
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T17:42:33.130Z
Comments.Text: Poked around more and found this in the CiviCRM log in the ConfigAndLog directory: `Element 'custom_37_from' does not exist in HTML_QuickForm::addRule()` There's more to the error message but that seems to be the crux of it. I'm not sure what it's trying to reference that no longer exists, but I'll dig further. If anyone has guidance I'm all ears! Thanks.
Comments.UserDisplayName: Matt Woodward
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T18:01:00.117Z
Comments.Text: And now I notice when I try to expand the custom fields area of the advanced search it throws a similar error: `Element 'custom_10_from' does not exist in HTML_QuickForm::addRule()` and a bit more: `"custom_10_from", "Precinct From must be an integer (whole number).", "integer"`. I have a custom field Precinct that is an integer select, is searchable, and is not required, so while that seems to be at the heart of the custom search error I'm not sure why if all the values are valid integers. More digging ...
Comments.UserDisplayName: Matt Woodward
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2018-10-26T19:47:47.360Z
Comments.Text: So it seems I have two separate things going on here -- integer select custom fields just seem broken (in my estimation) in terms of making them searchable, and it appears that's already been reported as a bug https://lab.civicrm.org/dev/core/issues/337 The relationships thing seems to be a different but similar issue.
Comments.UserDisplayName: Matt Woodward
Tags: <relationships><advanced-search>
Title: Error When Expanding Relationship Section on Advanced Search
ThreadText: # Error When Expanding Relationship Section on Advanced Search
  
  (Asked by: username_0 on 2018-10-24)
  
  I'm on CiviCRM 5.6.0 on WordPress 4.9.8, and I have created some custom relationships, all with contact type A of individual, and contact type B of organization.
  
  When I go to Search -> Advanced Search and expand the Relationships section, I get this notice:
  Network Error
  Unable to reach the server. Please refresh this page in your browser and try again.
  
  When I check the logs, this is the full error message that occurs when I expand the Relationships section:
  
  `[Wed Oct 24 15:42:05.499499 2018] [proxy_fcgi:error] [pid 32638:tid 140566905980672] [client X.X.X.X:56697] AH01071: Got error 'PHP message: PHP Warning: array_key_exists(): The first argument should be either a string or an integer in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contact/Form/Search.php on line 301\nPHP message: PHP Warning: array_key_exists(): The first argument should be either a string or an integer in /opt/bitnami/apps/wordpress/htdocs/wp-content/plugins/civicrm/civicrm/CRM/Contact/Form/Search.php on line 301\n', referer: https://XXXX/wp-admin/admin.php?page=CiviCRM&q=civicrm%2Fcontact%2Fsearch%2Fadvanced&reset=1`
  
  On another instance of CiviCRM 5.5.2, also on WordPress, on which I have not created any custom relationship types, I do not get this error. I tried disabling all the custom relationships I created in the instance on which I'm having issues but the error still occurs.
  
  Anyone have any ideas on what might be going on? Thanks.
  
  **Tags:** relationships, advanced-search
  
  > **Comments:**
  > **username_1**: so are you saying this is not happening when you do anything else either in Adv Search or eg on a Contact Record - seems odd it would relate to custom Relationship Types (assuming you didn't somehow get away with naming two the same)  
  > **username_1**: and are both systems on bitnami?  
  > **username_0**: Thanks for the responses -- yes both systems are on Bitnami on Amazon Lightsail. And correct, I don't see errors when I expand any of the other sections in advanced search, only the relationships. I added a couple of test relationships in the system that IS working and that didn't seem to break it. I'll take a look at the relationship records directly in the database to see if anything looks amiss there.  
  > **username_0**: Bit more info on this, I have a dev copy of this exact same site on another Lightsail instance, just with older data, and it doesn't have this issue. On the instance that's throwing the error I deleted all the relationship types I created thinking maybe there was some data related to one of them that was throwing things off, and I still get the error. Is there some way to turn on more verbose debugging so I can see more details when the error occurs?  
  > **username_0**: Poked around more and found this in the CiviCRM log in the ConfigAndLog directory: `Element 'custom_37_from' does not exist in HTML_QuickForm::addRule()` There's more to the error message but that seems to be the crux of it. I'm not sure what it's trying to reference that no longer exists, but I'll dig further. If anyone has guidance I'm all ears! Thanks.  
  > **username_0**: And now I notice when I try to expand the custom fields area of the advanced search it throws a similar error: `Element 'custom_10_from' does not exist in HTML_QuickForm::addRule()` and a bit more: `"custom_10_from", "Precinct From must be an integer (whole number).", "integer"`. I have a custom field Precinct that is an integer select, is searchable, and is not required, so while that seems to be at the heart of the custom search error I'm not sure why if all the values are valid integers. More digging ...  
  > **username_0**: So it seems I have two separate things going on here -- integer select custom fields just seem broken (in my estimation) in terms of making them searchable, and it appears that's already been reported as a bug https://lab.civicrm.org/dev/core/issues/337 The relationships thing seems to be a different but similar issue.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-10-26. Score: 1 | Accepted answer
  
  So this all boiled down to [this issue](https://lab.civicrm.org/dev/core/issues/337), which has to do specifically with custom fields that are integer selects, and it was impacting both the custom fields and the relationships sections of the advanced search since I was using the same custom field on a custom relationship.
  
  The short-term fix is I went into the database and made the custom field in question not searchable and set is\_search\_range to 0 as well, which resolved the issue with the relationships section on advanced search throwing an error.
  
  That does mean that for the time being I can't search by that custom field, which is unfortunate since it's kind of a key piece of what I might want to sort/filter by, but I'll keep an eye on the bug and if push comes to shove I can always change that custom field into a text field and rework things since in this case although the data is integers it doesn't have to be since I'm not running math on it or anything, it's essentially just a numeric label.
  
  Hope that helps someone else who runs into this with some thought process or at least raises awareness about the bug.
  
  
  ---
  
  