You need to sign in to do that
Don't have an account?
Yukinon
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.
Screenshot:
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.
Apex Controller:
Component:
JSController:
Thanks!
Screenshot:
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.
Apex Controller:
public class CaseCreationController { @AuraEnabled 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){ pickListValuesList.add(pickListVal.getLabel()); } return pickListValuesList; } }
Component:
<aura:component controller="CaseCreationController" implements="flexipage:availableForAllPageTypes" access="global"> <aura:attribute name="caseType" type="List" /> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <lightning:card> <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}" /> </aura:iteration> </div> </lightning:card> </aura:component>
JSController:
({ 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()); }else{ alert("ERROR"); } }); $A.enqueueAction(action); }, createCase : function (cmp, event) { //Create Case function here } })
Thanks!