function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sandeep EkambeSandeep Ekambe 

Unable to fetch custom object record into LWC using getRecord(), wire adapter

Hello All,
Trying to display single field(age__c) from a custom object(MVStudent__c) but its displaying blank on the record page.

Below is the code, please help me out.

loadRecord2.js
import { LightningElement, api, wire } from 'lwc';
/* Wire adapter to fetch record data */
import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import MVSTUDENT_OBJECT from '@salesforce/schema/MVStudent__c';
import AGE_FIELD from '@salesforce/schema/MVStudent__c.Age__c';
export default class AccountViewer extends LightningElement {
/** Id of record to display. */
@api recordId;
/* Expose schema objects/fields to the template. */
mvstudentObject = MVSTUDENT_OBJECT;
/* Load Account.Name for custom rendering */
@wire(getRecord, { recordId: '$recordId', fields: [AGE_FIELD] })
record;
/** Get the Account.Name value. */
get ageValue() {
return this.record.data ? getFieldValue(this.record.data, AGE_FIELD) : '';
}
}
loadRecord2.html
<template>
        <lightning-record-view-form
                record-id={recordId}
                object-api-name={mvstudentObject}>
            <div class="slds-grid">
                <div class="slds-col slds-size_1-of-2">
                    <!-- Other record data here -->
                </div>
                <div class="slds-col slds-size_1-of-2">
                    <lightning-formatted-text value={ageValue}
                        class="slds-text-heading_large">
                    </lightning-formatted-text>
                </div>
            </div>
        </lightning-record-view-form>
    </template>