I'm trying to implement a Google map using LWC, the component is on the record page called Project__c, I want to use Address__c as an input:
import { LightningElement, api, wire } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import ADDRESS_FIELD from '@salesforce/schema/PRoject__c.Address__c';
export default class Map extends LightningElement {
@api recordId;
@wire(getRecord, { recordId: '$recordId', fields: [ADDRESS_FIELD] })
project;
mapMarkers = [
{
location: {
City: this.project.ADDRESS_FIELD.value,
State: 'Norway',
},
},
];
zoomLevel = 5;
}
When I open the record page I get the following error:
render threw an error in 'c:map' [Cannot read property 'ADDRESS_FIELD' of undefined]
The Project__c.Address__c is populated, so I'm not sure how to continue.
I tried replacing this.project.ADDRESS_FIELD.value
with this.project.ADDRESS_FIELD
but got the same results.
console.log
tothis.project
and see the structure it returns.this.project
will result inundefined
- just as the error says. You may have a typo in import section. Is your SObject's API NamePRoject__c
orProject__c
? Can you also share some more code?