Wire Service GetRecord is not working


Here are some possible reasons why your wire service is not working, in this case the data will be undefined or current record id is not coming in the component

API names are case sensitive

All the API Names that you mention in Fields are case sensitive. So If you are using a constant variable to specify Fields, ensure they are defined as per your field definition in setup.

const FIELDS = ['Contact.Name', 'Contact.Phone']; 
//Here Name and Phone are the contact fields and 
//must be defined in same case as it is defined at object level

RecordId is not passed properly

There could be two reason for this problem

  • Ensure recordId is decorated with api decorator in lwc component, otherwise the current record context will not be respected and it cant get record id.
@api recordId;
  • If you are using lightning web component as a quick action, it needs to be embedded inside an aura component and pass the record id from aura component. So ensure the recordId is passed to lwc as below.
<c:disclosureRequestForm recordId ="{!v.recordId}" />

Field permission is not there

As per the documentation, the fields parameter in wire respect current user permissions, so the current user should have access to those fields.

As per the documentation, here is the statement

If the context user doesn’t have access to a field, an error is returned. If you’re not sure whether the context user has access to a field and you don’t want the request to fail if they don’t, use the optionalFields parameter.

If you are facing any issues or you want to share your challenges that you faced while working with wire service, please comment below



Please follow and like us: