Skip to main content
Conga Support

Create a Conga Batch List View Button (Lightning Experience)

  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 not supported.

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

Before you begin

You must have created a Conductor and Batch formula record. For more information see the Conga Batch Product Guide.

Alternative integration method

You can integrate Conga Batch within Salesforce Lightning.

1. Create a Visualforce page with a set controller.

2. Create a new button of type Visualforce. Enable Display checkboxes (for Multi-Record Selection) and selecting Content as the Visualforce page. 

clipboard_ec6511db35a0238f328acc9120855fad6.png

 3. Add the newly created button to the list in Search Layouts.

clipboard_ec88c48fe24d3c372b06abae5d22ff99e.png

From Step 1:

This example demonstrates how the code is setup for a List View Button on the Account Object. If you are using a different Object, the Standard Controller value in the Visualforce Page should reflect that Object.

  1. Create your Controller Extension (Conductor__c assumes you have created a formula field on object already). Note the placement and reference of the Conductor__c formula field below. 
/**
* @description Builds list of sObject Ids from recordSetVar and constructs the Conductor URL
*/
public class ConductorFromListViewController {
  private final static String urlFieldName = 'Conductor__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 = 'https://'+ApexPages.currentPage().getHeaders().get('Host')+'/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;
  }
}

2. Create a Test Class.

/**
* @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('Conductor__c',fieldName, 'The UrlFieldName parameter is not set' );
        Test.stopTest();
    }  
}

3. Create a Visualforce Page   

<apex:page standardController="Account" extensions="ConductorFromListViewController" recordSetVar="records" action="{!prepareConductorUrl}">
</apex:page>

According to Salesforce, you cannot create a new Apex class in a Production environment. You should be able to create a new class in the Sandbox org and publish that org updated to your Production Org. To learn more, see Create Apex classes in a production organization.