We have a requirement, after leads are converted, we are sending data to a partner about them. We have a batch process which will periodically look for newly converted leads, send the data to the partner in bulk, and then save ConvertedAccount.Was_Sent_to_Partner__c was true for each of the saved leads.
Our query looks like this:
Database.getQueryLocator([
SELECT Id, External_Id__c
FROM Lead
WHERE IsConverted = TRUE
AND ConvertedAccountId != NULL
AND ConvertedAccount.Was_Sent_to_Partner__c != TRUE
]);
But the problem is, that some values have never been set, so when queried with the Developer Console's Query Editor, their value shows as (null ConvertedAccount)
.... which aparrently is not equal to either false or null.
Is there a way I can filter on this value?
ConvertedAccount.Was_Sent_to_Partner__c = null
orConvertedAccount.Was_Sent_to_Partner__c = ''
in the WHERE clause should work. I'm able to do this in my org.ConvertedAccount.Was_Sent_to_Partner__c
is a checkbox/boolean so '' definitely won't work.ConvertedAccount.Name
and missed to notice that your fieldWas_Sent_to_Partner__c
is boolean. So, I guess you actually wanted the SOQL comparison onConvertedAccountId
?ConvertedAccountId != NULL
toConvertedAccount.Id != null
.ConvertedAccount.Id
, but thought you might have that already figured that based on David's answer. So, ended my previous comment with the question.