I am trying to create a button on Case to set the Status to Closed Case, however the button is not appearing on the Case Page Layout and I am not sure why.
I dont see that when creating a Lighting Web Component Quick Action there is anything that actually ties the code to a specific object when creating the Quick Action. To clarify I created the below quick action on Opportunity as well as Case. It oddly enough shows on Opportunity but does not show on Case? Is this some odd Limitation to the platform?
JS
import { LightningElement , api} from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { getRecordNotifyChange } from 'lightning/uiRecordApi';
//This calls the Apex Class which is a function
import lwcCloseCase from '@salesforce/apex/clsCloseCase.CloseCase';
export default class CloseCase extends LightningElement {
@api recordId ;
renderedCallback() {
CloseCase({
caseId: this.recordId
})
.then((cases) => {
const event = new ShowToastEvent({
title: 'Success',
message: 'Case Record has been Closed',
variant: 'success',
});
this.dispatchEvent(event);
getRecordNotifyChange([{recordId: this.recordId}]);
})
.catch((error) => {
const event = new ShowToastEvent({
title: "Error on update",
message: error.body.message,
variant: "error",
mode: 'sticky',
});
this.dispatchEvent(event);
});
}
}
HTML
<template>
</template>
APEX
public with sharing class clsCloseCase {
@AuraEnabled
public static Case CloseCase(Id caseId) {
Case soCase = [SELECT Id, RecordTypeId, Status FROM Case WHERE Id = :caseId];
soCase.Status = 'Close Case';
Update soCase;
Return soCase;
}
}
AURA.CMP
<aura:component implements="flexipage:availableForAllPageTypes,force:lightningQuickAction"
access="global" >
<c:lwcCloseCase></c:lwcCloseCase>
</aura:component>