+ Start a Discussion

Display Case Type as button in LWC in Contact Record Page

May I ask on how to query all the case types and output into the button in a button in lwc apex and aura only?

Something like this:
User-added image
Best Answer chosen by Yukinon
ravi soniravi soni
hi Yukinon,
I don't know is there any relationship between contact and case but we can get case picklist values without calling apex.take reference from below code.
import { LightningElement,wire } from 'lwc';
import { getPicklistValues } from 'lightning/uiObjectInfoApi';

import caseType from '@salesforce/schema/Case.Type';
import { getObjectInfo } from 'lightning/uiObjectInfoApi';
import CASE_OBJECT from '@salesforce/schema/Case';

export default class DisplayCaseTypeButtonInLwc extends LightningElement {
    caseTypeData = [];
 @wire(getObjectInfo, { objectApiName: CASE_OBJECT })

            recordTypeId: '$caseInfo.data.defaultRecordTypeId',
            fieldApiName: caseType
console.log('data========> ' + JSON.stringify(data));
this.caseTypeData = data.values;
        else if (error){
console.log('error========> ' + JSON.stringify(error));
    <template for:each={caseTypeData} for:item="value">
        <lightning-button   key={value.value} class="slds-m-right_small" variant="brand" label={value.label}  onclick={handleClick}></lightning-button> 

if you have recordtype in case object, you can get picklist values by below reference.

in my code I got values without recordType.
don't forget to mark it as the best answer if it helps you.
Thank you