I would need the value of a field from the current record to pass along to make an Continuation API callout within the connectedCallBack( ). But, the field value I am trying to access via @wire is getting executed upon completion of the connectedCallBack( ). Sample code below:
import { LightningElement, api, wire } from 'lwc';
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import REVENUE_FIELD from '@salesforce/schema/Account.AnnualRevenue';
const fields = [REVENUE_FIELD, CREATED_FIELD, EXP_FIELD];
export default class WireGetValue extends LightningElement {
@api recordId;
revData;
@wire(getRecord, { recordId: '$recordId', fields })
account;
get revenue() {
return getFieldValue(this.account.data, REVENUE_FIELD);
}
connectedCallback(){
this.revData = this.revenue(); //How can I get this executed upon getting data?
console.log('NEW: ' +this.revData); //Getting as 'undefined'
this.makeAPICallout(this.revData); //Failing.
}
}
This LWC would be used as a 'Quick Action' button on the record detail page.
Referred to these already:
And many others, but my scenario includes calling an API within the connectedCallBack( ). Is there a way I can access this specific field value without* involving Apex here?