• Sandeep Ekambe
  • NEWBIE
  • 0 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
Created a LWC to display Account Record data using the APEX wire method, after pushing the code to the scratch org, created a new Lightning Account record page, was trying to drag and drop the above LWC onto this page but this throws below error 
User-added image

Below is the code

.js code
import { LightningElement, wire } from 'lwc';
    import getAccountList from '@salesforce/apex/GetAccountData.getAccountList';
     
    export default class LWCWireEx extends LightningElement {
        @wire(getAccountList) accounts;
    }

.html code
<template>
            <lightning-card title="Apex Class Example(lWCWireEx compo)" icon-name="custom:custom63">
                    <div class="slds-m-around_medium">
                        <template if:true={accounts.data}>
                            <template for:each={accounts.data} for:item="acc">
                                <p key={acc.Id}>{acc.Name}</p>
                            </template>
                        </template>
                        
                    </div>
                </lightning-card>
        </template>


GetAccountData.cls APEX code
public with sharing class GetAccountData {
       @AuraEnabled(cacheable=true)
        public static List<Account> getAccountList() {
            return [SELECT Id, Name,Type,Rating,Phone FROM Account];
        }
    }

 
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>


 
Hello All,

Trying to save the code in the 'developer console' editor window but the code is never saved. Unable to save and execute my programs because of this problem.

Please view this screen recording of the problem
https://bit.ly/2J27QGX