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
Kris WebsterKris Webster 

String Query Syntax HELP

Hey guys I am needing some help with the way I need to format this string query so it will look up the records I need it to. 

Basically I need the query to look up contacts that are on a billable assignment that also have Is Resource = TRUE, Is Resource Active = TRUE, and Exclude From Time Calculations = FALSE, and the Work Calandar = weekStartDay. 

I am able to perform this string in the Query editor and find the results I am looking for, but am unsure of the exact syntax that is needed in Apex. 

Here is what I have so far... 
 
string assignments = 'SELECT Id, pse__End_Date__c, pse__Resource__c, pse__Is_Billable__c, Today__c FROM pse__Assignment__c WHERE pse__Is_Billable__c = True AND pse__End_Date__c > TODAY'; 

        string queryString = 'SELECT Id, ' + 
                             '       Name ' + 
                             '  FROM Contact ' + 
                             ' WHERE Id Like: assignments.pse__Resource__c AND' + 
            				 '		 pse__Is_Resource__c = true AND ' + 
                             '       pse__Is_Resource_Active__c = true AND ' + 
                             '       pse__Exclude_From_Missing_Timecards__c = false AND ' +
                             '       pse__Work_Calendar__r.pse__Week_Start_Day__c = \'' + weekStartDay + '\' ';
In the first string I am finding all the assignments that are bilalble, and have an end date greater than TODAY. 

I am then hoping to find a list of contacts that aer found within the first string, by using the contact ID and comparing it to pse__Resource__c, which is a lookup field to contacts on the Assignment object. 

Any help would be GREATLY apprecaited!!