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 2 Next »

Attachments
readAttachment

This API call returns the Attachment object with the Id specified with the full Base64 Body field populated.

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

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.

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

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.

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