I'm new to LWC. I was trying to get the field values without calling the apex class. I am using Lightning Data Service i.e. getRecord. I'm not understanding why the @wire is not executing when the @wire is executed as I need some suggestion.

Below is the code: Aura Component which is called from Quick Action:

<aura:component implements="force:hasRecordId,force:lightningQuickAction">
    <c:uploadPo recordId="{!v.recordId}"></c:uploadPo> </aura:component>




import { LightningElement, api, wire, track } from 'lwc';

import { getRecord } from 'lightning/uiRecordApi';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

const FIELDS = [

export default class UploadPo extends LightningElement {
    @api recordId;

    @track Opportunity;
    @track opportunityName;


    @wire(getRecord, { recordId: '$recordId', fields : FIELDS })
                new ShowToastEvent({
                    title: 'Error loading Order Value',
                    message: error.message,
                    variant: 'error',
        }else if(data){
            this.Opportunity = data;
            this.opportunityName = data.fields.Name.value;


LWC xml File:

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
        <targetConfig targets="lightning__RecordPage">    
            <property name="recordId" type="String" label="Record Id" description="Record Id"/>    

In the above code I am able to print only connectedCallback() console and @wired is not getting called. Thank you for your suggestions.

  • I use the same design and it works for me. The one thing I might try is adding a if true to the template for opportunityName or Opportunity - that might force something to rerender – BritishBoyinDC Feb 10 '20 at 15:00

@api recordId is reserved for components available to record pages (it automatically gets assigned the right value).

Since the Lightning Web Component is not directly in a record page context, try another attribute name like opptyId.

I got this to work:

<aura:component implements="force:lightningQuickAction,force:hasRecordId">
  <c:sampleForm opptyId="{!v.recordId}"></c:sampleForm>
  <p>Record ID: {opptyId}</p>
import { LightningElement, api } from 'lwc';

export default class SampleForm extends LightningElement {
  @api opptyId;
  • Thanks for the response. I have tried using opportunityId but same result. I am going to add some other fields of opportunity for validation purpose not for UI rendering. Is it right way to do so. – lavesh galipelli Feb 11 '20 at 5:40
  • I could make it work by simply renaming recordId in LWC. I'll update my answer. – POZ Feb 11 '20 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.