Conga cannot support customized code. Due to the complicated nature of supporting programmers and programming languages, the integration of Conga with Visualforce, Apex, and Javascript (or other programming languages) is outside the scope of Conga support.

Use Conga Grid to integrate Conga Batch with Salesforce Classic, Lightning and Salesforce One (SF1).

Ensure that you created a Conga Batch formula field. For more information, see the Conga Batch Product Guide. You will need to reference the API Name of the formula field in subsequent steps.

You cannot create a new Apex class in a Production environment. Create the new class in a Sandbox org and then deploy the Apex class to a Production org after testing. To learn more, see Create Apex classes in a production organization.

To create a Conga Batch List View Button in Lightning:

  1. Create an Apex Class.
    1. Navigate to Salesforce Setup and search for Apex in the Quick Find search box.
    2. Click Apex Classes under the Develop section.
    3. Click New to create a new Apex class.
    4. Copy and paste the code below into the Apex Class Edit section.

      /**
      * @description Builds list of sObject Ids from recordSetVar and constructs the Conductor URL
      */
      public class ConductorFromListViewController {
        private final static String urlFieldName = 'test__c';
        private String partnerServerUrl;
        private ApexPages.StandardSetController controller;
        private List<Id> recordIds = new List<Id>();
      
        public ConductorFromListViewController(ApexPages.StandardSetController controller) {
          this.controller = controller;
          for (sObject sObj : controller.getSelected()){
            recordIds.add(sObj.Id);
          }
          partnerServerUrl = System.URL.getOrgDomainUrl().toExternalForm()+'/services/Soap/u/26.0/'+UserInfo.getOrganizationId();
        } 
      
        public PageReference prepareConductorUrl() {
          PageReference conductorUrl = new PageReference('https://conductor.congamerge.com?');
          conductorUrl.getParameters().put('MOID', String.join(new List<Id>(recordIds),','));
          conductorUrl.getParameters().put('SessionId',  UserInfo.getSessionID());
          conductorUrl.getParameters().put('ServerUrl',  partnerServerUrl);
          conductorUrl.getParameters().put('UrlFieldName',  urlFieldName);
      
          return conductorUrl;
        }
      }
      CODE



    5. Replace the test__c field referenced in the code with the API name of your formula field.
    6. Click Save.
  2. Create a second Apex class after completing Step 1.

    This second Apex class is the Test class.

    1. Copy and paste the content below into the Apex Class Edit Section.

      The specific code below is for the standard Account object.

      /**
      * @description Test Class for the ConductorFromListViewController Class
      */
      @isTest
      public with sharing class ConductorFromListViewControllerTest {
          /**
          * @description setup - test data setup method
          */
          @testSetup
          public static void setup(){
              List<Account> testAccounts = new List<Account>();
      
              Account a = new Account();
              a.Name = 'ABC Company, Inc.';
              testAccounts.add(a);
      
              Account acct = new Account();
              acct.Name = 'XYZ Company, Inc.';
              testAccounts.add(acct);
      
              insert testAccounts;
          }
          /**
          * @description testMethod1 - Test Happy Path of code
          */
          public static testMethod void testMethod1() {
              List<sObject> accts = (List<Account>)[Select Id From Account];
              System.debug(accts);
              ApexPages.StandardSetController ssc = new ApexPages.StandardSetController(accts);
              ssc.setSelected(accts);
              ConductorFromListViewController cn = new ConductorFromListViewController(ssc);
              cn.prepareConductorUrl();
              Test.startTest();
              PageReference pr = cn.prepareConductorUrl();
              String fieldName = pr.getParameters().get('UrlFieldName');
              System.assertEquals('test__c',fieldName, 'The UrlFieldName parameter is not set' );
              Test.stopTest();
          }  
      }
      CODE
    2. Replace the test__c field reference in the code with the API name of your formula field.
    3. Click Save.
  3. Create a Visualforce page.
    1. Navigate to Salesforce Setup and search for Visualforce Pages in the Quick Find search box.
    2. Click Visualforce Pages.
    3. Click New to create a new Visualforce page. Label the Visualforce page as BatchList View.
    4. Delete the existing code and then copy and paste the code below into the new Visualforce page.

      This example demonstrates a List View button on the Account Object. If your formula field is located on a different object, update the bold section (the value of the Standard Controller) with the correct object.

      <apex:page standardController="Account" extensions="ConductorFromListViewController" recordSetVar="records" action="{!prepareConductorUrl}"> </apex:page>
      CODE
  4. Create a new button or link on your object.
    1. Navigate to your object in Salesforce Setup and select Button, Links, and Actions. Click New Button or Link.
    2. Fill out the required Label and Name fields to name the List View button.
    3. Select List Button as the Display Type value and check Display Checkboxes (for Multi-Record Selection).
    4. Choose Visualforce Page as Content Source value.
    5. Choose the newly created Visualforce page as the Content Source value.
  5. Add the new List View button to the list in the object's Search Layouts.
    1. Navigate to the object in Salesforce Setup and click Search Layouts for Salesforce Classic.
    2. Click Edit next to the object's List View Search Layout.
    3. Select and move the new List View button from the Available Buttons column to the Selected Buttons column.
    4. Click Save.