Skip to main content
Conga Support

Attach File

Custom Action Name

AG_AttachFile

Objects affected

Any objects that can have Attachments.

Description

This custom action adds an Attachment from any object that can have them. Use this on the level of the object you wish to attach something to. This will open a new window for each selected record, where you can add a Salesforce attachment using the native Salesforce attachment mechanisms.

This will show up on the Action Menu for all objects that allow attachments.

Use Cases

This is currently the main method for adding an attachment to a group of records via the ActionGrid. This will open a new window/browser tab for each selected record, allowing a different attachment to be added to each selected record.

Steps

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.
crmc.require(["KendoEntry", "KendoPopup", "ListButton", "sfdc"],
function(prompt, popup, navigate, sfdc) {
    crmc.addCustomAction({
        "itemID": "AG_AttachFile",
        "isAvailable": function (context) {
            var multipleSelected = context.selectedRows && context.selectedRows.length > 0 && context.selectedRows.length <= 5;
            if (multipleSelected && this.featureSecurity.getSetting(context.objectDescribe.name, this.itemID) !==false){
               var children = context.objectDescribe.childRelationships;
               for (var i = 0; i < children.length; i++) {
                 if (children[i].childSObject == 'Attachment'){
                       return true;
                   }
               };
            }
            return false;
         },
         "getLabel": function (context) {
           return "Attach File";
         },
         "createSubmenuItems": function (context) {
             return [];
         },
         "click": function (context) {
             var ids = [];
             context.selectedRows.map(function(row) {
                 ids.push(row.Id);
             });
             var data = sfdc.query("SELECT Id, Name FROM "+context.objectDescribe.name+" WHERE Id IN('" + ids.join("','") + "')");
             for (var i = 0; i < data.length; i++) {
                 var row = data[i];
               if(row.Name != undefined && row.Name != null){
                   window.open("/p/attach/NoteAttach?pid=" + row.Id+"&parentname="+encodeURIComponent(row.Name));
               }
               else{
                   window.open("/p/attach/NoteAttach?pid="+row.Id);
               }
             };
          }
      });
});
  • Was this article helpful?