0

I am calling LWC from Aura Component on Quick Action.I have to open my LWC open as a tab. for that I have used this method in my Aura Component . Now I am able to open LWC component but in the sames tab.I want to know that how to get the recordId in my LWC.

/* eslint-disable no-alert */
/* eslint-disable no-console */
import { LightningElement, api, track, wire } from 'lwc';
import getOppty from '@salesforce/apex/FeedbackCtrl.getOppty';
import { handleErrors, showToast } from 'c/girikonUtil';
import { createRecord } from 'lightning/uiRecordApi';
import { CurrentPageReference } from 'lightning/navigation';
import saveRefereeFeedback from '@salesforce/apex/FeedbackCtrl.refereeFeedback';

export default class RefereeFeedback extends LightningElement {

@track agencyName;
@track agentName;
@track applicationDate;
@track ecaContactOfficer;
@track oppId;
@track conParam;
@track ownerId;

    connectedCallback(){   
        let newURL = new URL(window.location.href).searchParams;        
        this.oppId=newURL.get('opp');      
        console.log('===oppId=='+this.oppId);
        this.conParam=newURL.get('con');      
        console.log('===conId=='+this.conParam);
        getOppty({
            oppId: this.oppId
            
      }).then(response => {
            console.log('==36=='+JSON.stringify(response));
            const objData = JSON.parse(JSON.stringify(response));
            this.agencyName = objData[0].Account.Name;
            this.ecaContactOfficer=objData[0].Owner.Name;
            this.applicationDate =objData[0].CreatedDate;
            this.agentName = objData[0].Account.hed__Primary_Contact__r.Name;
            this.ownerId = objData[0].OwnerId;
            console.log('==agencyName=='+JSON.stringify(objData[0].Account.Name));
            console.log('==ecaContactOfficer=='+JSON.stringify(objData[0].Owner.Name));
            console.log('==applicationDate=='+JSON.stringify(objData[0].CreatedDate));
            console.log('==agentName=='+JSON.stringify(objData[0].Account.hed__Primary_Contact__r.Name));

        }).catch(error => {
            console.log('Errors ', error.body.message);
        })
    }

   
saveForm(event) 
{
    this.isFormInProgress = true;
    this.template.querySelector(".submit").click();
}

handleSubmit(event)
{
    event.preventDefault();
    const fields = event.detail.fields;
    fields.Referee_Name__c = this.conParam;
    fields.Date_Of_Application__c = this.applicationDate;
    fields.ECA_Contact_Officer__c = this.ownerId;
    saveRefereeFeedback({Data:fields})
    .then(response =>{
        showToast(this, 'Thanks! your Feedback has been submitted successfully.', 'success', 'success');

    }).catch(error => {
        
    })
}

cancel(){
    window.close();
    return false;
}

}

2
  • have you defined the any public property on your lwc where you are expecting the value? Commented Jun 12, 2020 at 14:59
  • Yes I have defined api recordId.But I don't know how to get access recordid sent from aura component. @sanket Commented Jun 12, 2020 at 15:17

1 Answer 1

0

If your component is used as a quick action, you should wrap it in an aura component

<aura:component
    implements="flexipage:availableForAllPageTypes,force:hasRecordId"
    access="global">

    <c:aQuickActionLWC recordId="{!v.recordId}"></c:aQuickActionLWC>
</aura:component>

Then manage navigation in the connectedCallback method.

import { LightningElement, api} from "lwc";
import { NavigationMixin } from 'lightning/navigation';

export default class GoToHelloTab extends NavigationMixin(LightningElement) {

@api recordId;

  connectedCallback() {

      this[NavigationMixin.Navigate]({
        type: 'standard__navItemPage',
        attributes: {
        apiName: 'Hello',          
        },
      });
  }
}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .