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
Ragula SivakumarRagula Sivakumar 

Can we display the fields based on record type in using LWC component.

I want to display few fileds based on  record type using lWC.
I have two record type A,B .
I want to  display the field 3 if the record type is B and also display the field 6 using if the record type is A.

 

 

<template>
    <lightning-card  icon-name="standard:investment_account"   variant="narrow"   title="eDM Tactic" >
      <lightning-record-view-form record-id={recordId} object-api-name="Campaign">
         <div class="slds-grid slds-wrap">
           <div class="slds-col slds-size_1-of-2">
              <div class="slds-p-around_medium">
                <lightning-output-field field-name="field1" class="slds-m-right_x-small"></lightning-output-field>
                  <lightning-output-field field-name="field2"></lightning-output-field>
                    <lightning-output-field field-name="field3"></lightning-output-field>
                      </div>
                        </div>
                         <div class="slds-col slds-size_1-of-2">
                       <div class="slds-p-around_medium">
                     <lightning-output-field field-name="field4" class="slds-m-right_x-small"></lightning-output-field>
                   <lightning-output-field field-name="field5"></lightning-output-field>
                 <lightning-output-field field-name="field6"></lightning-output-field>
              </div>
            </div>
         </div>
       </lightning-record-view-form>    
    </lightning-card>
 </template>

 
Ragula SivakumarRagula Sivakumar
Forgot to add the JS file.
 
import { LightningElement ,api,track,wire} from 'lwc';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import CAMPAIGN_OBJECT from '@salesforce/schema/Account';
export default class EDMtacticfields extends LightningElement {
    @api recordId;
    @api objectApiName;
    @track objectInfo;
    @wire(getObjectInfo, { objectApiName: CAMPAIGN_OBJECT })
    objectInfo;
}