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
-d-g--d-g- 

A List Exception, Query Returning 0 Records

I am getting an exception because one of my queries is not returning results, I'm not sure why, can you take a look?

This is the line that's causing the problem: List<Quote> Synced = [SELECT Synced_Quote_Id__c FROM Quote WHERE Id = :quotelid[0].Id];

 

Here's the rest of the code, if that helps.  Thanks!

 

trigger SyncdQuoteUpdate onMilestone1_Project__c (beforeinsert, beforeupdate) {

Id INVLI = trigger.new[0].Invoice_Line_Item__c;

String SyncedQuote = trigger.new[0].Synced_Quote__c;

Date breakdate = Date.newinstance(2012, 7, 8);

Date CreationDate = trigger.new[0].Created_Date__c;

System.Debug(INVLI);

List<QuoteLineItem> quotelid = [SELECT QuoteId FROM QuoteLineItem WHERE Id = :INVLI];

List<Quote> Synced = [SELECT Synced_Quote_Id__c FROM Quote WHERE Id = :quotelid[0].Id];

if ( CreationDate > breakdate ) {

if (SyncedQuote == null) {

trigger.new[0].Synced_Quote__c = Synced[0].Id;

}

}

}

Best Answer chosen by Admin (Salesforce Developers) 
Leon MorockiLeon Morocki

In a Quote query you are using "quotelid[0].Id" which is an Id of a QuoteLineItem not a Quote.

You probably wanted to use "quotelid[0].QuoteId".

All Answers

Leon MorockiLeon Morocki

In a Quote query you are using "quotelid[0].Id" which is an Id of a QuoteLineItem not a Quote.

You probably wanted to use "quotelid[0].QuoteId".

This was selected as the best answer
-d-g--d-g-

Thank you kindly!