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
Piyush Bajoria 15Piyush Bajoria 15 

New button override using Aura and LWC is cached. How do I make sure form displayed is new, everytime it loads??

I've an Aura Component that is overridding the "New" Button. The aura component loads the LWC - which displays a record edit form to input data. 
This works well the first time. However, if I fill in some value on a field, click New again - the data/form that is displayed is cached and shows the old data. How do I overcome this?
David Zhu 🔥David Zhu 🔥
You may try disable the lightning expeirence cach.
 Setup | search Session Settings | uncheck Enable secure and persistent browser caching to improve performance
Piyush Bajoria 15Piyush Bajoria 15
Hi @David Zhu - Disabling lightning experience cache doesn't help. Still have the same issue.
RSuzukiRSuzuki
You will have to reinstantiate the variables on the component. I don't know your specific situation without code, but I recommend something like this:
refreshCmp() {
    //Grab all lightning-input-field
    const inputFields = this.template.querySelectorAll('lightning-input-field');
    if (inputFields) {
        inputFields.forEach((field) => {
            //Run the reset method
            field.reset();
        });
    }
}

https://developer.salesforce.com/docs/component-library/bundle/lightning-input-field/specification
Piyush Bajoria 15Piyush Bajoria 15
Hi @RSuzuki - How would I call this refreshCmp method? I don't see anything getting called in the LWC, the second time. This is my code snippet if this helps you see what I am trying to do - 

The "New" button calls the Aura - which in turn calls the LWC.

Aura
 
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,lightning:actionOverride,lightning:hasPageReference,force:appHostable" controller="pageLayoutOverrideController" access="global" >
    <aura:attribute name="recordId" type="String" default=""/>
    <aura:attribute name="objectName" type="String" default="Opportunity" />
    <aura:attribute name="selectedRecordTypeId" type="String" default=""/>
    <aura:attribute name="recordMode" type="String" default="" />
    <aura:attribute name="pickListValues" type="String" />
    <aura:attribute name="loadComplete" type="Boolean" default="false" />  
    
    <aura:attribute name="pageReference" type="Object" />
	<aura:handler name="change" value="{!v.pageReference}" action="{!c.handlePageChange}" />
    
    <!--Declare Handler-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
   
    <aura:if isTrue="{!v.loadComplete}">
        <div class="view-custom-ui">
            <c:viewRecordUIDetails recordId="{!v.recordId}" objectApiName="{!v.objectName}" recordTypeIdVar="{!v.selectedRecordTypeId}" mode="{!v.recordMode}" pickListMapping="{!v.pickListValues}"/>
        </div>
    </aura:if>
</aura:component>

LWC Controller -
 
// importing required methods

export default class ViewRecordUIDetails extends NavigationMixin(LightningElement) {


//Variable declaration start


//Variable declaration end

@wire(getRecordCreateDefaults, { objectApiName: '$objectApiName', recordTypeId : '$recordTypeIdVar' })
    defaultCreateUIInfo({error,data}){

//Wire method logic

}

 @wire(getRecordUi, { recordIds: '$recordId', layoutTypes: 'Full', modes: 'View' })
    recordUIInfo({ error, data }) {

//Wire method logic

}


renderedCallback(){
        console.log('--called rendered callback----');

    }


connectedCallback(){
      console.log('--in connected callback---');

}


}

 
Pandeiswari SathiakumarPandeiswari Sathiakumar
Hi Piyush Bajoria 15,

Have you found solution for your issue. I am facing same issue now.