2
<lightning-record-edit-form object-api-name="Account">
       <lightning-input-field field-name='Name'></lightning-input-field>
</lightning-record-edit-form>

above peice of code displays the help text of the field if the component is used inside salesforce org. But if it's used in the community help text is not displayed. Any way to achieve this.

0

It looks like you have to ditch lightning-record-edit-form and use getObjectInfo from uiObjectInfoApi and getRecord from uiRecordApi

I have created a custom-record-edit-form earlier that fetches data and metadata, you can refer it.

Markup:

<template>
    <template if:true={complexAccount}>
        <template for:each={complexAccount} for:item=field>
            <lightning-input key={field.apiName} label={field.label} value={field.value}
                             field-level-help={field.inlineHelpText}></lightning-input>
        </template>
    </template>
</template>

JS:

import { LightningElement , wire , api } from 'lwc';
import { getRecord } from 'lightning/uiRecordApi';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import ACCOUNT_OBJECT from '@salesforce/schema/Account';
import NAME_FIELD from '@salesforce/schema/Account.Name';
import PHONE_FIELD from '@salesforce/schema/Account.Phone';

export default class Accountpage extends LightningElement {
    @wire(getRecord, { recordId: '0012600000xI6vh', fields: [NAME_FIELD,PHONE_FIELD] })
        account;

    @wire(getObjectInfo, { objectApiName: ACCOUNT_OBJECT })
        accountObjectInfo;

    get complexAccount(){
        let ac = [];
        if(this.account.data && this.accountObjectInfo.data){
        Object.keys(this.account.data.fields).forEach(ele => {
                var indElement;
                indElement = {...this.account.data.fields[ele]};
                indElement.inlineHelpText = this.accountObjectInfo.data.fields[ele].inlineHelpText;
                indElement.apiName = this.accountObjectInfo.data.fields[ele].apiName;
                indElement.label = this.accountObjectInfo.data.fields[ele].label;
                ac.push(indElement);
        });
        return ac;
        }
    }

}
|improve this answer|||||
  • How can i get the picklist values from the schema for the user to select ? I'm trying on new record creation not editing. Thanks – steamyfire Jan 21 at 16:49
  • You can look into getPicklistValues – Pranay Jaiswal Jan 23 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.