Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Attachments
readAttachment

This API call returns the Attachment object with the Id specified.

Important returned fields:

  • Body – base64 encoded attachment data (if ReturnBase64Data is not false)
  • ThumbBody – base64 encoded attachment thumbnail data (if ReturnBase64Data is not false and attachment is an image)
  • FilePath – path (or URL) to the attachment file
  • ThumbPath – path (or URL) to the attachment thumbnail file (for image attachments)

Related Pulsar Settings:

var request = { 
"type" : "readAttachment",
"data" : {
        "Id" : "001234567891234",    // Required attachment Id
        "ReturnBase64Data" : false   // Optional, default true.  If false you will have access to path of attachment to get the data
    }
};
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

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.

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

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, 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.

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

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.

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
	}
});
  • No labels