1

I have created a lookup between two custom objects. Object A is an existing object that has a new lookup to object B, a new object.

For the next few months I need to have a scheduled batchjob to keep the new lookup field populated on new records of object A

In order to find all records that do not have a lookup to B I have tried the following SOQL:

SELECT Id, LookupB__c FROM A__c
WHERE LookupB__c= NULL

It returns zero records. I get the same result if I try with an empty string ('')

If I run the query without the WHERE clause and then print the content of lookupB__c, it tells me it is null

So what should I use to find the records where the lookup is not set?

2
  • Are you sure it does not work? I did the same on my org. SELECT Id, LookupField__c FROM ObjectWithLookup__c WHERE LookupField__c = null. Do you have View All Data on Profile? Sep 5, 2022 at 12:33
  • I am Admin so I don't think that is the problem. I was running the queries from my IDE, I just tried from the developer console. That works. And it also works from my IDE now. I have not changed the query at all...
    – Snowgoon
    Sep 5, 2022 at 12:40

1 Answer 1

0

Ran the query I the developer Console instead of in my IDE. It works now, the query have not been changed.

I have no explanation.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .