[SalesForce] Custom Button – Close the Status for Cases in Lightning Experience

I am struggling with the following task:

1) I need to create a custom button "Close the status", that closes the status for the Case and

2) it should be located at the same position as on the picture below (location of the Close the ticket).

enter image description here

I have tried different things:

  1. I created a quick action that just updates the record with a pre-defined value of the Status – Closed. It works, but it is located in the Chatter. I disabled the Feed Tracking for Case, Quick Actions moved to the Highlight Panel, as I wanted… but the Chatter disappeared, which we still need to have.

  2. I tried to create a Custom Button with a Display Type – Detail Page Button, Behavior: Execute Java Script, with a Content Source: OnClick JavaScript with the following code:

    {!REQUIRESCRIPT("/soap/ajax/29.0/connection.js")}
    var p = new sforce.SObject("Case");
    p.id = "{! Case.Id }";
    p.Status = "Closed";
    result = sforce.connection.update([p]);
    location.reload(true);

This code works good and it changed the status of the case in one click, but…only in Classic. I don't see it in Lightning 🙁

  1. I tried to create a custom button with Display Type – Detail Page Button, Content Source – URL and with: /{!Case.Id}/s?retURL=%2F{!Case.Id}&cas7=Closed

    Closes the status but only in Classic.

All custom buttons I put into the page layout for the custom button placeholder, but I don't see them at the Lightning Experience at all.

I am Beginner in Apex and Visualforce pages, but I have a feeling maybe it is possible to create a custom button with Apex or Visualforce.

If someone had the same problem with the Close the Status button, could you please tell me the direction? Is it possible to create a custom button with Apex or Visualforce? What are the steps?

Best Answer

There are a couple of overlapping challenges here.

  • JavaScript buttons are not supported in Lightning, so that option is out.

  • Cases have special behavior in Lightning Experience regarding placement of Quick Actions:

    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.

If you must have this button shown in the button bar on the Case record page, and you must have feed tracking turned on, I believe only code-based solutions remain available to you.

Those would be either

  • Developing a Visualforce-page button, where I think you may find getting the user experience just right a bit challenging.
  • Developing a Lightning component that can be placed on a custom Lightning Record Page.

I would prefer the latter, myself, for a fully-native Lightning experience. However, I don't believe there's a way to do either of these without writing Apex + either Visualforce or Lightning JavaScript.

Related Topic