Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: added documentation of new batch endpoints

...

titleAttachments

...

Table of Contents

Single Attachment Actions

readAttachment

icon

This API call returns an array containing a dictionary with the Attachment object matching the Id specified.

Important returned fields:

  • Body – base64 encoded attachment data (if ReturnBase64Data is not false)

  • ThumbBody

 – base64
  •  – base64 encoded attachment thumbnail data (if ReturnBase64Data is not false and attachment is an image)

  • FileURL – local URL to the attachment file

  • ThumbURL – local URL to the attachment thumbnail file (empty string if attachment is not an image)

Related Pulsar Settings:

Info
false
Code Block
var request = { 
"type" : "readAttachment",
"data" : {
        "Id" : "001234567891234",    // Required attachment Id
        "ReturnBase64Data" : false   // Optional, default true.  If false you will still have access to URL of attachment
    }
};
bridge.sendRequest(request, function (responseData) { alert('The Attachment is located here: ' + responseData.data[0].
FileUrl
FileURL });
Note

Normal data reads through 'select' API will not contain Base64 Attachment data in the body field unless that body field has previously been queried from Salesforce or otherwise populated with Base64 data.

Panel
title

queryAttachment

false
Info
icon

This API call returns an array of dictionaries representing Attachment objects matching the specified filter. The filter is specified in sqlite where clause format, and is applied to objects in the Attachment table only. For example "(ParentId = '001234567891234')" will return all Attachments where the ParentId field is set to 001234567891234. This method will return URLs to a cached version of the Attachment file, but will not return the file data directly as in readAttachment.

Important returned fields:

  • FileURL – local URL to the attachment file

  • ThumbURL – local URL to the attachment thumbnail file (empty string if attachment is not an image)

Related Pulsar Settings:

Code Block
var request = {

"type" : "queryAttachment",
"data" : {
        "filter" : "ParentId = '001234567891234'"
  
    }
};
bridge.sendRequest(request, function (responseData) { alert('The first Attachment is located here: ' + responseData.data[0].
FileUrl
FileURL });
Note

The queryAttachment API call will NOT return the Attachment's Base64 Body field or the Base64 data representing the thumbnail.

createAttachmentFromCamera

The createAttachment method allows creation of

Info

The createAttachmentFromCamera method allows creation of Attachments directly from the device's camera. The intended Attachment ParentId is a required argument. Optionally, you can specify a file name for the attachment, instead of using the name of the original file. On success, the response data contains the Id of the created attachment.

Panel
titlecreateAttachment
Info
iconfalse
Code Block
var request = {
"type" : "createAttachmentFromCamera",
"data" : {
        "ParentId" : "001234567891234",            // Required
        "Name" : "AttachmentName.jpg"             // Optional
    }
};
bridge.sendRequest(request, function (responseData) {
    if (responseData.type == "createAttachmentResponse") {
        alert('Created Attachment Id: ' + responseData.data);
    }
    else {
        // error code
    }
});

Create Actions on Multiple Attachments (recommended v14+)

createBatchResponse returned from batch endpoints

All of the following endpoints return a response in the format below. The response below is simplified for brevity.

Full Success – all files saved

Code Block
{
    "type": "createbatchResponse",
    "object": "Attachment",
    "data": {
        "summary": { "success": "TRUE" },
        "results": {
            "0": {
                "objectId": "CURIUM_1111111111_1", // this could also be an 069 ContentDocumentId if performed online.
                "success": "TRUE",
                "FileURL": "http://127.0.0.1:17014/datacache/FileName1.jpg"
            },
            "1": {
                "objectId": "CURIUM_222222222_2", // this could also be an 069 ContentDocumentId if performed online.
                "success": "TRUE",
                "FileURL": "http://127.0.0.1:17014/datacache/FileName2.jpg"
            }
        }
    }
}

Partial Success – some files saved

Code Block
{
    "type": "createbatchResponse",
    "object": "Attachment",
    "data": {
        "summary": { "success": "FALSE" },
        "results": {
            "0": {
                "objectId": "CURIUM_1111111111_1", // this could also be an 069 ContentDocumentId if performed online.
                "success": "TRUE",
                "FileURL": "http://127.0.0.1:17014/datacache/FileName.jpg"
            },
            "1": {
                "success": "FALSE",
                "error": "...error message from API for this file..."
            }
        }
    }
}

createAttachmentBatch
Anchor
createattachmentbatch
createattachmentbatch

Info

The createAttachmentBatch method allows creation of multiple Attachments directly from Base64 encoded data.

The intended Attachment ParentId

An array of objects with their intended parent SObject Id (ParentId), Name, and Body are required arguments. The ContentType of the

Attachment

File may be optionally specified in MIME type format, as in the example below. On success, the response data contains the Id of the created

attachment

Attachment.

Code Block
var request = {

"type" : "
createAttachment
createAttachmentBatch",
"data" : [
   {
     
   "ParentId" : "001234567891234",  // Required
        
// Required
"Name" : "
AttachmentName
FileName.jpg",         // Required
      
//
 
Required
 
"Body" : "AABBCCDDEEFF...",      // Base64 data --   Required

        "ContentType" : "image/jpeg"     // Optional -- manual entry of content type
}

    },
    { ... },
    { ... },
]};
bridge.sendRequest(request, function (responseData) {
    
if (responseData.type == "
createAttachmentResponse
createbatchResponse") {
alert('Created Attachment Id: ' + responseData.data); } else {

        // process results
    }
    else {
        // error code
 
   }
});
panel

createAttachmentFromFilePathBatch
Anchor

...

createattachmentfromfilepathbatch

...

createattachmentfromfilepathbatch

false
Info
icon

The

createAttachmentFromFilePath

createAttachmentSFFileFromFilePathBatch method allows creation of multiple Attachments directly from valid, accessible, device file paths.

The intended Attachment ParentId, FilePath

An array of objects with their intended parent SObject Id (ParentId), Name, and Body are required arguments. The ContentType of the

Attachment

File may be optionally specified in MIME type format, as in the example below.

 Optionally

 Optionally, you can specify a file name

for the attachment

, instead of using the name of the original file. On success, the response data contains the Id of the created

attachment

Attachment.

Code Block
var request = {

"type" : "
createAttachmentFromFilePath
createAttachmentFilePath",
"data" : {
    
    "ParentId" : "001234567891234",            // Required

        "Name" : "
AttachmentName
FileName.jpg",                    // Optional

        "ContentType" : "image/jpeg",               // Optional -- manual entry of content type

        "FilePath" : "/Valid/Path/To/File.Jpg"      // Required
    }
};
bridge.sendRequest(request, function (responseData) {
    if (responseData.type == "createbatchResponse") {
         // process results
    }
    else {
        // error code
    }
});

Create Actions on Single Attachments

createAttachment

Info

The createAttachment method allows creation of Attachments directly from Base64 encoded data. The intended Attachment ParentId, Name, and Body are required arguments. The ContentType of the Attachment may be optionally specified in MIME type format, as in the example below. On success, the response data contains the Id of the created attachment.

Note

Multiple create or delete requests MUST NOT run concurrently. If you need to create multiple attachments, it is recommend you using the createAttachmentBatch endpoint to avoid the effort of using callbacks and/or promises with .then() for continuations.

createAttachmentFromCamera
Code Block
var request = { 
"type" : "createAttachment",
"data" : { 
		"ParentId" : "001234567891234",             // Required
		"Name" : "AttachmentName.jpg",              // Required
		"Body" : "AABBCCDDEEFF...", // Base64 data --   Required
		"ContentType" : "image/jpeg" // Optional -- manual entry of content type
	} 
};
bridge.sendRequest(request, function (responseData) {
	if (responseData.type == "createAttachmentResponse") {
	 	alert('Created Attachment Id: ' + responseData.data); 
	}
	else {
		// error code
	}
});
Panel
title

createAttachmentFromFilePath

false
Info
icon

The

createAttachmentFromCamera

createAttachmentFromFilePath method allows creation of Attachments directly from

the device's camera

valid, accessible, device file paths. The intended Attachment ParentId

is a required argument. Optionally

, FilePath are required arguments. The ContentType of the Attachment may be optionally specified in MIME type format, as in the example below. Optionally, you can specify a file name for the attachment, instead of using the name of the original file. On success, the response data contains the Id of the created attachment.

Note

Multiple create or delete requests MUST NOT run concurrently. If you need to create multiple attachments, it is recommend you using the createAttachmentFromFilePathBatch endpoint to avoid the effort of using callbacks and/or promises with .then() for continuations.

Code Block
var request = { 
"type" : "
createAttachmentFromCamera
createAttachmentFromFilePath",
"data" : { 
		"ParentId" : "001234567891234",            // Required
		"Name" : "AttachmentName.jpg",             // Optional
		"ContentType" : "image/jpeg",               // Optional -- manual entry of content type
		"FilePath" : "/Valid/Path/To/File.Jpg"     // Required
	} 
};
bridge.sendRequest(request, function (responseData) {
	if (responseData.type == "createAttachmentResponse") {
	 	alert('Created Attachment Id: ' + responseData.data); 
	}
	else {
		// error code
	}
});