Attachments
readAttachment
Normal data reads 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.
var request = { "type" : "readAttachment", "data" : { "Id" : "001234567891234" } // this will return full attachment data for the object with this Id }; bridge.sendRequest(request, function (responseData) { alert('Javascript got its select response: ' + responseData); });
createAttachment
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 } });
createAttachmentFromFilePath
NOTE- This method is currently only supported on Android and Windows platforms
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 } });
createAttachmentFromCamera
NOTE- This method is currently only supported on Android and Windows platforms
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 } });