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
YukinonYukinon 

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 })
    caseInfo;

    @wire(getPicklistValues,
        {
            recordTypeId: '$caseInfo.data.defaultRecordTypeId',
            fieldApiName: caseType
        }
    )
    caseTypeValues({data,error}){
        if(data){
console.log('data========> ' + JSON.stringify(data));
this.caseTypeData = data.values;
        }
        else if (error){
console.log('error========> ' + JSON.stringify(error));
        }
    }
    
}
================================================
<template>
    <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> 
    </template>
</template>

if you have recordtype in case object, you can get picklist values by below reference.
https://www.salesforcepoint.com/2020/08/lwc-picklist-get-pick-list-values-with.html#:~:text=Fetching%20and%20Displaying%20Picklist%20Values%20In%20Lightning%20Web,to%20fetch%20picklist%20values%20by%20using%20dynamic%20schema.the

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