lightning-record-view-form use lightning-output-field and is used to display information related to that record. The field-level security and sharing are taken into consideration by this component so user will only see the data they have access to.
Note: Not all standard object are supported.
For ex: Event and task.
To display the fields on a record, use lightning-output-field.
lightningRecordViewFormExample.html
<template>
<lightning-record-view-form
record-id={recordId}
object-api-name="Account">
<div class="slds-box">
<lightning-output-field
field-name="Name">
</lightning-output-field>
<lightning-output-field
field-name="Description">
</lightning-output-field>
</div>
</lightning-record-view-form>
</template>
lightningRecordViewFormExample.js
import {
LightningElement,api } from 'lwc';
export default class
LightningRecordViewFormExample extends LightningElement {
@api recordId;
}
lightningRecordViewFormExample.js-meta.xml
<?xml
version="1.0" encoding="UTF-8"?>
<LightningComponentBundle
xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>50.0</apiVersion>
<isExposed>true</isExposed>
<targets>
<target>lightning__RecordPage</target>
</targets>
</LightningComponentBundle>
Output:
No comments:
Post a Comment