Attachments
readAttachment
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('Javascript got its select response: ' + responseData); });
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.
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
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
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 } });