So I have a Case lightning record page. Then I created a LWC to display some text depending on the record type of the page and put that LWC into the lightning record page. The text that is displayed is controlled by a property in the LWC. I can only pass in a constant string into the property from the lightning record page. I don't know how to pass in a variable (record type). Does anyone know if this is possible?


1 Answer 1


You can't pass it in directly. What you're expected to do is to call LDS (Lightning Data Service). You do this by importing the method and then using the magic api attribute recordId:

import { getRecord, getFieldValue } from 'lightning/uiRecordApi';
import { LightningElement, wire, api } from 'lwc';
import RECORDTYPEFIELD from '@salesforce/schema/ObjectName/RecordTypeId';

export default class MyComponent extends LightningElement {
  @api recordId;
  @wire(getRecord, { recordId: '$recordId', fields: [RECORDTYPEFIELD] })
  record({data,error}) {

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .