We need to convert some buttons to lightning quick actions to have on the lightning experience. I'm having a difficult time designing an adequate solution.

Current Button Functionality:

var result = sforce.apex.execute("CloneObject","cloneQuote",
        cloneAttachments: true

window.open(result + '/e?&retURL=' + result + '&saveURL=' + result);

This calls out to a piece of APEX code in a class called CloneObject and runs a method called cloneQuote. This is custom clone functionality because we would like to clone related objects as well.

Lightning Quick Action Functionality:

I ventured down the path of a VisualForce quick action, but it's unnecessary for a modal window to open. It just needs to be a button.

Is there an elegant quick action alternative for calling out to a piece of apex code?

2 Answers 2


I think no matter what kind of Quick Action you do, native or customized, it will always open a modal window in Lightning.

You could create a small VisualForce page or Lightning component to add directly to the Lightning page layout, which simply hosts a button that carries out the desired action. That may be the only way to put a one-click action inside the layout.

Here is another thought: Create a native Quick Action that creates a record copying over whatever fields you want as Predefined Values, and allows them to edit any they want to. This will display as a modal dialog, replacing the Edit page they'd get patched through to. But also set a Predefined Value in text field that is hidden from the Action layout. This hidden value would be the ID of the record you clone. Now you can set an Apex trigger that states, if a record is created with a value in the hidden field, run your custom code that clones the child objects.

  • Thanks Charles, I believe this is the path I'll have to take. I semi like the nested lightning page on the page layout, however I wish it could be located next to the quick action buttons. Just a limitation of the system. I wish they would allow custom javascript buttons in lightning. Mar 16, 2017 at 18:12
  • If you want it next to the QA buttons then go with a QA. The user flow with the JS button was, 1) click the button, 2) it executes Apex to clone the children, 3) you get an edit page for the cloned record, 4) you save it. The user still passes through one intermediate page to get to the end result. So if you go with a native Quick Action instead, you get the same number of steps with a different order of execution: 1) click the button, 2) you get a modal layout with predefined values instead of an Edit page, 3) you save it, 4) it executes Apex to clone the children.
    – Charles T
    Mar 17, 2017 at 14:49

Recently I transformed a similar js button into a visualforce action this way:

  1. Create a Visualforce Action (see how to create a visualforce action ) where you do the callout and redirect once the page is requested (see apex:page action attribute)
  2. On page layout find your action under "Salesforce1 and lightning actions" and place it to the "Salesforce1 and Lightning Experience Actions" section of the layout

When user clicks the action - a blank quick action popup appears for a second, than the redirect occurs.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .