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
Margaret FleischakerMargaret Fleischaker 

Field missing from trigger context when updated from visualforce apex class

I have a quote trigger on after update. When I update the quote directly, the AccountId is included. However, when the quote is updated via a class that runs when a quote line item is saved, the AccountId is blank.

Here is a snippet of the code that updates the quote. This is in a controller extension for a visualforce page.
qlis.add(qli);
System.debug('qlis ' + qlis);
if(myQuote!=null){
	System.debug('[MF] myQuote: ' + myQuote);
	update myQuote;
}
upsert qlis;
return null;

/** The debug log**/
USER_DEBUG [260]|DEBUG|[MF] myQuote: Quote:{Id=0Q0Q0000000OkFDKA0, CurrencyIsoCode=USD}_

 Then, when I debug Trigger.new, the other quote fields are filled out, with the exception of AccountId. (I've removed some below for readability)
13:40:41:792 USER_DEBUG [3]|DEBUG|[MF] Trigger.new: (Quote:{Id=0Q0Q0000000OkFDKA0, OwnerId=00570000004PSo5AAG, IsDeleted=false, Name=Sol Food- - 00002565, CurrencyIsoCode=USD, OpportunityId=006Q000000Fl8mzIAB, Pricebook2Id=01sQ00000003jdzIAA, ContactId=003Q000001E0EFLIA3, QuoteNumber=00002565, IsSyncing=true, ExpirationDate=2017-10-26 00:00:00, AccountId=null, Discount=0.00, GrandTotal=4198.00, Start_Date__c=2017-10-26 00:00:00, Term_Months__c=24, End_Date__c=2019-10-25 00:00:00)
Why would AccountId be null in this scenario? Shouldn't all fields automatically be included in the trigger context? When I make an edit to the Quote directly, it is included.

Thanks in advance for any help!
 
Alain CabonAlain Cabon
AccountId returns null in trigger on Quote when DML happens in Lightning Experience

Description:  Due to a platform limitation in lightning which filters out the fields of quote which are not directly editable or creatable, the value of accountid cannot be obtained via trigger in a DML on quote. 

Workaround:
Query the AccountID field using SOQL.

https://help.salesforce.com/articleView?id=000267839&language=en_US&type=1