You need to sign in to do that
Don't have an account?
Itay Shechter 10
getting parent fields in LWC
Hello!
I'm trying to get the values from some account fields that are related to an opportunity. I'm not sure why I was able to get the account name but not the custom fields...What am I doing wrong?
I would appreciate your help
This one is working fine:
This one is not working:
I'm trying to get the values from some account fields that are related to an opportunity. I'm not sure why I was able to get the account name but not the custom fields...What am I doing wrong?
I would appreciate your help
This one is working fine:
import { LightningElement, api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; import LightningAlert from 'lightning/alert'; import ACCOUNTNAME_FIELD from '@salesforce/schema/Opportunity.Account.Name' import VALIDATEADDRESS_FIELD from '@salesforce/schema/Opportunity.Account.Address_Verified__c' import ACCOUNTMANAGERFORGETT_FIELD from '@salesforce/schema/Opportunity.Account.Account_Manager_for_GT__c' import VATNUMBER_FIELD from '@salesforce/schema/Opportunity.Account.Company_Id__c' import PRIMARYCONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Primary_Contact__c' import FINANCECONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Finance_Contact__c' import LEGALCOMPANYNAME_FIELD from '@salesforce/schema/Opportunity.Account.Legal_Company_Name__c' import PAYMENTMETHOD_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Method__c' import PAYMENTTERM_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Term__c' import ACCOUNTID_FIELD from '@salesforce/schema/Opportunity.AccountId' export default class CompanyCreationAlerts extends LightningElement { accRecordId @api recordId @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNTNAME_FIELD]}) oppHandler({ data, error }) { if (data) { console.log(data) } if (error) { console.error(error) } } }
This one is not working:
import { LightningElement, api, wire } from 'lwc'; import { getRecord } from 'lightning/uiRecordApi'; import LightningAlert from 'lightning/alert'; import VALIDATEADDRESS_FIELD from '@salesforce/schema/Opportunity.Account.Address_Verified__c' import ACCOUNTMANAGERFORGETT_FIELD from '@salesforce/schema/Opportunity.Account.Account_Manager_for_GT__c' import VATNUMBER_FIELD from '@salesforce/schema/Opportunity.Account.Company_Id__c' import PRIMARYCONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Primary_Contact__c' import FINANCECONTACT_FIELD from '@salesforce/schema/Opportunity.Account.Finance_Contact__c' import LEGALCOMPANYNAME_FIELD from '@salesforce/schema/Opportunity.Account.Legal_Company_Name__c' import PAYMENTMETHOD_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Method__c' import PAYMENTTERM_FIELD from '@salesforce/schema/Opportunity.Account.Payment_Term__c' import ACCOUNTID_FIELD from '@salesforce/schema/Opportunity.AccountId' export default class CompanyCreationAlerts extends LightningElement { accRecordId @api recordId @wire(getRecord, { recordId: '$recordId', fields: [ACCOUNTID_FIELD,VALIDATEADDRESS_FIELD,ACCOUNTMANAGERFORGETT_FIELD, VATNUMBER_FIELD, PRIMARYCONTACT_FIELD,FINANCECONTACT_FIELD, LEGALCOMPANYNAME_FIELD,PAYMENTMETHOD_FIELD, PAYMENTTERM_FIELD]}) oppHandler({ data, error }) { if (data) { console.log(data) } if (error) { console.error(error) } } }
Reason behind , because your custom fields is blank or Empty that's why not showing in result. for more test by SOQL with all custom fields that's you have deceleared in Component.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
All Answers
Reason behind , because your custom fields is blank or Empty that's why not showing in result. for more test by SOQL with all custom fields that's you have deceleared in Component.
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh