Skip to content

MobileCRM.DynamicEntity.saveDocumentBody

rescocrm edited this page May 15, 2023 · 8 revisions

[v10.0]Asynchronously saves 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 saved.

Arguments

Argument Type Description
entityId String GUID of the existing entity or "null" for new one.
entityName String The logical name of the entity; optional, default is "annotation".
relationship MobileCRM.Relationship The relationship with parent object.
filePath String Absolute or app data-relative path to the file holding the body.
mimeType String MimeType of the content, optional.
success function(MobileCRM.Reference) A callback function for successful asynchronous result. The result argument will carry the Reference to updated/created entity.
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 save the document body (e.g. attached image) for newly created annotation (Note). Following function locally stores the attachment (defined by file path) for newly created note.

function saveAnnotation(filePath, accountReference) {
	///<param name='filePath' type='String'>path to file for annotation attachment.</param>
	///<param name='accountReference' type='MobileCRM.Reference'>Reference to account.</param>
	var relationship = new MobileCRM.Relationship("objectid", accountReference);
	MobileCRM.DynamicEntity.saveDocumentBody(null, null, relationship, filePath, null, function (annotation) {
		///<param name='annotation' type='MobileCRM.Reference'>Reference to nelwy created annotation.</param>
		MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
	}, MobileCRM.bridge.alert, null);
}
Clone this wiki locally