Skip to content

MobileCRM.UI.MediaTab.getDataAsync

rescocrm edited this page May 15, 2023 · 9 revisions

[v8.0] Gets the media tab document in form of base64 string.

Arguments

Argument Type Description
viewName String The name of the media tab.

This example demonstrates how to retrieve data from existing media tab (in our case with name "DocumentAction"). In case of image data, resulting base64 can be set as source of the <img> element.

// WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
// It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
	return __awaiter(this, void 0, void 0, function* () {
		// get media tab by its name 
		var media = entityForm.getMediaTab("DocumentAction");
		var base64String = yield media.getData();
		MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
		var img = document.getElementById("imgTarget");
		if (img)
			// Construct data URL from base64 data and set it as a source to <img> element.
			img.src = "data:;base64," + base64String;
	});
});
Clone this wiki locally