[This article is specific to Decisions on Demand version 1.14. If you are using version 1.15 or later please see this updated article instead]

In Classic, list view buttons for Decisions on Demand are implemented using JavaScript, which is not supported in Lightning.

This article describes how to create list view buttons in Lightning using a Visualforce page, which is the approach recommended by Salesforce.

The steps are as follows:

  • Install the Lightning Extension unmanaged package as described here.
    This will create a Visualforce component called DecsOnD_ApplyPolicyToList
    If you cannot install the unmanaged package, please see below for the complete source of the Visualforce component.
  • Create a Visualforce page to use in the list view button
    The content of the page is as follows:
    <apex:page standardController="Lead" recordSetVar="Leads" showHeader="false" sidebar="false">
       <c:DecsOnD_ApplyPolicyToList objectName="Lead" policyName="Assignment" records="{!selected}"/>
    The text in bold should be replaced with the applicable object type and policy name.
    Note that a separate page needs to be created for each business policy that requires a list view button.
  • Create a custom list view button referencing the Visualforce page
    It should look something like this:
  • Add the button to the List view search layout for the desired object

Visualforce component source

If you are unable to install the Lightning Extension unmanaged package, you can recreate the Visualforce component referenced above. 

The source is:

<apex:component >
<apex:attribute name="objectName" description="The name of the main object for the policy" type="String" required="true"/>
<apex:attribute name="policyName" description="The name of the policy to be applied" type="String" required="true"/>
<apex:attribute name="records" description="The records to which the policy will be applied" type="sObject[]" required="true"/>

var ids = [];
<apex:repeat value="{!records}" var="rec">
var url = "/apex/DecsOnD__ApplyPolicyToList?object=" + "{!URLENCODE(objectName)}" + "&policy=" + "{!URLENCODE(policyName)}" + "&ids=" + ids.join();
window.open(url, "_self");