function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Rachel FrazerRachel Frazer 

Trying to create cross filter functionality using SOQL

I am trying to query two related objects in Field Service Lightning. Ideally I would return the same results as in the report below, namely:

Show Name, Skill__c, and Territories__c from Service Resources, with this cross filter:

Service Resources WITHOUT Assigned Resources
  with a Start Date less than 2/28/2019
and
 an End Date less than 2/1/2019
User-added image
Currently, my query looks like this:

SELECT Id,Name,Skill__c,Territory__c FROM ServiceResource
 where (Id NOT in (select Service_Resource__c from Request_Resource__c where Start_Date__c < 2019-02-28 and End_Date__c > 2019-02-01))

but it is returning too many records.
Raj VakatiRaj Vakati
Its matter like how you create a report type with child objects.  Check these two settings 

https://help.salesforce.com/articleView?id=reports_report_type_objects.htm&type=5

For each child object, select one of the following criteria:
  1. Each "A" record must have at least one related "B" record. Only parent records with child records are shown in the report.
  2.  
  3. "A" records may or may not have related "B" records. Parent records are shown, whether or not they have child records.


User-added image
Rachel FrazerRachel Frazer
I am not actually trying to create a report type. I want to use SOQL to get the same result as an existing cross filter.
locat mark 5locat mark 5
Why should you care about collecting and analyzing customer feedback? Find out why are the top reasons why customer feedback is important! 
customer feedback (https://customerfeedbacks.xyz/)