<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: how to set api filter for &amp;quot;multiple checkboxes&amp;quot; field type? in APIs &amp; Integrations</title>
    <link>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/597497#M51765</link>
    <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/341808"&gt;@DBiler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you just wanting to check if there is a value in the property or are you wanting that specific value?&lt;/P&gt;
&lt;P&gt;If first: &lt;CODE class=" language-none"&gt;HAS_PROPERTY&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;If second: &lt;CODE class=" language-none"&gt;EQ&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Mar 2022 16:31:19 GMT</pubDate>
    <dc:creator>dennisedson</dc:creator>
    <dc:date>2022-03-18T16:31:19Z</dc:date>
    <item>
      <title>how to set api filter for "multiple checkboxes" field type?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/597146#M51755</link>
      <description>&lt;P&gt;hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this custom property for Contacts called&amp;nbsp;"mh_instance" (internal value)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2022-03-18 at 8.14.55 AM.png" style="width: 999px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/62031iEB2912CCF6613F32/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2022-03-18 at 8.14.55 AM.png" alt="Screen Shot 2022-03-18 at 8.14.55 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Currently, this is how i do it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="php"&gt;$client = \HubSpot\Factory::createWithApiKey('MY_API_KEY'); 
$searchRequest = new \HubSpot\Client\Crm\Contacts\Model\PublicObjectSearchRequest(); 
$filters = []; 
$conditions = [ 'email' =&amp;gt; 'test@example.com', 'mh_instance' =&amp;gt; 'AU' ]; 
$field_operators = [ 'email' =&amp;gt; 'EQ', 'mh_instance' =&amp;gt; 'IN' ]; 
$fields = ['email']; 

foreach($conditions as $property_name =&amp;gt; $property_value){ 
    $curFilter = new \HubSpot\Client\Crm\Contacts\Model\Filter(); 
    $operator = $field_operator[$property_name]; 
    $curFilter-&amp;gt;setOperator($operator)-&amp;gt;setPropertyName($property_name)-&amp;gt;setValue($property_value); 
    $filters[] = $curFilter;
 } 
 
 $filterGroup = new \HubSpot\Client\Crm\Contacts\Model\FilterGroup(); 
 $filterGroup-&amp;gt;setFilters($filters); 
 $searchRequest-&amp;gt;setFilterGroups([$filterGroup]); 
 $searchRequest-&amp;gt;setProperties($fields); 
 $searchRequest-&amp;gt;setLimit(1); 
 
 try { 
     $apiResponse = $client-&amp;gt;crm()-&amp;gt;contacts()-&amp;gt;searchApi()-&amp;gt;doSearch($searchRequest); 

     if($apiResponse['total'] &amp;gt;= 1){ 
         $tmp = $apiResponse['results'][0]['properties']; 
         return [ 
            'id' =&amp;gt; $tmp['hs_object_id'], 'date_added' =&amp;gt; $tmp['createdate'], 'date_modified' =&amp;gt; $tmp['lastmodifieddate'] 
        ];
    } 
    else 
        return false; 
} 
 catch (ApiException $e) { return false; }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;request body&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "filterGroups": [
    {
      "filters": [
        {
          "value": "AU",
          "propertyName": "mh_instance",
          "operator": "IN"
        },
        {
          "value": "test@example.com",
          "propertyName": "email",
          "operator": "EQ"
        }
      ]
    }
  ],
  "properties": [
    "email",
    "mh_instance"
  ],
  "limit": 100
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but im getting the following result&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
  "status": "error",
  "message": "Invalid input JSON on line 1, column 88: Cannot construct instance of `com.hubspot.inbounddb.publicobject.core.v3.search.Filter`, problem: operator IN requires values",
  "correlationId": "2c85d210-c5f2-4849-9c75-291e44851a45"
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 00:51:02 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/597146#M51755</guid>
      <dc:creator>DBiler</dc:creator>
      <dc:date>2022-03-18T00:51:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to set api filter for "multiple checkboxes" field type?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/597497#M51765</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/341808"&gt;@DBiler&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you just wanting to check if there is a value in the property or are you wanting that specific value?&lt;/P&gt;
&lt;P&gt;If first: &lt;CODE class=" language-none"&gt;HAS_PROPERTY&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;If second: &lt;CODE class=" language-none"&gt;EQ&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Mar 2022 16:31:19 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/597497#M51765</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2022-03-18T16:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: how to set api filter for "multiple checkboxes" field type?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/964439#M72983</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/13982"&gt;@dennisedson&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Can You please explain the second ? What do you mean by EQ.&lt;BR /&gt;It would be nice if you can give an example on the json or any documentation link&lt;BR /&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 11:47:59 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/964439#M72983</guid>
      <dc:creator>UMuhammad21</dc:creator>
      <dc:date>2024-04-22T11:47:59Z</dc:date>
    </item>
    <item>
      <title>Re: how to set api filter for "multiple checkboxes" field type?</title>
      <link>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/964605#M72996</link>
      <description>&lt;P&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/749495"&gt;@UMuhammad21&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Rereading this, I believe my advice was not the best.&amp;nbsp; Let me update it,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For a multiselect, the EQ operator will not work.&amp;nbsp; What you will need to do is do multiple filters with the IN operator.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;P&gt;I have a property with 3 value options: option1, option2, option3&lt;BR /&gt;I have a contact with option1 and option2 selected.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The JSON I can send to return only contacts with thos two values would look like this&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;{
    "filterGroups":[
      {
        "filters":[
          {
            "propertyName": "multi_check",
            "operator": "IN",
            "values":["option1"]
          },
          {
            "propertyName": "multi_check",
            "operator": "IN",
            "values":["option2"]
          }
        ]
      }
    ]
  }&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope that clears this up and sorry again for the misinformation.&amp;nbsp; I think I read the question too quickly!&lt;/P&gt;</description>
      <pubDate>Mon, 22 Apr 2024 16:08:43 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/APIs-Integrations/how-to-set-api-filter-for-quot-multiple-checkboxes-quot-field/m-p/964605#M72996</guid>
      <dc:creator>dennisedson</dc:creator>
      <dc:date>2024-04-22T16:08:43Z</dc:date>
    </item>
  </channel>
</rss>

