Skip to main content
Saurav Kumar ha preguntado en #Apex
When I try to Query 

Invoice__C[] InvoiceData =  [Select Id,Attachment_Id__c,Supporting_Attachment_Id__c from Invoice__c where Id=:InvoiceId]; 

In the debug I see Only Id and Attachment_Id__c fields, because Supporting_Attachment_Id__c is null.

But then I try to  check it using below line.

if(InvoiceData[0].Supporting_Attachment_Id__c == ''||InvoiceData[0].Supporting_Attachment_Id__c == null)

It throws System.NullPointerException: Attempt to de-reference a null object.

How to solve this issue?
7 respuestas
  1. 23 mar 2021, 6:06

    hi Saurav,

    try

    if(!String.isBlank(InvoiceData[0].Supporting_Attachment_Id__c)) {

       //your condition if there is a value

    }
0/9000