<?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: GraphQL filter with OR Issue in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020430#M40116</link>
    <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/163809"&gt;@JBrake&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I haven't tested this, but in theory the following query should represent this logical expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;publish_status="published"&lt;/STRONG&gt; AND (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date &amp;lt;= $today&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date &amp;gt;= $tomorrow&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date &amp;lt;= $today&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date == null&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date ==&amp;nbsp; null&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date &amp;gt;= $tomorrow&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date == null&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date == null&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;# $today: {{ unixtimestamp(today()) }}
# $tomorrow {{ unixtimestamp(today().plusDays(1)) }}

query LoadMyObjectList($today: Date, $tomorrow: Date) {
  CRM {
    MyObjects: p_myobject_collection(
      orderBy: start_date__desc
      offset: $page
      limit: $limit
      filter: {publish_status__eq: "published",
        OR: [
          {publish_date__lte: $today, expiry_date__gte: $tomorrow},
          {publish_date__lte: $today, expiry_date__null: true},
          {publish_date__null: true, expiry_date__gte: $tomorrow},
          {publish_date__null: true, expiry_date__null: true},
        ]}
    ) {
      total
      limit
      offset
      items {
        hs_object_id
        name
        description
        link
        publish_status
        publish_date
        start_date
      }
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;I believe this is what you're looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also had a missing ")" when defining your $today variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully this gets you moving!&lt;/P&gt;
&lt;P&gt;If I can clarify anything please don't&amp;nbsp;hesitate to reach out!&lt;/P&gt;</description>
    <pubDate>Fri, 02 Aug 2024 02:25:35 GMT</pubDate>
    <dc:creator>Kevin-C</dc:creator>
    <dc:date>2024-08-02T02:25:35Z</dc:date>
    <item>
      <title>GraphQL filter with OR Issue</title>
      <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020420#M40115</link>
      <description>&lt;P&gt;I am using GraphQL to load a list of objects that have the publish_status of "published" AND where the publish_date is null OR the publish_date is less than or equal to today, AND where the expiry_date is null OR the expiry_date is greater than or equal to tomorrow.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is this even possible? I've tied every combination I can think of but cannot get the out come I need.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Has anyone done some thing like this sucessfully before?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# $today: {{ unixtimestamp(today() }}
# $tomorrow {{ unixtimestamp(today().plusDays(1)) }}


query LoadMyObjectList($today: Date, $tomorrow:Date) {
  CRM {
    MyObjects: p_myobject_collection(
      orderBy: start_date__desc
      offset: $page
      limit: $limit
      filter: {publish_status__eq: "published", OR: [{publish_date__lte: $today, publish_date__null: true},{expiry_date__gte: $today, expiry_date__null: true}]}}
    ) {
      total
      limit
      offset
      items {
        hs_object_id
        name
        description
        link
        publish_status
        publish_date
        start_date
      }
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Jonathan&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 01:49:07 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020420#M40115</guid>
      <dc:creator>JBrake</dc:creator>
      <dc:date>2024-08-02T01:49:07Z</dc:date>
    </item>
    <item>
      <title>Re: GraphQL filter with OR Issue</title>
      <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020430#M40116</link>
      <description>&lt;P&gt;Hey &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/163809"&gt;@JBrake&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I haven't tested this, but in theory the following query should represent this logical expression:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;publish_status="published"&lt;/STRONG&gt; AND (&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date &amp;lt;= $today&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date &amp;gt;= $tomorrow&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date &amp;lt;= $today&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date == null&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date ==&amp;nbsp; null&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date &amp;gt;= $tomorrow&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; OR&lt;/P&gt;
&lt;P&gt;&amp;nbsp; (&lt;STRONG&gt;publish_date == null&lt;/STRONG&gt; AND &lt;STRONG&gt;expiry_date == null&lt;/STRONG&gt;)&lt;/P&gt;
&lt;P&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;# $today: {{ unixtimestamp(today()) }}
# $tomorrow {{ unixtimestamp(today().plusDays(1)) }}

query LoadMyObjectList($today: Date, $tomorrow: Date) {
  CRM {
    MyObjects: p_myobject_collection(
      orderBy: start_date__desc
      offset: $page
      limit: $limit
      filter: {publish_status__eq: "published",
        OR: [
          {publish_date__lte: $today, expiry_date__gte: $tomorrow},
          {publish_date__lte: $today, expiry_date__null: true},
          {publish_date__null: true, expiry_date__gte: $tomorrow},
          {publish_date__null: true, expiry_date__null: true},
        ]}
    ) {
      total
      limit
      offset
      items {
        hs_object_id
        name
        description
        link
        publish_status
        publish_date
        start_date
      }
    }
  }
}&lt;/LI-CODE&gt;
&lt;P&gt;I believe this is what you're looking for.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also had a missing ")" when defining your $today variable&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully this gets you moving!&lt;/P&gt;
&lt;P&gt;If I can clarify anything please don't&amp;nbsp;hesitate to reach out!&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 02:25:35 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020430#M40116</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2024-08-02T02:25:35Z</dc:date>
    </item>
    <item>
      <title>Re: GraphQL filter with OR Issue</title>
      <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020433#M40117</link>
      <description>&lt;P&gt;Thanks for the prompt reply, yeah I tried that and get the error:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;"errors": [
    {
      "message": "Exception while fetching data (/CRM/MyObjectsCollection) : No value present",
      "locations": [
        {
          "line": 19,
          "column": 5,
          "sourceName": null
        }
      ],
      "path": [
        "CRM",
        "MyObjectsCollection"
      ],
      "extensions": null,
      "errorType": "DataFetchingException"
    }
  ]&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;Jonathan&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 02:34:12 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020433#M40117</guid>
      <dc:creator>JBrake</dc:creator>
      <dc:date>2024-08-02T02:34:12Z</dc:date>
    </item>
    <item>
      <title>Re: GraphQL filter with OR Issue</title>
      <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020439#M40118</link>
      <description>&lt;P&gt;Heu &lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/163809"&gt;@JBrake&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The "No value present" error typically occurs in GraphQL when the query attempts to access a value that is either missing or not present in the context it expects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would check that all variables are recieving the expected values:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;$today&lt;/LI&gt;
&lt;LI&gt;$tomorrow&lt;/LI&gt;
&lt;LI&gt;$page&lt;/LI&gt;
&lt;LI&gt;$limit&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;After a quick review when defining $tomorrow you might try the &lt;A href="https://developers.hubspot.com/docs/cms/hubl/filters#plus-time" target="_blank" rel="noopener"&gt;plus_time&lt;/A&gt; filter rather than the plusDays function. You may also need to throw a render filter on those today functions to ensure the correct computation order.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;EDIT: I would also remove the filters slowly to id which is throwing the error.&lt;/P&gt;</description>
      <pubDate>Fri, 02 Aug 2024 03:09:25 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1020439#M40118</guid>
      <dc:creator>Kevin-C</dc:creator>
      <dc:date>2024-08-02T03:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: GraphQL filter with OR Issue</title>
      <link>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1021903#M40139</link>
      <description>&lt;P&gt;Hey ya,&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Sorry for the late reply, our friday come early.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;plusDays / plus_time didn't make a difference an the output is the same. I have managed to identify the problem though, and have implemented a workaround with an additional property and a workflow, while inforcing that a date is entered into the two date fields I am querying on.&lt;BR /&gt;&lt;BR /&gt;The&amp;nbsp; problem it seams is this:&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE&gt;publish_date__null: true, expiry_date__null: true&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You cannot use __null or __not_null to check for null values in date fields.&lt;BR /&gt;&lt;BR /&gt;I reckon you should be, null is a valid (non)value for any field.&lt;BR /&gt;&lt;BR /&gt;Jonathan&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE class=""&gt;&lt;CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 04 Aug 2024 21:35:09 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/GraphQL-filter-with-OR-Issue/m-p/1021903#M40139</guid>
      <dc:creator>JBrake</dc:creator>
      <dc:date>2024-08-04T21:35:09Z</dc:date>
    </item>
  </channel>
</rss>

