-
Notifications
You must be signed in to change notification settings - Fork 26
MobileCRM.DynamicEntity.loadDocumentBody
rescocrm edited this page May 15, 2023
·
9 revisions
Asynchronously loads the document body for specified entity.
Function sends an asynchronous request to application, where the locally stored document body (e.g. the annotation.documentbody) is encoded to base64 and sent back to the Javascript callback. This function supports both online data and the data stored in local database/BLOB store.
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 demonstrates how to load the document body (e.g. attached image) for given annotation (Note). Following function loads locally stored attachment for note defined by its id and sets the base-64 data as image source.
function loadAccountDocumentBody(accountid) {
MobileCRM.DynamicEntity.loadDocumentBody("annotation", accountidid, function (base64str) {
/// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
MobileCRM.bridge.alert("Base64String: \n\n" + base64str);
var imgElement = document.getElementById("img-result");
if (imgElement)
imgElement.setAttribute("src", "data:image/jpeg;base64," + base64str); // set the "src" attribute for out <img> element
}, MobileCRM.bridge.alert, null);
}