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
Ross JamesRoss James 

Trigger checking for an Empty Lookup Field

I am having problems with a simple IF statement and Lookup Fields. How do I ask if the Lookup Field Membership_Number__c is empty.

 

This is my code, but all records, with or without a Membership Number are going to the else.

 

 

if (ili.Product_Family__c=='Membership') { 
        		if (ili.Account_Name__r.Membership_Number__c==NULL) {
        			InvoiceLineItemPaid.AddMembership((String)ili.Id);
        		} else {
        			InvoiceLineItemPaid.AddMembershipLineItem((String)ili.Id);
        		}

 

 

aalbertaalbert

Have you checked if that field is empty (vs NULL)? Why not add a System.debug statement to output the value of the Membership_Number__c field so you can see it in the debug logs and verify its value.