[SalesForce] LWC Quick Action on Case

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>

Best Answer

This is a platform limitation and articulated here. Quoting from the docs below

NOTE Actions on user profiles, cases, and work orders can appear in a different way than on other records.

Actions on the user profile page come from the Quick Actions in the Salesforce Classic Publisher section of the global publisher layout. Only standard Chatter actions appear on the user profile page, regardless of which actions are assigned to the User Page Layout or the global publisher layout.

When feed tracking is enabled for cases or work orders, the page-level action menu on those records contains only custom buttons and supported standard buttons. Quick actions appear on the Chatter tab.

So how to solve this,

  • Use dynamic actions documented here

OR

  • If you do not need chatter feed, disable feed tracking for case object.
Related Topic