Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Table of Contents

Attachments

...

...

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 });
title

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

queryAttachment

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:

Info
false
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 });
Note

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

Panel
title

createAttachment

false
Info
icon

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.

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

icon

The createAttachmentFromFilePath method allows creation of Attachments directly from valid, accessible, device file paths. The intended Attachment ParentId, FilePath are required arguments. The ContentType of the Attachment 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.

Info
false
Code Block
var request = { 
"type" : "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
	}
});
panel
title

createAttachmentFromCamera

false
Info
icon

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.

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
 
   }
});