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

Create a Case Related to a Specific Contact using LWC Button

I created an LWC button that gets the picklist value of a case type in the record contact page. I want to create a function wherein it will create case when clicked that is related to the current contact record and the case type is the same value as the clicked button.

User-added image

Basically, I want to clone the function of this default related case button here in the contact record pagge with case type is the same as the button clicked above and contact is automatically loaded.
User-added imageUser-added image

Apex Controller:
public class CaseCreationController {
    public static List<String> getCaseTypePicklist(){
    	List<String> pickListValuesList= new List<String>();
		Schema.DescribeFieldResult fieldResult = Case.Type.getDescribe();
		List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
		for(Schema.PicklistEntry pickListVal : ple){
		return pickListValuesList;

<aura:component controller="CaseCreationController" implements="flexipage:availableForAllPageTypes" access="global">
  	<aura:attribute name="caseType" type="List" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
        <div class="slds-p-around_medium">
            <aura:iteration items="{!v.caseType}" var="cs">
            <lightning:button variant="brand-outline" label="{!cs}" onclick="{!c.createCase}" name="{!cs}" />

	doInit : function(component, event, helper) {
		    var action =  component.get("c.getCaseTypePicklist");
       		action.setCallback(this, function(response){
            var state = response.getState();
            if(state === "SUCCESS")	{
               component.set("v.caseType", response.getReturnValue()); 
     createCase : function (cmp, event) {
        //Create Case function here