Hi Aswini, I have different recordtypes, i'm displaying like A, B, C sections in page when click on button and i dont' want to display B section based on record type .
To achieve this you can create a variable in js and use the apex controller to get the record type and then based on the value you can set the condition in HTML of your LWC component.
<template>
<template if:true={RecordType=='A'}>
<p>This is content for Record Type A.</p>
</template>
<template if:true={RecordType=='B'}>
<p>This is content for Record Type B.</p>
</template>
<template if:true={RecordType=='C'}>
<p>This is default content for other Record Types.</p>
</template>
</template>
import { LightningElement, api, wire } from 'lwc';
import getRecordType from '@salesforce/apex/RecordTypeController.getRecordType';
export default class Example extends LightningElement {
@api recordId; // Assuming you have a property to store the record Id
recordType;
@wire(getRecordType, { recordId: '$recordId' })
wiredRecordType({ error, data }) {
if (data) {
this.recordType = data;
// Now, this.recordType contains the record type name
} else if (error) {
// Handle any errors
}
}
}
Can you elaborate more on the ask?
I have different recordtypes, i'm displaying like
A, B, C sections in page when click on button and i dont' want to display B section based on record type .
Thanks
KMK
Hi,
To achieve this you can create a variable in js and use the apex controller to get the record type and then based on the value you can set the condition in HTML of your LWC component.
I hope this will help you.
Thanks!