I have a hidden lightning component on a Lightning page that checks some data of the record and updates the record if needed. The record is a SBQQ__Quote__c record.
It mostly works, however, sometimes the record loads with cached (i.e. stale) data instead of the most recent data. Here is the code in the component:
<aura:component implements="force:hasRecordId,force:hasSObjectName,force:lightningQuickActionWithoutHeader,flexipage:availableForAllPageTypes" access="global" controller="SBQQ_CheckLineItems">
<!-- This is a hidden component on the SBQQ__Quote__c page used to check that GSA Line Item Descriptions comply with the rules -->
<aura:attribute name="record" type="Object"/>
<aura:attribute name="simpleRecord" type="Object"/>
<aura:attribute name="recordError" type="String"/>
<force:recordData aura:id="recordLoader"
recordId="{!v.recordId}"
layoutType="FULL"
fields="SBQQ__ExpirationDate__c,Warning__c,QLE_Run__c"
mode="VIEW"
targetRecord="{!v.record}"
targetFields="{!v.simpleRecord}"
targetError="{!v.recordError}"
recordUpdated="{!c.doInit}"
/>
</aura:component>
I've tried keying off of the event type, but it is just telling me it is Loaded.
var eventParams = event.getParams();
if(eventParams.changeType === "LOADED") {
// force the reload while skipping the cache
// this puts me in infinite loop
}
I've tried forcing a reloadRecord method and skipping the cache as documented here: https://developer.salesforce.com/docs/component-library/bundle/force:recordData/specification
The problem is this creates an infinite loop of loading. Is there anyway to detect if the load is from the cache or from the server?
Thanks,
Mike