Skip to main content
Conga Support

Conga Query Code Example

Normally when you run the Conga > Batch Invoice action on multiple records (see Conga Conductor Solutions - Multiple Rows), Conga Conductor creates separate output documents. The custom action code below will add a Conga Query item to the Action menu. It will pass the records into a single Conga Composer solution so that you can merge the records into one document. Here is an example:

This example merges the selected records to create a single Invoice document.

The use of JavaScript in Conga solutions is considered an advanced method, requiring JavaScript knowledge, and is not supported by Conga or the Conga support team. You are welcome to use this feature at your own risk.

Follow these steps to create the custom action:

  1. Click ActionGrid Setup.
  2. Select the object for which you want to create the custom action.
  3. Select the object Features tab.
  4. Click New Custom Action. The Custom Action screen appears.
  5. Delete the sample code from the Javascript field.
  6. Copy and paste the following code into the Javascript field.
  7. Copy the itemID value and paste it as the Action Name.
  8. Click OK.
var templateId = 'a2to0000000YX8d';
var queryId = 'a2lo0000000u0pl';
var label = 'Conga Query';

crmc.addCustomAction({
  "itemID": "CongaQuery",
  fieldName: '',
  "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
    return this.featureSecurity.getSetting(context.objectDescribe.name, this.itemID) !== false;
  },
  "getLabel": function (context) {
    // This function returns the display label of the action item and is called before the item is shown
    return label;
  },
  "createSubmenuItems": function (context) {
    // If this function returns additional action item objects, they will appear as submenu items
    return [];
  },
  "click": function (context) {
    if (context.selectedRows.length > 0) {
      var ids = '';
      Object.each(context.selectedRows, function(item) {
        if (ids.length > 0) ids += "'|'";
        ids += item.Id;
      });
      var url =  "https://composer.congamerge.com" +
    "?sessionId=" + sforce.connection.sessionId +
    "&ServerUrl=" + context.actionGrid.settings.Partner_Server_URL_290 +
    "&Id=" + sforce.connection.getUserInfo().userId +
    "&templateId=" + templateId +
    "&QueryId="+ queryId +"?pv0='" + ids +"'";
      window.open(url, 'Conga', 'width=700,height=450,menubar=0');
    }
    else {
      kendoPopup.popup('Please select records',
        'Select at least one record to send to Conga.');
      return;
    }
  },
});
  • Was this article helpful?