Conga Product Documentation

Welcome to the new doc site. Some of your old bookmarks will no longer work. Please use the search bar to find your desired topic.

Batch Email

Custom Action Name

Batch_Send_Pardot_Emails

Objects affected

None

Description

This is an example of a custom action that integrates Conga Grid with a marketing email application.

Use Cases

Send Pardot emails from a Conga Grid. This could be really useful from a targeted list of contacts or leads.

Steps

crmc.require(['sfdc', 'KendoPopup'], function (sfdc, popup) { crmc.addCustomAction({ "itemID": "Batch_Send_Pardot_Emails", "isAvailable": function (context) { // This function is called before the action item is displayed and returns a boolean if the item should be displayed // By default determine availability based on Feature Security for this action var isEnabled = this.featureSecurity.getSetting(context.objectDescribe.name, this.itemID) !== false; // Only allow this action from Contacts and Leads var isCorrectContext = context.objectDescribe.name == "Contact" || context.objectDescribe.name == "Lead"; var multipleSelected = context.selectedRows && context.selectedRows.length > 0; return isCorrectContext && isEnabled && multipleSelected; }, "getLabel": function (context) { // This function returns the display label of the action item and is called before the item is shown return "Send Engage Email"; }, "createSubmenuItems": function (context) { // If this function returns additional action item objects, they will appear as submenu items return []; }, "click": function (context) { var sendToVFPage = function() { var selectedIds = []; if (context.selectedRows.length > 0) { //Is the context Contact or Lead? Set the page to the correct VisualForce page. var page = context.objectDescribe.name == "Contact" ? "MicroCampaignContact" : "MicroCampaignLead"; Object.each(context.selectedRows, function (item) { selectedIds.push({name: "ids", value: item["Id"]}); }); var parameters = { retURL: context.actionGrid.settings.pageURL, }; sfdc.postToVFPage("pi", page, parameters, selectedIds, false, "_blank"); } else { popup.popup('Please select records', 'Select at least one record to process.'); } }; // Include static resource from managed namespace pre-creates session and allows us to safely POST data without the redirect issue var head = document.getElementsByTagName('HEAD').item(0); var script = document.createElement("script"); script.type = "text/javascript"; head.appendChild(script); var domains = window.location.hostname.split("."); if (domains.length == 3) { instance = domains[0]; } else { instance = domains[1]; } script.src = "https://pi." + instance + ".visual.force.com/resource/loadingSpinner?ts=" + new Date().getTime(); //On error call page logic because you will still have a session. script.onerror = function() { sendToVFPage(); }; //Call page logic. script.onload = function() { sendToVFPage(); } } });});