Skip to content

MobileCRM.DynamicEntity.loadDocumentBody

maros316 edited this page Feb 17, 2020 · 9 revisions

Arguments

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);
}
Clone this wiki locally