MobileCRM.DynamicEntity.downloadAttachment - Resconet/JSBridge GitHub Wiki
[v9.1] Initiates the attachment download for specified entity.
Function sends an asynchronous request to application, which downloads the document body (e.g. the annotation) from server and sends it back to the Javascript callback.
Argument | Type | Description |
---|---|---|
entityName | String | The logical name of the entity, in most cases "annotation". |
id | String | GUID of the existing entity or null for new one. |
success | function(result) | A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data. |
failed | function(error) | A callback function for command failure. The error argument will carry the error message. |
scope | A scope for calling the callbacks; set "null" to call the callbacks in global scope. |
This example demonstrate how to download the note attachment image and set it into <img> element.
function downloadNoteAttachment(noteId) {
MobileCRM.DynamicEntity.downloadAttachment("annotation", noteId, function (base64str) {
/// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
var imgElement = document.getElementById("img-result");
if (imgElement)
imgElement.setAttribute("src", "data:;base64," + base64str); // set the "src" attribute for out <img> element
}, MobileCRM.bridge.alert, null);
}