Useful Links

API Changes
Empty Offline HTML page
Empty Offline HTML Visual Studio solution
Official JSBridge GitHub Page

MobileCRM Namespace

The MobileCRM namespace encapsulates all the functionality of the Resco MobileCRM Javascript Bridge (later JSBridge).

Namespaces

NamespaceDescription
FetchXmlContains a set of objects implementing the FetchXML request methods
UIContains a set of objects implementing the Javascript equivalent of the MobileCRM application UI components.
UI.DetailViewItemsContains a set of objects representing particular detail view items.
ServicesContains non-UI classes for accessing documents...
Services.WorkflowContains objects accessing the Dynamics 365 workflow.

Properties

PropertyDescription
bridgeSingleton instance of MobileCRM.Bridge providing the management of the Javascript / native code cross-calls.

Objects

ObjectDescription
AboutInfo[v8.2] Represents the branding information.
ApplicationEncapsulates the application-related functionality.
BridgeProvides the management of the Javascript/native code cross-calls. Its only instance MobileCRM.bridge is created immediately after the "JSBridge.js" script is loaded.
ConfigurationProvides an access to the application configuration.
CultureInfo[v10.2] Provides information about current device culture. The information includes the names for the culture, the writing system, the calendar used, and formatting for dates.
DateTimeFormat[v10.2] Provides culture-specific information about the format of date and time values.
DynamicEntityRepresents a CRM entity, with only a subset of properties loaded.
LocalizationA static object with functions allowing to access the localized texts.
ManyToManyReferenceA static object with functions managing many to many relations.
MetaEntityRepresents an entity metadata.
MetaPropertyRepresents a property (CRM field) metadata.
MetadataA static object with functions for accessing the entity metadata store.
MobileReportProvides a functionality of mobile reporting.
NumberFormat[v10.2] Provides culture-specific information for formatting and parsing numeric values.
ObservableObjectRepresents a generic object which is monitoring the changes of its properties.
PlatformRepresents object for querying platform specific information and executing platform integrated actions.
QuestionnaireProvides a functionality for questionnaires.
ReferenceRepresents an entity reference which provides the minimum information about an entity.
RelationshipRepresents a relationship between two entities.
_DeviceInfoRepresents the device information.
_SettingsInternal object representing the application settings.

MobileCRM.AboutInfo Object

[v8.2] Represents the branding information.

Properties

PropertyTypeDescription
manufacturerStringGets the manufacturer text.
productTitleStringGets the product title text.
productTitleAndVersionString[v9.0] Gets the string with product title and version.
productSubTitleStringGets the product subtitle text.
poweredByStringGets the powered by text.
iconStringGets the icon name.
websiteStringGets the website url.
supportEmailStringGets the support email.

Functions

FunctionDescription
requestObject[v8.2] Asynchronously gets the AboutInfo object with branding information.

MobileCRM.AboutInfo.requestObject Function

[v8.2] Asynchronously gets the AboutInfo object with branding information.

Arguments

ArgumentTypeDescription
callbackfunction(Object)The callback function that is called asynchronously with the about info object.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.

Example 1

This example demonstrates how to get application about info.

  1. // Request About info object
  2. MobileCRM.AboutInfo.requestObject(
  3. function (aboutInfo) {
  4. /// <param name="aboutInfo" type="MobileCRM.AboutInfo"/>
  5. var appReport = "About Info : \n";
  6. for (var prop in aboutInfo)
  7. appReport += prop + ": " + aboutInfo[prop] + "\n";
  8.  
  9. MobileCRM.bridge.alert(appReport);
  10. },
  11. MobileCRM.bridge.alert // alerts an error
  12. );

MobileCRM.Application Object

Encapsulates the application-related functionality.

Functions

FunctionDescription
checkUserRolesChecks whether the current user is member of the passed roles. Role can be either the Guid (aeb33d0f-89b4-e111-9c9a-00155d0b710a) or the role Name.
createDirectoryAsynchronously creates the directory in the application local data.
deleteDirectoryAsynchronously deletes the empty directory from the application local data.
deleteFileAsynchronously deletes the file from the application local data.
directoryExistsChecks whether the directory with given path exists in the application local data.
fileExistsChecks whether the file with given path exists in application local data.
getAppColorGets the customized color by its name.
getAppImageGets the colorized application image. It is taken either from customization package or from application bundle.
getDirectoriesAsynchronously gets the list of directories from the application local data.
getFilesAsynchronously gets the list of files from the application local data.
moveFileAsynchronously moves the application local file to another location.
readFileReads the file from the application local data and asynchronously gets its content.
readFileAsBase64Reads the file from the application local data and asynchronously gets its base64-encoded content.
setAppColors[v11.2] Sets the application colors.
showAppLoginCauses that the password is forgotten and user is required to type it again to make the app running.
synchronizeStarts background/foreground sync if not synchronized or the last sync was before desired limit.
synchronizeOnForeground[v8.1] Starts the synchronization on foreground (closes all form if possible and showing the standard progress).
writeFileAsynchronously writes the text into the file from the application local data.
writeFileFromBase64Asynchronously writes the base64-encoded data into the application local storage file.
writeFileWithEncoding[v9.0.2] Asynchronously writes the text into the file from the application local data.

MobileCRM.Application.checkUserRoles Function

Checks whether the current user is member of the passed roles. Role can be either the Guid (aeb33d0f-89b4-e111-9c9a-00155d0b710a) or the role Name.

Arguments

ArgumentTypeDescription
rolesArray(String)Defines the roles to check.
successfunction(result)A callback function for successful asynchronous result. The result will carry a number with the count of matching roles.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.createDirectory Function

Asynchronously creates the directory in the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the directory in the application local data.
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to create a folder in the application storage.

  1. MobileCRM.Application.createDirectory("TestData/MyFolder", function () {
  2. MobileCRM.bridge.alert("Folder was created");
  3. }, function () {
  4. MobileCRM.bridge.alert("Folder wasn't created");
  5. });

MobileCRM.Application.deleteDirectory Function

Asynchronously deletes the empty directory from the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the directory in the application local data.
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to delete an application storage folder.

  1. MobileCRM.Application.deleteDirectory("TestData/MyFolder", function (res) {
  2. MobileCRM.bridge.alert("Folder was deleted");
  3. }, function () {
  4. MobileCRM.bridge.alert("Folder wasn't deleted");
  5. });

MobileCRM.Application.deleteFile Function

Asynchronously deletes the file from the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to delete an application storage file.

  1. MobileCRM.Application.deleteFile("TestData/MyFile.txt", function (res) {
  2. MobileCRM.bridge.alert("File was deleted");
  3. }, function () {
  4. MobileCRM.bridge.alert("File wasn't deleted");
  5. });

MobileCRM.Application.directoryExists Function

Checks whether the directory with given path exists in the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the directory located in the application local data.
successfunction(result)A callback function for successful asynchronous result. The result will carry a Boolean object determining whether the directory exists or not.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

  1. MobileCRM.Application.directoryExists("TestData/MyFolder", function (exists) {
  2. MobileCRM.bridge.alert(exists ? "Exists" : "Doesn't exist");
  3. }, MobileCRM.bridge.alert)

MobileCRM.Application.fileExists Function

Checks whether the file with given path exists in application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file located in the application local data.
successfunction(result)A callback function for successful asynchronous result. The result will carry a Boolean object determining whether the file exists or not.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

  1. MobileCRM.Application.fileExists("TestData/MyFile.txt", function (exists) {
  2. MobileCRM.bridge.alert(exists ? "Exists" : "Doesn't exist");
  3. }, MobileCRM.bridge.alert)

MobileCRM.Application.getAppColor Function

Gets the customized color by its name.

Arguments

ArgumentTypeDescription
colNameStringDefines the color name. Must be one of these: TitleBackground, TitleForeground, ListBackground, ListForeground, ListSelBackground, ListSelForeground, ListSeparator, SearchBackground, SearchForeground, SearchSelForeground, FormBackground, FormItemBackground, FormItemForeground, FormItemLabelForeground, FormItemDisabled, FormItemLink, TabBackground, TabForeground, TabSelForeground.
successfunction(result)A callback function for successful asynchronous result. The result will carry a String object with color in CSS format (e.g. "#FF0000" for red color).
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to change the DOM element color to specific color from application theme defined in Woodford.

  1. MobileCRM.Application.getAppColor("ListForeground", function (color) {
  2. /// <param name="color" type="String">String containing the color definition (e.g. "#FF0000" for red color).</param>
  3. if (color) {
  4. MobileCRM.bridge.alert("ListForeground color = " + color);
  5. var element = document.getElementById("mainTable");
  6. if (element)
  7. element.style.color = color;
  8. }
  9. });

MobileCRM.Application.getAppImage Function

Gets the colorized application image. It is taken either from customization package or from application bundle.

Arguments

ArgumentTypeDescription
imageNameStringDefines the image name (e.g. "Buttons.Call.png").
colorizeStringIf the image supports colorization, this value defines the colorization color. It can be either integer with RGB value or the application color name as defined in MobileCRM.Application.getAppColor. Leave null if no colorization is desired.
successfunction(result)A callback function for successful asynchronous result. The result will carry a String object with "data:" URL containing base64-encoded colorized application image.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.getDirectories Function

Asynchronously gets the list of directories from the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the Directory in the application local data.
successfunction(result)A callback function which carry the array of directories names.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.getFiles Function

Asynchronously gets the list of files from the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the Directory in the application local data.
successfunction(result)A callback function which carry the array of files names in the directory.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.moveFile Function

Asynchronously moves the application local file to another location.

Arguments

ArgumentTypeDescription
srcStringDefines the relative path of the source file in the application local data.
dstStringDefines the relative path of the destination file in the application local data.
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.readFile Function

Reads the file from the application local data and asynchronously gets its content.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
successfunction(result)A callback function for successful asynchronous result. The result will carry a String object with the file content.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.readFileAsBase64 Function

Reads the file from the application local data and asynchronously gets its base64-encoded content.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
successfunction(result)A callback function for successful asynchronous result. The result will carry a string with the base64-encoded file content.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to load the image from application storage if exists and show it in <img> element.

  1. var imagePath = "Images/MobileCrm/Images.MonoTouch/Logo/Logo@2x.png";
  2. MobileCRM.Application.fileExists(imagePath, function (exists) {
  3. if (exists) {
  4. MobileCRM.Application.readFileAsBase64(imagePath, function (data) {
  5. var imgElement = document.getElementById("test-image");
  6. if (imgElement)
  7. imgElement.src = "data:image/jpeg;base64," + data;
  8. }, MobileCRM.bridge.alert);
  9. }
  10. else
  11. MobileCRM.bridge.alert("File '"+ imagePath +"' doesnt'exist");
  12. });

MobileCRM.Application.setAppColors Function

[v11.2] Sets the application colors.

Arguments

ArgumentTypeDescription
colorsobjectProperties of the object define the colors to set. The values must be int in the AARRGGBB format.
successfunction(result)A callback function for successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.showAppLogin Function

Causes that the password is forgotten and user is required to type it again to make the app running.


MobileCRM.Application.synchronize Function

Starts background/foreground sync if not synchronized or the last sync was before desired limit.

Arguments

ArgumentTypeDescription
backgroundOnlyBooleanif true, only the background sync is allowed; otherwise it can also run the foreground sync.
ifNotSyncedBeforeDateDefines a time limit required for the last sync. Starts the sync only if wasn"t done yet or if it was before this limit. If it is null or undefined, sync is done always.

Example 1

This example demonstrates how to initiate the application synchronization.

  1. // Following line initiates immediate foreground synchronization.
  2. // If required "Sync login" is active, it causes all forms being closed and "Sync Login" form is being shown.
  3. MobileCRM.Application.synchronize(false);
  4.  
  5. // Following line initiates the background synchronization, if the last synchronization was performed before given Date.
  6. // It requires "Save password" being active and "Sync login" inactive
  7. MobileCRM.Application.synchronize(true, new Date("Dec 25, 2017"));

MobileCRM.Application.synchronizeOnForeground Function

[v8.1] Starts the synchronization on foreground (closes all form if possible and showing the standard progress).

Foreground sync must be done to download the new customization or to display the sync conflicts.

Arguments

ArgumentTypeDescription
forceLoginBooleanif true, the sync dialog with URL and credentials will be opened; otherwise it is opened only if the password is not saved.

MobileCRM.Application.writeFile Function

Asynchronously writes the text into the file from the application local data.

File content is encoded using UTF-8 encoding.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
textStringDefines the file content to be written.
appendBooleanDetermines whether to overwrite or append to an existing file..
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Application.writeFileFromBase64 Function

Asynchronously writes the base64-encoded data into the application local storage file.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
base64StringA string containing the base64-encoded file content.
successfunction()A callback function which is called in case of success.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to store the image data into application storage root and show it in <img> element using relative URL.

  1. function saveAndShowImage(base64ImageData) {
  2. /// <param name="base64ImageData" type="String">String containing base64-encoded image data.</param>
  3. MobileCRM.Application.writeFileFromBase64("ExternalImage.jpg", base64ImageData, function () {
  4. var imgElement = document.getElementById("test-image");
  5. imgElement.src = "../ExternalImage.jpg"; // Offline HTML is opened from the WWW folder and image was stored into the root folder
  6. }, MobileCRM.bridge.alert);
  7. }

MobileCRM.Application.writeFileWithEncoding Function

[v9.0.2] Asynchronously writes the text into the file from the application local data.

Arguments

ArgumentTypeDescription
pathStringDefines the relative path of the file in the application local data.
textStringDefines the file content to be written.
encodingStringDefines the text encoding for file content (default is UTF-8). Use "ASCII" for ANSI text or "UTF-16" for multi-byte Unicode.
appendBooleanDetermines whether to overwrite or append to an existing file.
successfunction(result)A callback function which is called in case of successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Bridge Object

Provides the management of the Javascript/native code cross-calls. Its only instance MobileCRM.bridge is created immediately after the "JSBridge.js" script is loaded.

Properties

PropertyTypeDescription
platformStringA string identifying the device platform (e.g. Android, iOS, Windows, WindowsRT, Windows10 or WindowsPhone).
versionNumberA number identifying the version of the JSBridge. This is the version of the script which might not match the version of the application part of the bridge implementation. Application version must be equal or higher than the script version.

Methods

MethodDescription
alertShows a message asynchronously and calls the callback after it is closed by user.
closeFormCloses a form containing this HTML document.
enableDebugEnables platform-specific features for debugging the web page.
enableZoomEnables platform-specific pinch zoom gesture.
getWindowSize[v8.0] Returns the size of the window in logical pixels without any scaling and viewport calculations..
invokeMethodPromiseInvokes a method on exposed managed object asynchronously as a Promise.
invokeStaticMethodPromiseInvokes a static method on specified type asynchronously as a Promise.
log[v8.0] Appends a message into the JSBridge log.
onGlobalEvent[v9.0] Binds or unbinds the handler for global event.
raiseGlobalEvent[v9.0] Raises the global event which can have listeners bound by other iFrames.

MobileCRM.Bridge.alert Method

Shows a message asynchronously and calls the callback after it is closed by user.

Arguments

ArgumentTypeDescription
callbackfunction(obj)The callback function that is called asynchronously.
scopeObjectThe scope for callbacks.

MobileCRM.Bridge.closeForm Method

Closes a form containing this HTML document.

Example 1

This example demonstrates how to close current form from Javascript.

  1. MobileCRM.bridge.closeForm();

MobileCRM.Bridge.enableDebug Method

Enables platform-specific features for debugging the web page.

After calling this method, it is possible to attach the Google Chrome debugger into the web page opened in MobileCRM application running on Android (KitKat or newer).

This method also activates the Javascript warnings in Windows 7 app.

It has dummy implementation on iOS and Android debug build.

Arguments

ArgumentTypeDescription
callbackfunction(obj)The callback function that is called asynchronously.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to switch the Android WebView into debugging mode which enables remote connection from Google Chrome device inspector.

  1. MobileCRM.bridge.enableDebug();

MobileCRM.Bridge.enableZoom Method

Enables platform-specific pinch zoom gesture.

After calling this method, it is possible to use the pinch gesture to control the content zoom. This functionality is implemented only on Android. Other platforms either do not support zoom or it is controlled by the HTML viewport meta tag.

Arguments

ArgumentTypeDescription
enableBooleanIndicates whether to enable or disable zooming support.

Example 1

This example demonstrates how to enable zooming on Android iFrame. Method "enableZoom" has dummy implementation on other platforms.

  1. MobileCRM.bridge.enableZoom(true);

MobileCRM.Bridge.getWindowSize Method

[v8.0] Returns the size of the window in logical pixels without any scaling and viewport calculations..

Arguments

ArgumentTypeDescription
callbackfunction(obj)The callback function that is called asynchronously. Gets an object with the window "width" and "height".
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get the window "width" and "height".

  1. MobileCRM.bridge.getWindowSize(
  2. function (obj) {
  3. MobileCRM.bridge.alert("window size : " + obj.width + " x " + obj.height);
  4. },
  5. MobileCRM.bridge.alert
  6. );

MobileCRM.Bridge.invokeCommandPromise Method


MobileCRM.Bridge.invokeMethodPromise Method

Invokes a method on exposed managed object asynchronously as a Promise.

Arguments

ArgumentTypeDescription
objectNameStringThe name of exposed managed object as it was registered on C# side (IJavascriptBridge.ExposeObject).
methodStringThe name of the method implemented by object class.
paramsListArrayAn array with parameters that should be passed to a method.

Return value

Type: Promise<any>

A Promise object which will be resolved with JSON-serialized return value. It is either generic type or MobileCRM.ObservableObject with JSON-serialized return value..


MobileCRM.Bridge.invokeStaticMethodPromise Method

Invokes a static method on specified type asynchronously as a Promise.

Arguments

ArgumentTypeDescription
assemblyStringThe name of the assembly which defines the type.
typeNameStringThe full name of the C# type which implements the method.
methodStringThe name of static method to be invoked.
paramsListArrayAn array with parameters that should be passed to a method.

Return value

Type: Promise<any>

A Promise object which will be resolved with JSON-serialized return value. It is either generic type or MobileCRM.ObservableObject with JSON-serialized return value..


MobileCRM.Bridge.log Method

[v8.0] Appends a message into the JSBridge log.

Arguments

ArgumentTypeDescription
textStringA text to be written into the log.

Example 1

This example demonstrates how to append a text to the JSBridge log which is included in About/SendLog reporting.

  1. /// This method can be used to add specific information into the JSBridge log.
  2. MobileCRM.bridge.log("This will be added to end of JSBridge log.");

MobileCRM.Bridge.onGlobalEvent Method

[v9.0] Binds or unbinds the handler for global event.

This methods binds or unbinds a handler which is called when this or other iFrame raises the specified event by calling the MobileCRM.bridge.raiseGlobalEvent method.

It can also bind a handler for pre-defined events EntityFormClosed, IFrameFormClosed, SyncStarted and SyncFinished.

Arguments

ArgumentTypeDescription
eventNameStringGlobal event name.
handlerfunction(args)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to register custom global event. Other iFrame can raise the event and provide the parameters. See raiseGlobalEvent for example of raising such an event.

  1. MobileCRM.bridge.onGlobalEvent("MyCustomEvent", function (args) {
  2. MobileCRM.bridge.alert("Retreived arguments from raised event 'MyCustomEvent' " + JSON.stringify(args));
  3. }, true);

Example 2

This example demonstrates how to use global event listener to handle the EntityFormClosed event for refreshing the product list on Order form after editing one of its product details.

  1. MobileCRM.bridge.onGlobalEvent("EntityFormClosed", function (closedEntityForm) {
  2. /// <param name='closedEntityForm' type='MobileCRM.UI.EntityForm'>An EntityForm object representing the form that was closed.</param>
  3. if (closedEntityForm.entity.entityName == "salesorderdetail")
  4. onProductChanged(closedEntityForm.entity.id);
  5. }, true);

MobileCRM.Bridge.raiseGlobalEvent Method

[v9.0] Raises the global event which can have listeners bound by other iFrames.

Arguments

ArgumentTypeDescription
eventNameStringGlobal event name.
argsObjectAny object that has to be passed to all event listeners. This object is stringified JSON and passed to another iFrame listening on the global event.

Example 1

This example demonstrates how to raise a custom global event. Other iFrame can register the callback which will be then called with specified parameters. See onGlobalEvent for example of registering such an event.

  1. MobileCRM.bridge.raiseGlobalEvent("MyCustomEvent", {
  2. testTitle: "My Title",
  3. testData: { aaa: 1, bbb: 2 },
  4. testDirectVal: 666
  5. });

MobileCRM.Configuration Object

Provides an access to the application configuration.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.Configuration.requestObject function.

Properties

PropertyTypeDescription
applicationEditionStringGets the application edition.
applicationPathStringGets the application folder.
applicationVersionStringGets the application version (major.minor.subversion.build).
customizationDirectoryStringGets or sets the runtime customization config root.
externalConfigurationStringGets the external configuration directory (either customization or legacy configuration).
isBackgroundSyncBooleanGets or sets whether background synchronization is in progress.
isOnlineBooleanGets or sets whether the online mode is currently active.
legacyVersionStringGets or sets the legacy redirect folder.
licenseAlertStringGets the flag set during sync indicating that the user's license has expired.
settingsMobileCRM._SettingsGets the application settings.
storageDirectoryStringGets the root folder of the application storage.

Functions

FunctionDescription
requestObjectRequests the managed Configuration object.

MobileCRM.Configuration.requestObject Function

Requests the managed Configuration object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of Configuration object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(config)The callback function that is called asynchronously with MobileCRM.Configuration object instance as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to obtain and modify MobileCRM.Configuration object. It checks if user is working in Online mode and calls a function with user's credentials obtained from MobileCRM._Settings object.

  1. MobileCRM.Configuration.requestObject(
  2. function (config) {
  3. /// <param name="config" type="MobileCRM.Configuration">/<param>
  4. if (config.isOnline) {
  5. var settings = config.settings;
  6. queryXYStatistics(settings.userName, settings.password, settings.domain);
  7. }
  8. // we have done no changes, thus return false to disallow sending the changes back to C#.
  9. return false;
  10. },
  11. function (err) {
  12. /// <param name="err" type="String">/<param>
  13. MobileCRM.bridge.alert("An error occurred: " + err);
  14. },
  15. null
  16. );
  17. function queryXYStatistics(userName, password, domain) {
  18. // Use CRM credentials let's say for an AJAX call to a WebService...
  19. }

MobileCRM.CultureInfo Object

[v10.2] Provides information about current device culture. The information includes the names for the culture, the writing system, the calendar used, and formatting for dates.

Properties

PropertyTypeDescription
nameStringGets the culture name in the format languageCode/region (e.g. "en-US"). languageCode is a lowercase two-letter code derived from ISO 639-1. regioncode is derived from ISO 3166 and usually consists of two uppercase letters.
displayNameStringGets the full localized culture name.
nativeNameStringGets the culture name, consisting of the language, the country/region, and the optional script, that the culture is set to display.
ISONameStringGets the ISO 639-1 two-letter code for the language of the current CultureInfo.
isRightToLeftBooleanGets a value indicating whether the current CultureInfo object represents a writing system where text flows from right to left.
dateTimeFormatMobileCRM.DateTimeFormatGets a DateTimeFormat that defines the culturally appropriate format of displaying dates and times.
numberFormatMobileCRM.NumberFormatGets a NumberFormat that defines the culturally appropriate format of displaying numbers, currency, and percentage.

Functions

FunctionDescription
formatDate[v10.2] Returns the formatted date/time string that matches current device culture.
fullDateTimeString[v10.2] Returns the date and time string that matches current device culture.
initialize[v10.2] Initializes the CultureInfo object.
initializeAsync[v10.2] Initializes the CultureInfo object.
load[v10.2] Asynchronously gets the CultureInfo object for specified language/country.
loadAsync[v10.2] Asynchronously gets the CultureInfo object for specified language/country.
longDateString[v10.2] Returns the long date string that matches current device culture.
longTimeString[v10.2] Returns the long time string that matches current device culture.
monthDayString[v10.2] Returns the month and day string that matches current device culture.
shortDateString[v10.2] Returns the short date string that matches current device culture.
shortTimeString[v10.2] Returns the short time string that matches current device culture.
yearMonthString[v10.2] Returns the year and month string that matches current device culture.

MobileCRM.CultureInfo.formatDate Function

[v10.2] Returns the formatted date/time string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.
formatStringCustom format string that meets the MSDN Sepcification.

Example 1

This example demonstrates how to format current date to a string having pre-defined or custom format.

  1. MobileCRM.CultureInfo.initialize(function (currentCulture) {
  2. ///<param name='currentCulture' type='MobileCRM.CultureInfo' />
  3. var formatDate = new Date();
  4.  
  5. var monthDayPattern = "MM-MMMM, ddd-dddd";
  6. var customDate = MobileCRM.CultureInfo.formatDate(formatDate, monthDayPattern);
  7.  
  8. var fullDateTime = MobileCRM.CultureInfo.fullDateTimeString(formatDate);
  9. var longDate = MobileCRM.CultureInfo.longDateString(formatDate);
  10. var longTime = MobileCRM.CultureInfo.longTimeString(formatDate);
  11. var shortDate = MobileCRM.CultureInfo.shortDateString(formatDate);
  12. var shortTime = MobileCRM.CultureInfo.shortTimeString(formatDate);
  13. var mothDay = MobileCRM.CultureInfo.monthDayString(formatDate);
  14. var yearMonth = MobileCRM.CultureInfo.yearMonthString(formatDate);
  15.  
  16. var result =
  17. monthDayPattern + ": " + customDate + "\n" +
  18. "full date time : " + fullDateTime + "\n" +
  19. "long date : " + longDate + "\n" +
  20. "short date : " + shortDate + "\n" +
  21. "long time : " + longTime + "\n" +
  22. "short time : " + shortTime + "\n" +
  23. "day of month : " + mothDay + "\n" +
  24. "year of month : " + yearMonth + "\n";
  25.  
  26. MobileCRM.bridge.alert(result);
  27. }, MobileCRM.bridge.alert, null);

MobileCRM.CultureInfo.fullDateTimeString Function

[v10.2] Returns the date and time string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.initialize Function

[v10.2] Initializes the CultureInfo object.

Method loads the current culture information asynchronously and calls either the errorCallback with error message or the callback with initialized CultureInfo object.

All other functions will return the default or empty string before the initialization finishes.

Arguments

ArgumentTypeDescription
callbackfunction(currentCulture)The callback function that is called asynchronously with initialized CultureInfo object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is to be called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to initialize CultureInfo object providing information about current culture.

  1. MobileCRM.CultureInfo.initialize(function (currentCulture) {
  2. ///<param name='currentCulture' type='MobileCRM.CultureInfo' />
  3. var cultureInfo =
  4. "Display name: " + currentCulture.displayName + "\n" +
  5. "ISO name: " + currentCulture.ISOName + "\n" +
  6. "Native name: " + currentCulture.nativeName + "\n\n" +
  7. "Number format: " + JSON.stringify(currentCulture.numberFormat) + "\n\n" +
  8. "DateTime format: " + JSON.stringify(currentCulture.dateTimeFormat) + "\n" +
  9. "Right to left: " + currentCulture.isRightToLeft + "\n";
  10.  
  11. // for further details about date, time and number format,
  12. // see MobileCRM.DateTimeFormat and MobileCRM.NumberFormat
  13.  
  14. MobileCRM.bridge.alert(cultureInfo);
  15. }, MobileCRM.bridge.alert, null);

MobileCRM.CultureInfo.initializeAsync Function

[v10.2] Initializes the CultureInfo object.

Method loads the current culture information asynchronously.

All other functions will return the default or empty string before the initialization promise is resolved.

Return value

Type: Promise<MobileCRM.CultureInfo>

A Promise object which will be resolved with the loaded CultureInfo object.


MobileCRM.CultureInfo.load Function

[v10.2] Asynchronously gets the CultureInfo object for specified language/country.

Arguments

ArgumentTypeDescription
cultureStringThe name of culture that has to be loaded. The culture name is in the format language code-country where language code is a lowercase two-letter code derived from ISO 639-1. country is derived from ISO 3166 and usually consists of two uppercase letters
callbackfunction(cultureInfo)The callback function that is called asynchronously with initialized CultureInfo object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is to be called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get specific culture information.

  1. MobileCRM.CultureInfo.load("en-GB", function (info) {
  2. ///<param name='info' type='MobileCRM.CultureInfo' />
  3. var cultureInfo =
  4. "Display name: " + info.displayName + "\n" +
  5. "ISO name: " + info.ISOName + "\n" +
  6. "Native name: " + info.nativeName + "\n\n" +
  7. "Number format: " + JSON.stringify(info.numberFormat) + "\n\n" +
  8. "DateTime format: " + JSON.stringify(info.dateTimeFormat) + "\n" +
  9. "Right to left: " + info.isRightToLeft + "\n";
  10.  
  11. // for further details about date, time and number format,
  12. // see MobileCRM.DateTimeFormat and MobileCRM.NumberFormat
  13.  
  14. MobileCRM.bridge.alert(cultureInfo);
  15. }, MobileCRM.bridge.alert, null);

MobileCRM.CultureInfo.loadAsync Function

[v10.2] Asynchronously gets the CultureInfo object for specified language/country.

Arguments

ArgumentTypeDescription
cultureStringThe name of culture that has to be loaded. The culture name is in the format language code-country where language code is a lowercase two-letter code derived from ISO 639-1. country is derived from ISO 3166 and usually consists of two uppercase letters

Return value

Type: Promise<MobileCRM.CultureInfo>

A Promise object which will be resolved with the loaded CultureInfo object.


MobileCRM.CultureInfo.longDateString Function

[v10.2] Returns the long date string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.longTimeString Function

[v10.2] Returns the long time string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.monthDayString Function

[v10.2] Returns the month and day string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.shortDateString Function

[v10.2] Returns the short date string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.shortTimeString Function

[v10.2] Returns the short time string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.CultureInfo.yearMonthString Function

[v10.2] Returns the year and month string that matches current device culture.

This method fails if CultureInfo.initialize method hasn't completed yet.

Arguments

ArgumentTypeDescription
dateDateA date being formatted.

MobileCRM.DateTimeFormat Object

[v10.2] Provides culture-specific information about the format of date and time values.

Properties

PropertyTypeDescription
abbreviatedDayNamesString[]Gets a string array containing the culture-specific abbreviated names of the days of the week.
abbreviatedMonthGenitiveNamesString[]Gets a string array of abbreviated month names associated with the current DateTimeFormat object.
abbreviatedMonthNamesString[]Gets a string array that contains the culture-specific abbreviated names of the months.
aMDesignatorStringGets the string designator for hours that are "ante meridiem" (before noon).
dayNamesString[]Gets a string array that contains the culture-specific full names of the days of the week.
firstDayOfWeekNumberGets the first day of the week (0=Sunday, 1=Monday, ...)
fullDateTimePatternStringGets the custom format string for a long date and long time value.
longDatePatternStringGets the custom format string for a long date value.
longTimePatternStringGets the custom format string for a long time value.
monthDayPatternStringGets the custom format string for a month and day value.
monthGenitiveNamesString[]Gets a string array of month names associated with the current DateTimeFormat object.
monthNamesString[]Gets a string array containing the culture-specific full names of the months.
pMDesignatorStringGets the string designator for hours that are "post meridiem" (after noon).
shortDatePatternStringGets the custom format string for a short date value.
shortestDayNamesString[]Gets a string array of the shortest unique abbreviated day names associated with the current DateTimeFormat object.
shortTimePatternStringGets the custom format string for a short time value.
sortableDateTimePatternStringGets the custom format string for a sortable date and time value.
universalSortableDateTimePatternStringGets the custom format string for a universal, sortable date and time string.
yearMonthPatternStringGets the custom format string for a year and month value.

MobileCRM.DynamicEntity Object

Represents a CRM entity, with only a subset of properties loaded.

This class is derived from MobileCRM.Reference

There is a compatibility issue since the version 7.4 which gets the boolean and numeric properties as native Javascript objects (instead of strings). If you experienced problems with these types of fields, switch on the legacy serialization by setting the static property MobileCRM.DynamicEntity.legacyPropsSerialization to true.

Properties

PropertyTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.
isNewBooleanIndicates whether the entity is newly created.
isOnlineBooleanIndicates whether the entity was created by online request or from local data.
forceDirtyBooleanIndicates whether to force save the provided properties even if not modified. Default behavior is to save only properties that were modified.
primaryNameStringThe human readable name of the entity, e.g. "Alexandro".
propertiesObjectAn object with entity properties, e.g. {firstname:"Alexandro", lastname:"Puccini"}.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.DynamicEntity object.
savePerforms the asynchronous CRM create/modify entity command.
saveAsyncPerforms the asynchronous CRM create/modify entity command.

Functions

FunctionDescription
createNewCreates the MobileCRM.DynamicEntity object representing new entity.
deleteAsyncAsynchronously deletes the CRM entity.
deleteByIdAsynchronously deletes the CRM entity.
downloadAttachment[v9.1] Initiates the attachment download for specified entity.
downloadAttachmentAsync[v9.1] Initiates the attachment download for specified entity.
loadAsyncAsynchronously loads the CRM entity properties.
loadByIdAsynchronously loads the CRM entity properties.
loadDocumentBodyAsynchronously loads the document body for specified entity.
loadDocumentBodyAsyncAsynchronously loads the document body for specified entity.
saveDocumentBody[v10.0]Asynchronously saves the document body for specified entity.
saveDocumentBodyAsync[v10.0]Asynchronously saves the document body for specified entity.
unzipDocumentBody[v9.1] Asynchronously unpacks the document body (assumes it's a zip file) for specified entity.

MobileCRM.DynamicEntity.constructor Method

Constructs an instance of MobileCRM.DynamicEntity object.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.
primaryNameStringThe human readable name of the entity, e.g "Alexandro".
propertiesObjectAn object with entity properties, e.g. {firstname:"Alexandro", lastname:"Puccini"}.
isOnlineBooleanIndicates whether the entity was created by online request or from local data.

MobileCRM.DynamicEntity.save Method

Performs the asynchronous CRM create/modify entity command.

Arguments

ArgumentTypeDescription
callbackfunction(err)A callback function for asynchronous result. The err argument will carry the error message or null in case of success. The callback is called in scope of DynamicEntity object which is being saved.
forceModeBoolean[v10.0.2] Optional parameter which forces online/offline mode for saving. Set "true" to save entity online; "false" to save it offline. Any other value (including "undefined") causes entity tobe saved in currently selected application offline/online mode.

Example 1

This example demonstrates how to create a new account.

  1. var account = MobileCRM.DynamicEntity.createNew("account");
  2. var props = account.properties;
  3. props.name = "A Bike Store";
  4. props.address1_line1 = "Unknown";
  5. // ...
  6. account.save(
  7. function (error) {
  8. if (error)
  9. MobileCRM.bridge.alert("An error occurred: " + error);
  10. else {
  11. // callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
  12. var newId = this.id;
  13. var allProps = this.properties;
  14. rememberNewAccount(newId, allProps.name);
  15. }
  16. }
  17. );

Example 2

This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.

  1. function updateGPS(accountid, latitude, longitude) {
  2. var account = new MobileCRM.DynamicEntity("account", accountid);
  3. var props = account.properties;
  4. props.address1_latitude = latitude;
  5. props.address1_longitude = longitude;
  6. account.save(
  7. function (error) {
  8. if (error)
  9. MobileCRM.bridge.alert("An error occurred: " + error);
  10. else {
  11. // callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
  12. logModification(this.id, this.primaryName);
  13. }
  14. }
  15. );
  16. }

MobileCRM.DynamicEntity.saveAsync Method

Performs the asynchronous CRM create/modify entity command.

Arguments

ArgumentTypeDescription
forceModeBooleanOptional parameter which forces online/offline mode for saving. Set "true" to save entity online; "false" to save it offline. Any other value (including "undefined") causes entity to be saved in currently selected application offline/online mode.

Return value

Type: Promise<DynamicEntity>

A Promise object which will be resolved with saved DynamicEntity object as result.

Example 1

This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.

  1. function updateGPS(accountid, latitude, longitude) {
  2. // Instead of loading whole entity object, we'll create the DynamicEntity object
  3. // for Account entity with existing ID and provide just changed fields.
  4. var account = new MobileCRM.DynamicEntity("account", accountid);
  5. var props = account.properties;
  6. props.address1_latitude = latitude;
  7. props.address1_longitude = longitude;
  8. account.saveAsync()
  9. .then(function (savedEntity) {
  10. // Promise was fulfilled and we obtained full MobileCRM.DynamicEntity object with all its fields (including primary name)
  11. logModification(savedEntity.id, savedEntity.primaryName);
  12. })
  13. .catch(function (error) {
  14. // Promise was rejected with error
  15. MobileCRM.bridge.alert("An error occurred: " + error);
  16. });
  17. }

MobileCRM.DynamicEntity.createNew Function

Creates the MobileCRM.DynamicEntity object representing new entity.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.
primaryNameStringThe human readable name of the entity, e.g "Alexandro".
propertiesObjectAn object with entity properties, e.g. {firstname:"Alexandro", lastname:"Puccini"}.

MobileCRM.DynamicEntity.deleteAsync Function

Asynchronously deletes the CRM entity.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.

Return value

Type: Promise<void>

A Promise object which will be resolved after the entity record is deleted.

Example 1

This example demonstrates how to delete an account with given id.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function deleteAccount(accountId) {
  4. try {
  5. await MobileCRM.DynamicEntity.deleteAsync("account", accountid);
  6. onAccountDeleted(accountid);
  7. }
  8. catch (error) {
  9. MobileCRM.bridge.alert("An error occurred: " + error);
  10. }
  11. }

MobileCRM.DynamicEntity.deleteById Function

Asynchronously deletes the CRM entity.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.
successfunction()A callback function for successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to delete an account with given id.

  1. MobileCRM.DynamicEntity.deleteById(
  2. "account",
  3. accountid,
  4. function () {
  5. onAccountDeleted(accountid);
  6. },
  7. function (error) {
  8. MobileCRM.bridge.alert("An error occurred: " + error);
  9. }
  10. );

MobileCRM.DynamicEntity.downloadAttachment Function

[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.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, in most cases "annotation".
idStringGUID of the existing entity or null for new one.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrate how to download the note attachment image and set it into <img> element.

  1. function downloadNoteAttachment(noteId) {
  2. MobileCRM.DynamicEntity.downloadAttachment("annotation", noteId, function (base64str) {
  3. /// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
  4. var imgElement = document.getElementById("img-result");
  5. if (imgElement)
  6. imgElement.setAttribute("src", "data:;base64," + base64str); // set the "src" attribute for out <img> element
  7. }, MobileCRM.bridge.alert, null);
  8. }

MobileCRM.DynamicEntity.downloadAttachmentAsync Function

[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 resolves pending Javascript promise.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, in most cases "annotation".
idStringGUID of the existing entity or null for new one.

Return value

Type: Promise<string>

A Promise object which will be resolved with base64-encoded data string.

Example 1

This example demonstrate how to download the note attachment image and set it into <img> element.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function downloadNoteAttachment(noteId) {
  4. try {
  5. var base64str = await MobileCRM.DynamicEntity.downloadAttachmentAsync("annotation", noteId);
  6. var imgElement = document.getElementById("img-result");
  7. if (imgElement)
  8. imgElement.setAttribute("src", "data:;base64," + base64str); // set the "src" attribute for out <img> element
  9. }
  10. catch (error) {
  11. MobileCRM.bridge.alert("An error occurred: " + error);
  12. }
  13. }

MobileCRM.DynamicEntity.loadAsync Function

Asynchronously loads the CRM entity properties.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.

Return value

Type: Promise<MobileCRM.DynamicEntity>

A Promise object which will be resolved with an instance of DynamicEntity object representing entity record.

Example 1

This example demonstrates how to load the account entity with given id.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function getAccountData(accountId) {
  4. try {
  5. var entity = await MobileCRM.DynamicEntity.loadAsync("account", accountId);
  6. MobileCRM.bridge.alert(JSON.stringify(entity));
  7. }
  8. catch (err) {
  9. MobileCRM.bridge.alert(err);
  10. }
  11. }

MobileCRM.DynamicEntity.loadById Function

Asynchronously loads the CRM entity properties.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, e.g. "account".
idStringGUID of the existing entity or null for new one.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the MobileCRM.DynamicEntity object.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to load the account entity with given id.

  1. function getAccountData(accountId) {
  2. /// <param name="account" type="MobileCRM.Reference"/>;
  3. MobileCRM.DynamicEntity.loadById(
  4. "account",
  5. accountId,
  6. function (entity) {
  7. /// <param name="entity" type="MobileCRM.DynamicEntity"/>;
  8. // "entity" argument contains the MobileCRM.DynamicEntity object
  9. MobileCRM.bridge.alert(JSON.stringify(entity.properties));
  10. },
  11. function (error) {
  12. MobileCRM.bridge.alert("An error occurred: " + error);
  13. },
  14. null
  15. );
  16. }

MobileCRM.DynamicEntity.loadDocumentBody Function

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.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, in most cases "annotation".
idStringGUID of the existing entity or null for new one.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

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.

  1. function loadAccountDocumentBody(accountid){
  2. MobileCRM.DynamicEntity.loadDocumentBody("annotation", accountidid, function (base64str) {
  3. /// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
  4. MobileCRM.bridge.alert("Base64String: \n\n" + base64str);
  5. var imgElement = document.getElementById("img-result");
  6. if (imgElement)
  7. imgElement.setAttribute("src", "data:image/jpeg;base64," + base64str); // set the "src" attribute for out <img> element
  8. }, MobileCRM.bridge.alert, null);
  9. }

MobileCRM.DynamicEntity.loadDocumentBodyAsync Function

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 pending Javascript promise is resolved. This function supports both online data and the data stored in local database/BLOB store.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, in most cases "annotation".
idStringGUID of the existing entity or null for new one.

Return value

Type: Promise<string>

A Promise object which will be resolved with base64-encoded data string.

Example 1

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.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function loadAccountDocumentBody(accountid){
  4. try{
  5. var base64str = await MobileCRM.DynamicEntity.loadDocumentBody("annotation", accountidid);
  6. MobileCRM.bridge.alert("Base64String: \n\n" + base64str);
  7. var imgElement = document.getElementById("img-result");
  8. if (imgElement)
  9. imgElement.setAttribute("src", "data:image/jpeg;base64," + base64str); // set the "src" attribute for out <img> element
  10. }
  11. catch (error) {
  12. MobileCRM.bridge.alert("An error occurred: " + error);
  13. }
  14. }

MobileCRM.DynamicEntity.saveDocumentBody Function

[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

ArgumentTypeDescription
entityIdStringGUID of the existing entity or "null" for new one.
entityNameStringThe logical name of the entity; optional, default is "annotation".
relationshipMobileCRM.RelationshipThe relationship with parent object.
filePathStringAbsolute or app data-relative path to the file holding the body.
mimeTypeStringMimeType of the content, optional.
successfunction(MobileCRM.Reference)A callback function for successful asynchronous result. The result argument will carry the Reference to updated/created entity.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

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.

  1. function saveAnnotation(filePath, accountReference) {
  2. ///<param name='filePath' type='String'>path to file for annotation attachment.</param>
  3. ///<param name='accountReference' type='MobileCRM.Reference'>Reference to account.</param>
  4. var relationship = new MobileCRM.Relationship("objectid", accountReference);
  5. MobileCRM.DynamicEntity.saveDocumentBody(null, null, relationship, filePath, null, function (annotation) {
  6. ///<param name='annotation' type='MobileCRM.Reference'>Reference to nelwy created annotation.</param>
  7. MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
  8. }, MobileCRM.bridge.alert, null);
  9. }

MobileCRM.DynamicEntity.saveDocumentBodyAsync Function

[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

ArgumentTypeDescription
entityIdStringGUID of the existing entity or "null" for new one.
entityNameStringThe logical name of the entity; optional, default is "annotation".
relationshipMobileCRM.RelationshipThe relationship with parent object.
filePathStringAbsolute or app data-relative path to the file holding the body.
mimeTypeStringMimeType of the content, optional.

Return value

Type: Promise<MobileCRM.Reference>

A Promise object which will be resolved with the Reference object representing updated/created entity.

Example 1

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.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function saveAnnotation(filePath, accountReference) {
  4. ///<param name='filePath' type='String'>path to file for annotation attachment.</param>
  5. ///<param name='accountReference' type='MobileCRM.Reference'>Reference to account.</param>
  6. try{
  7. var relationship = new MobileCRM.Relationship("objectid", accountReference);
  8. var annotation = await MobileCRM.DynamicEntity.saveDocumentBody(null, null, relationship, filePath, null);
  9. MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
  10. }
  11. catch (error) {
  12. MobileCRM.bridge.alert("An error occurred: " + error);
  13. }
  14. }

MobileCRM.DynamicEntity.unzipDocumentBody Function

[v9.1] Asynchronously unpacks the document body (assumes it's a zip file) for specified entity.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the entity, in most cases the "annotation".
idStringGUID of the existing entity or null for new one.
targetDirStringThe relative path of the target directory within the application storage.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Localization Object

A static object with functions allowing to access the localized texts.

Functions

FunctionDescription
getGets the display string for the passed id.
getComponentLabelGets the display string for the passed entity and component (view, form) id.
getLoadedLangIdAsynchronously gets currently loaded localization language.
getPluralGets the plural version of the display string for the passed id.
getTextOrDefaultGets the display string for the passed id, or the passed default string if a string with the passed id doesn't exists.
initializeInitializes the Localization object.
initializeAsync[v10.0] Initializes the Localization object.
initializeEx[v10.0] Initializes the Localization object.
makeIdCreates an absolute id from section and id.

MobileCRM.Localization.get Function

Gets the display string for the passed id.

Arguments

ArgumentTypeDescription
idStringDisplay string id.

Return value

Type: String

Human readable string label.

Example 1

This example demonstrates how to get the localized text.

  1. MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
  2.  
  3. function startPointFn(localization) {
  4. // returns the localized text for localization ID "Cmd.Action".
  5. var actionText = MobileCRM.Localization.get("Cmd.Action");
  6. MobileCRM.bridge.alert(actionText);
  7. }

MobileCRM.Localization.getComponentLabel Function

Gets the display string for the passed entity and component (view, form) id.

Arguments

ArgumentTypeDescription
entityNameStringThe entity logical name.
componentTypeStringThe component type. (View, DetailView).
viewNameStringThe component id

Return value

Type: String

The component label.

Example 1

This example demonstrates how to get the localized label for certain view for Account entity.

  1. MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
  2.  
  3. function startPointFn(localization) {
  4. var viewLabel = MobileCRM.Localization.getComponentLabel("account", "View", "Custom View");
  5. MobileCRM.bridge.alert(viewLabel);
  6. }

MobileCRM.Localization.getLoadedLangId Function

Asynchronously gets currently loaded localization language.

The default language is "en-US".

Arguments

ArgumentTypeDescription
callbackfunction(langId)The callback function that is called asynchronously with currently loaded localization language as argument.
errorCallbackfunction(errorMsg)The errorCallback which is to be called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This Example demonstrate how to get current localization loaded language.

  1. MobileCRM.Localization.getLoadedLangId(startPointFn, MobileCRM.bridge.alert, null);
  2.  
  3. function startPointFn(loadedLangId) {
  4. // returns the localized loaded language id ("EN" for English);
  5. var langId = loadedLangId;
  6. MobileCRM.bridge.alert(loadedLangId);
  7. }

MobileCRM.Localization.getPlural Function

Gets the plural version of the display string for the passed id.

Arguments

ArgumentTypeDescription
idStringDisplay string id.

Return value

Type: String

Human readable plural string label.

Example 1

This example demonstrates how to get the localized plural for the name of Account entity.

  1. MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
  2.  
  3. function startPointFn(localization) {
  4. // returns the localized plural for entity "account" ("Accounts" for English).
  5. var accountsLabel = MobileCRM.Localization.getPlural("account");
  6. MobileCRM.bridge.alert(accountsLabel);
  7. }

MobileCRM.Localization.getTextOrDefault Function

Gets the display string for the passed id, or the passed default string if a string with the passed id doesn't exists.

Arguments

ArgumentTypeDescription
idStringDisplay string id.
defaultStringStringDefault display string.

Return value

Type: String

Human readable string label.


MobileCRM.Localization.initialize Function

Initializes the Localization object.

Method loads the string table asynchronously and calls either the errorCallback with error message or the callback with initialized Localization object.

All other functions will return the default or empty string before the initialization finishes.

Arguments

ArgumentTypeDescription
callbackfunction(config)The callback function that is called asynchronously with initialized Localization object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is to be called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Localization.initializeAsync Function

[v10.0] Initializes the Localization object.

Method loads the string table asynchronously and resolves pending promise with initialized Localization object.

All other functions will return the default or empty string before the initialization finishes.

Arguments

ArgumentTypeDescription
regularExpressionstringOptional regular expression defining a subset of localization keys. Refer to Regular Expression Language - Quick Reference. Set to null to obtain whole localization.

Return value

Type: Promise<MobileCRM.Localization>

A Promise object which will be resolved with initialized Localization object as argument.


MobileCRM.Localization.initializeEx Function

[v10.0] Initializes the Localization object.

Method loads the string table asynchronously and calls either the errorCallback with error message or the callback with initialized Localization object.

All other functions will return the default or empty string before the initialization finishes.

Arguments

ArgumentTypeDescription
regularExpressionstringThe regular expression defining a subset of localization keys. Refer to Regular Expression Language - Quick Reference. Set to null to obtain whole localization.
callbackfunction(config)The callback function that is called asynchronously with initialized Localization object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is to be called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Localization.makeId Function

Creates an absolute id from section and id.

Arguments

ArgumentTypeDescription
sectionStringThe section id.
idStringDisplay string id.

Return value

Type: String

Absolute id.


MobileCRM.ManyToManyReference Object

A static object with functions managing many to many relations.

Functions

FunctionDescription
addRecordAdds or removes an N-N relationship record between the two passed entities.
createCreates a new N-N relationship between the two passed entities.
removeRemoves an existing N-N relationship between the two passed entities.

MobileCRM.ManyToManyReference.addRecord Function

Adds or removes an N-N relationship record between the two passed entities.

Arguments

ArgumentTypeDescription
entityNameStringThe relationship entity name.
ref1MobileCRM.ReferenceFirst entity instance.
ref2MobileCRM.ReferenceSecond entity instance.
createBooleanWhether to create or delete the relationship record.
successfunction(result)A callback function for successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

[Obsolete]This example demonstrates how to create or remove N-N relationship between contact and account entities.

  1. var competitor = new MobileCRM.Reference("competitor", competitorid);
  2. var product = new MobileCRM.Reference("product", productid);
  3. MobileCRM.ManyToManyReference.addRecord("competitorproduct", competitor, product,
  4. function () { onCreated(); },
  5. function (err) { showError(err); }
  6. );

MobileCRM.ManyToManyReference.create Function

Creates a new N-N relationship between the two passed entities.

New relationship is created either in local database or using the online request. It depends on current application mode.

Arguments

ArgumentTypeDescription
entityNameStringThe relationship entity name.
ref1MobileCRM.ReferenceFirst entity instance.
ref2MobileCRM.ReferenceSecond entity instance.
successfunction(result)A callback function for successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to create a new N-N relationship between competitor and product entities.

  1. var competitor = new MobileCRM.Reference("competitor", competitorid);
  2. var product = new MobileCRM.Reference("product", productid);
  3. MobileCRM.ManyToManyReference.create("competitorproduct", competitor, product,
  4. function () { onCreated(); },
  5. function (err) { showError(err); }
  6. );

MobileCRM.ManyToManyReference.remove Function

Removes an existing N-N relationship between the two passed entities.

Relationship is removed either from local database or using the online request. It depends on current application mode.

Arguments

ArgumentTypeDescription
entityNameStringThe relationship entity name.
ref1MobileCRM.ReferenceFirst entity instance.
ref2MobileCRM.ReferenceSecond entity instance.
successfunction(result)A callback function for successful asynchronous result.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to remove an existing N-N relationship between competitor and product entities.

  1. var competitor = new MobileCRM.Reference("competitor", competitorid);
  2. var product = new MobileCRM.Reference("product", productid);
  3. MobileCRM.ManyToManyReference.remove("competitorproduct", competitor, product,
  4. function () { onRemoved(); },
  5. function (err) { showError(err); }
  6. );

MobileCRM.MetaEntity Object

Represents an entity metadata.

Properties

PropertyTypeDescription
isEnabledBooleanIndicates whether an entity is enabled. This field is used for limited runtime customization.
isExternalBooleanIndicates whether an entity stores data from external sources Exchange/Google.
nameStringGets the entity (logical) name.
objectTypeCodeNumberGets the unique entity type code.
primaryFieldNameStringThe name of the entity primary field (name) property.
primaryKeyNameStringThe name of the entity primary key property.
relationshipNameStringGets the name of the many-to-many relationship name. Defined only for intersect entities.
statusFieldNameStringGets the status property name. In general it is called "statuscode" but there are exceptions.
uploadOnlyBooleanIndicates whether this entity can be downloaded during synchronization.
attributesNumberGets additional entity attributes.

Methods

MethodDescription
canAppendToChecks whether the user has permission to append a child To a this parent entity.
canCreateChecks whether the current user has create permission on the entity type.
canDeleteChecks whether the current user has create permission on the entity type.
canReadChecks whether the current user has read permission on the entity type.
canWriteChecks whether the current user has write permission on the entity type.
getDepthGets the permission depth.
getPropertyGets the MetaProperty object describing the CRM attribute (field) properties.

Functions

FunctionDescription
loadByNameGets the MetaEntity by its name.

MobileCRM.MetaEntity.canAppendTo Method

Checks whether the user has permission to append a child To a this parent entity.

Arguments

ArgumentTypeDescription
childStringThe entity to append (f.e. opportunity).

Return value

Type: Boolean

True if the user has append permissions, false otherwise.


MobileCRM.MetaEntity.canCreate Method

Checks whether the current user has create permission on the entity type.

Return value

Type: Boolean

True if the permission is granted, false otherwise.


MobileCRM.MetaEntity.canDelete Method

Checks whether the current user has create permission on the entity type.

Return value

Type: Boolean

True if the permission is granted, false otherwise.


MobileCRM.MetaEntity.canRead Method

Checks whether the current user has read permission on the entity type.

Return value

Type: Boolean

True if the permission is granted, false otherwise.


MobileCRM.MetaEntity.canWrite Method

Checks whether the current user has write permission on the entity type.

Return value

Type: Boolean

True if the permission is granted, false otherwise.


MobileCRM.MetaEntity.getDepth Method

Gets the permission depth.

Arguments

ArgumentTypeDescription
permissionNumberPermission to check.

Return value

Type: Number

The permission depth (none, user, business unit, organization).


MobileCRM.MetaEntity.getProperty Method

Gets the MetaProperty object describing the CRM attribute (field) properties.

Arguments

ArgumentTypeDescription
nameStringA logical name of the CRM field.

Return value

Type: MobileCRM.MetaProperty

An instance of the MobileCRM.MetaProperty object or "null".


MobileCRM.MetaEntity.loadByName Function

Gets the MetaEntity by its name.

If you only need to know the attributes of a single entity, use this method to prevent requesting all Metadata information.

Arguments

ArgumentTypeDescription
nameStringA logical name of requested entity.
callbackfunctionThe callback function that is called asynchronously with MetaEntity object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get the MobileCRM.MetaEntity object.

  1. MobileCRM.Metadata.requestObject(
  2. function (metaData) {
  3. // Request MetaEntity object by its name.
  4. MobileCRM.MetaEntity.loadByName(
  5. "account",
  6. function (metaEntity) {
  7. /// <param name="metaEntity" type="MobileCRM.MetaEntity"/>;
  8. var metaProperties = "MetaEntity properties \n";
  9. metaProperties += "can account append to contact : " + metaEntity.canAppendTo("contact") + "\n";
  10. metaProperties += "account C-R-W-D : " + metaEntity.canCreate(); + "-" + metaEntity.canRead(); +
  11. "-" + metaEntity.canWrite(); + "-" + metaEntity.canDelete();
  12. MobileCRM.bridge.alert(metaProperties);
  13. }, MobileCRM.bridge.alert,
  14. null
  15. );
  16. },
  17. MobileCRM.bridge.alert
  18. );

MobileCRM.MetaProperty Object

Represents a property (CRM field) metadata.

Properties

PropertyTypeDescription
nameStringGets the field (logical) name.
requiredNumberGets the attribute requirement level (0=None, 1=SystemRequired, 2=Required, 3=Recommended, 4=ReadOnly).
typeNumberGets the attribute CRM type (see MS Dynamics SDK).
formatNumberGets the attribute display format.
isVirtualBooleanGets whether the property is virtual (has no underlying storage). State and PartyList properties are virtual.
isReferenceBooleanGets whether the property is a reference (lookup) to another entity.
isNullableBooleanGets whether the property may contain NULL.
defaultValueGets the property default value.
targetsArrayGets the names of target entities, if the property is a lookup, or customer.
minimumNumberGets the attribute minimum value.
maximumNumberGets the attribute minimum value.
precisionNumberGets the numeric attribute's precision (decimal places).
permissionNumberGets the attribute's permission set (0=None, 1=User, 2=BusinessUnit, 4=ParentChild, 8=Organization).
activityPartyTypeNumberGets the activity party type (from, to, attendee, etc.)
isMultiPartyBooleanGets whether the activity party property can have multiple values (multiple to, cc, resources.)
isSingularPartyBooleanGets whether the property represents a singular activity party property. These properties exists as both a Lookup property on the entity and an ActivytParty record.

MobileCRM.Metadata Object

A static object with functions for accessing the entity metadata store.

Functions

FunctionDescription
entityHasChildrenGets whether the passed entity has child entities.
getActivitiesGets the list of activities.
getEntityGets the MetaEntity object describing the entity attributes.
getEntityParentGets the entity's parent entity name.
getOptionSetValuesAsynchronously gets the list of values for given CRM OptionSet.
getStringListOptionsGets the list of options for the string list property.
requestObjectRequests the Metadata object containing the list of MetaEntities which are enabled for current mobile project.

MobileCRM.Metadata.entityHasChildren Function

Gets whether the passed entity has child entities.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.

Return value

Type: Boolean

True if the entity is a parent, false otherwise.


MobileCRM.Metadata.getActivities Function

Gets the list of activities.

It&s required to request the Metadata object prior to using this object. See MobileCRM.Metadata.requestObject.

Return value

Type: Array

An array of entity names.


MobileCRM.Metadata.getEntity Function

Gets the MetaEntity object describing the entity attributes.

It's required to request the Metadata object prior to using this object. See MobileCRM.Metadata.requestObject.

Arguments

ArgumentTypeDescription
nameStringA name of MetaEntity.

Return value

Type: MobileCRM.MetaEntity

A MobileCRM.MetaEntity object or "undefined".


MobileCRM.Metadata.getEntityParent Function

Gets the entity's parent entity name.

Arguments

ArgumentTypeDescription
childEntityNameStringThe entity name.

Return value

Type: String

The parent entity name, or "undefined" if N/A.


MobileCRM.Metadata.getOptionSetValues Function

Asynchronously gets the list of values for given CRM OptionSet.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
optionSetNameStringThe OptionSet name.
callbackfunction(optionSetValues)The callback function that is called asynchronously with option set values object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get list of values for the OptionSet field opportunity.statuscode (normally, "In Progress = 1, On Hold = 2, Won = 3, Canceled = 4, Out-Sold = 5").

  1. MobileCRM.Metadata.getOptionSetValues(
  2. "opportunity",
  3. "statuscode",
  4. function (optionSetValues) {
  5. /// <param name="optionSetValues" type="Object"></param>
  6. var values = "";
  7. for (var name in optionSetValues) {
  8. var val = optionSetValues[name];
  9. values += name + " = " + val + "\n";
  10. }
  11. MobileCRM.bridge.alert("Opportunity option set values: \n\n" + values);
  12. },
  13. MobileCRM.bridge.alert,
  14. null
  15. );

MobileCRM.Metadata.getStringListOptions Function

Gets the list of options for the string list property.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
propertyNameStringThe string list property name.

MobileCRM.Metadata.requestObject Function

Requests the Metadata object containing the list of MetaEntities which are enabled for current mobile project.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of Metadata object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(metadata)The callback function which is called asynchronously with serialized EntityForm object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get the metadata object.

  1. MobileCRM.Metadata.requestObject(function (metadata) {
  2. var metaEntity = MobileCRM.Metadata.getEntity("account");
  3. var latitudeProp = metaEntity.getProperty("address1_latitude");
  4. var longitudeProp = metaEntity.getProperty("address1_longitude");
  5. // contains entity what has child ("invoicedetail","salesorder",...);
  6. var childrenMap = metadata._childParentMap;
  7. for (var i in childrenMap) {
  8. // Parent for children (invoice has invoicedetail;)
  9. var entityParent = entity.getEntityParent(i);
  10. }
  11. }, MobileCRM.bridge.alert);

MobileCRM.MobileReport Object

Provides a functionality of mobile reporting.

Functions

FunctionDescription
runReport[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.
runReportAsync[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.
showForm[v10.1] Shows new MobileReport form.

MobileCRM.MobileReport.runReport Function

[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.

Arguments

ArgumentTypeDescription
fetchStringThe fetch XML defining the entity (entities) query used as report input.
reportXMLStringThe mobile report XML definition which can be loaded from the resco_report entity or constructed dynamically. Ignored if IsExportOnly parameter is true.
reportFormatStringReport format: Pdf (default), Html, Excel, Text.
isExportOnlyBooleanIf true then ReportXml is optional. The default is false.
isOnlineBooleanIndicates whether the report should be run against the online data or local database. The default is current application mode.
outputFileStringThe full path to the output file. If omitted a temp file is created. The output path is always passed to the success callback.
successfunction(obj)A callback function that is called with the file path to successfully created report.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to create a mobile report document of specific format.

  1. function fetchReportXML() {
  2. var report = new MobileCRM.FetchXml.Entity("resco_mobilereport");
  3. report.addAttribute("resco_data");
  4.  
  5. var fetch = new MobileCRM.FetchXml.Fetch(report);
  6. fetch.execute("Array", function (res) {
  7. /// <param name='res' type='Array'>Array of results carrying resco_data field value.</param>
  8. if (res.length > 0) {
  9. var reportXML = res[0][0];
  10. runMobileReport(reportXML);
  11. }
  12. }, MobileCRM.bridge.alert, null);
  13. }
  14. // Alternatively, you can run your own custom mobile report definition.
  15. // Assumes that 'salesorder' entity have 'totalamount' and 'name' attributes enabled.
  16. function runMobileReport(reportXML) {
  17. var fetchXML = "<fetch version='1.0' count='1' resultformat='Array' mapping='logical' distinct='true'><entity name='salesorder'><attribute name='discountamount' /><attribute name='totalamount' /><attribute name='name' /></entity></fetch>";
  18.  
  19. MobileCRM.Configuration.requestObject(function (config) {
  20. /// <param name='config' type='MobileCRM.Configuration'/>
  21. var filePath = config.storageDirectory + "/MyCustomReport.pdf"; // Create file in storage directory.
  22. MobileCRM.MobileReport.runReport(fetchXML, reportXML, "Pdf", null, false, filePath, function (res) {
  23. /// in success callback, report form with data and fetch should be displayed.
  24. }, MobileCRM.bride.alert);
  25. }, MobileCRM.bridge.alert, null);
  26. }

MobileCRM.MobileReport.runReportAsync Function

[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.

Arguments

ArgumentTypeDescription
fetchStringThe fetch XML defining the entity (entities) query used as report input.
reportXMLStringThe mobile report XML definition which can be loaded from the resco_report entity or constructed dynamically. Ignored if IsExportOnly parameter is true.
reportFormatStringReport format: Pdf (default), Html, Excel, Text.
isExportOnlyBooleanIf true then ReportXml is optional. The default is false.
isOnlineBooleanIndicates whether the report should be run against the online data or local database. The default is current application mode.
outputFileStringThe full path to the output file. If omitted a temp file is created.

Return value

Type: Promise<string>

A Promise object which will be resolved with the file path to successfully created report.


MobileCRM.MobileReport.showForm Function

[v10.1] Shows new MobileReport form.

Arguments

ArgumentTypeDescription
entityMobileCRM.ReferenceReport Entity reference what the report is related to.
sourceMobileCRM.Reference[]The list of entities that should be source of report.">Array of entity references .
reportXMLStringThe report source query.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.NumberFormat Object

[v10.2] Provides culture-specific information for formatting and parsing numeric values.

Properties

PropertyTypeDescription
currencyDecimalDigitsNumberGets the number of decimal places to use in currency values.
currencyDecimalSeparatorStringGets the string to use as the decimal separator in currency values.
currencyGroupSeparatorStringGets the string that separates groups of digits to the left of the decimal in currency values.
currencyGroupSizesNumber[]Gets the number of digits in each group to the left of the decimal in currency values.
currencyNegativePatternNumberGets the format pattern for negative currency values.
currencyPositivePatternNumberGets the format pattern for positive currency values.
currencySymbolStringGets the string to use as the currency symbol.
naNSymbolStringGets the string that represents the IEEE NaN (not a number) value.
negativeInfinitySymbolStringGets the string that represents negative infinity.
negativeSignStringGets the string that denotes that the associated number is negative.
numberDecimalDigitsNumberGets the number of decimal places to use in numeric values.
numberDecimalSeparatorStringGets the string to use as the decimal separator in numeric values.
numberGroupSeparatorStringGets the string that separates groups of digits to the left of the decimal in numeric values.
numberGroupSizesNumber[] Gets the number of digits in each group to the left of the decimal in numeric values.
numberNegativePatternNumberGets the format pattern for negative numeric values.
percentDecimalDigitsNumberGets the number of decimal places to use in percent values.
percentDecimalSeparatorStringGets the string to use as the decimal separator in percent values.
percentGroupSeparatorStringGets the string that separates groups of digits to the left of the decimal in percent values.
percentGroupSizesNumber[]Gets the number of digits in each group to the left of the decimal in percent values.
percentNegativePatternNumberGets the format pattern for negative percent values.
percentPositivePatternNumberGets the format pattern for positive percent values.
percentSymbolStringGets the string to use as the percent symbol.
perMilleSymbolStringGets the string to use as the per mille symbol.
positiveInfinitySymbolStringGets the string that represents positive infinity.
positiveSignStringGets the string that denotes that the associated number is positive.

MobileCRM.ObservableObject Object

Represents a generic object which is monitoring the changes of its properties.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.ObservableObject object.
addPropCreates a new observable property for this object
getChangedCreates a clone of this object containing all properties that were changed since object construction.
setTypedValue[v8.0] Sets the explicitly typed value for specified property.

MobileCRM.ObservableObject.constructor Method

Constructs an instance of MobileCRM.ObservableObject object.

Arguments

ArgumentTypeDescription
propsObjectOptional list of properties.

MobileCRM.ObservableObject.addProp Method

Creates a new observable property for this object

Arguments

ArgumentTypeDescription
nameStringA name of the new property.
writableBooleanIndicates whether the property should have setter.
valueAn initial value.

MobileCRM.ObservableObject.getChanged Method

Creates a clone of this object containing all properties that were changed since object construction.

This method enumerates object recursively and creates the object clone containing only the changed properties.

Return value

Type: Object

An object clone containing all changed properties.


MobileCRM.ObservableObject.setTypedValue Method

[v8.0] Sets the explicitly typed value for specified property.

Arguments

ArgumentTypeDescription
propNameStringThe name of the property which is being set.
typeStringThe fully qualified .Net type (e.g. "System.String" or "MobileCrm.Data.IReference,MobileCrm.Data").
valueThe value which has to be set.

Example 1

This example demonstrate how to set list of values for multi select pick list item on entity form.

  1. MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
  2. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  3. if (detailView) {
  4. var dv = entityForm.getDetailView("General");
  5. if (dv) {
  6. var multiOpt = dv.getItemByName("multi_pick_list_item");
  7. if (multiOpt) {
  8. // val must contain a string with a list of numeric values delimited with semi-colon (;)
  9. multiOpt.setTypedValue("value", "System.String", "100000001;100000000;100000002");
  10. }
  11. }
  12. }
  13. return true;
  14. }, MobileCRM.bridge.alert, null);

MobileCRM.Platform Object

Represents object for querying platform specific information and executing platform integrated actions.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.Platform.requestObject function.

Properties

PropertyTypeDescription
capabilitiesNumberGets the mask of capability flags supported by this device (MakePhoneCalls=1; HasMapView=2).
deviceIdentifierStringGets the unique identifier of this device.
screenWidthNumberGets the current screen width in pixels.
screenHeightNumberGets the current screen width in pixels.
screenDensityNumberGets the screen density (DPI).
isMultiPanelBooleanGets whether the device has tablet or phone UI.
customImagePathStringGets or sets the custom image path that comes from customization.

Functions

FunctionDescription
email[v8.1] Opens the platform-specific e-mail message form with pre-filled data.
emailWithAttachments[v9.1] Sends a list of files (full paths or IReferences to blobs) as email attachments.
getDeviceInfoGets the device information.
getLocationGets current geo-location from platform-specific location service.
getLocationAsyncGets current geo-location from platform-specific location service.
getNetworkInfo[v11.2] Gets network information.
getURLGets the full URL of currently loaded HTML document.
makeCall[v8.0] Opens the platform-specific call application with specified phone number.
navigateToExecute the navigateTo function based on the latitude and longitude.
openDocument[v8.1] Opens specified document in associated program.
openUrlOpen url in external browser.
preventBackButtonPrevents application to close when HW back button is pressed and installs handler which is called instead.
requestObjectRequests the managed Platform object.
scanBarCodeActivates the bar-code scanning.
scanBarCodeRequiredLengthActivates the bar-code scanning.
sendSMS[v11.2.3] Opens the platform-specific sms application with specified phone number and pre-fill text.

MobileCRM.Platform.email Function

[v8.1] Opens the platform-specific e-mail message form with pre-filled data.

Arguments

ArgumentTypeDescription
addressStringRecipient's email address.
subjectStringAn e-mail subject.
bodyStringA string with email body.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for errorCallback.

Example 1

This example demonstrates how to call native email client and send message to specific email address.

  1. MobileCRM.Platform.email(
  2. "someone@example.com", /// email address
  3. "Test Subject", /// email subject
  4. "Hi, This is Resco email.", /// email body
  5. MobileCRM.bridge.alert
  6. );

MobileCRM.Platform.emailWithAttachments Function

[v9.1] Sends a list of files (full paths or IReferences to blobs) as email attachments.

This method either open the CRM Email form or the native mail client (depending on application settings).

Arguments

ArgumentTypeDescription
addressStringRecipient"s email address.
subjectStringAn e-mail subject.
bodyStringA string with email body.
attachmentsArrayArray of files to send. Element must be a full path or a IReference to a note, etc.
entityMobileCRM.ReferenceThe related entity reference.
relationshipMobileCRM.RelationshipThe relationship to the created email entity. (optional).
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for errorCallback.

Example 1

This example demonstrates how to call native email client or MobileCRM HTML emails with attachments.

  1. function sendEmail(filePath) {
  2. var attachments = []; /// Array attachments to send. Element must be a full path or a reference to a note.
  3. attachments.push(filePath);
  4.  
  5. MobileCRM.Platform.emailWithAttachments(
  6. "someone@example.com", /// email address
  7. "Test Subject", /// email subject
  8. "Hi, This is Resco email.", /// email body
  9. attachments,
  10. null, null,
  11. endTest, null
  12. );
  13. }

MobileCRM.Platform.getDeviceInfo Function

Gets the device information.

Arguments

ArgumentTypeDescription
successfunction(result)A callback function for successful asynchronous result. The result will carry a MobileCRM._DeviceInfo object.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to get device info MobileCRM._DeviceInfo object.

  1. // Request device info object
  2. MobileCRM.Platform.getDeviceInfo(
  3. function (info) {
  4. /// <param name="info" type="MobileCRM._DeviceInfo"></param>
  5. var result = "Device Info : \n";
  6. for (var prop in info) {
  7. result += prop + " : " + info[prop].toString(); + "\n";
  8. }
  9. MobileCRM.bridge.alert(result);
  10. },
  11. MobileCRM.bridge.alert
  12. );

MobileCRM.Platform.getLocation Function

Gets current geo-location from platform-specific location service.

If the current platform does not support the location service, the failed handler is called with error "Unsupported".

Arguments

ArgumentTypeDescription
successfunction(result)A callback function for successful asynchronous result. The result will carry an object with properties latitude and longitude.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.
ageNumberMax age in seconds to accept GPS.
precisionNumberDesired accuracy in meters.
timeoutNumberTimeout in milliseconds (since v10.1).

MobileCRM.Platform.getLocationAsync Function

Gets current geo-location from platform-specific location service.

If the current platform does not support the location service, returned Promise is rejected with error "Unsupported".

Arguments

ArgumentTypeDescription
ageNumberMax age in seconds to accept GPS.
precisionNumberDesired accuracy in meters.
timeoutNumberTimeout in milliseconds (since v10.1).

Return value

Type: Promise<object>

A Promise object which will be resolved with an object having latitude and longitude properties.


MobileCRM.Platform.getNetworkInfo Function

[v11.2] Gets network information.

Arguments

ArgumentTypeDescription
successfunction(result)A callback function for successful asynchronous result. The result will carry an object with properties connected and fastConnection.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Platform.getURL Function

Gets the full URL of currently loaded HTML document.

Arguments

ArgumentTypeDescription
successfunction(result)A callback function for successful asynchronous result. The result will carry a string with URL.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Platform.makeCall Function

[v8.0] Opens the platform-specific call application with specified phone number.

Arguments

ArgumentTypeDescription
telephoneStringTelephone number
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for errorCallback.

Example 1

This example demonstrates how to call a phone number.

  1. var tel = "555-0131";
  2. MobileCRM.Platform.makeCall(tel, MobileCRM.bridge.alert);

MobileCRM.Platform.navigateTo Function

Execute the navigateTo function based on the latitude and longitude.

Arguments

ArgumentTypeDescription
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Platform.openDocument Function

[v8.1] Opens specified document in associated program.

Apple security policy doesn&t allow this functionality on iOS.

Arguments

ArgumentTypeDescription
pathStringA path to the document file.
mimeTypeStringDocument MIME type (required on Android).
argsStringOptional arguments for Windows 7 command line.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for errorCallback.

Example 1

This example demonstrates how to open a document in associated program.

  1. var documentPath = "c:\\Desktop\\test.txt";
  2. MobileCRM.Platform.openDocument(documentPath, "text/plain", null, MobileCRM.bridge.alert, null);

Example 2

This example demonstrates how to open a document in explicitly specified program using command line arguments (Windows only!).

  1. var documentPath = "c:\\Desktop\\test.txt";
  2. var notePad = "c:\\windows\\system32\\notepad.exe"
  3. MobileCRM.Platform.openDocument(notePad, "text/plain", documentPath, MobileCRM.bridge.alert, null);

MobileCRM.Platform.openUrl Function

Open url in external browser.

Arguments

ArgumentTypeDescription
urlStringweb page url

Example 1

This example demonstrates how to open link outside of MobileCRM application.

  1. MobileCRM.Platform.openUrl("http://www.google.com");

MobileCRM.Platform.preventBackButton Function

Prevents application to close when HW back button is pressed and installs handler which is called instead.

Pass "null" handler to allow the HW back button.

Works only under OS having HW back button (Android, Windows 10).

Arguments

ArgumentTypeDescription
handlerfunction()Handler function which will be called each time when user presses the Android HW back button.

MobileCRM.Platform.requestObject Function

Requests the managed Platform object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of Platform object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(platform)The callback function that is called asynchronously with serialized Platform object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get MobileCRM.Platform object.

  1. // Request MobileCRM.Platform object
  2. MobileCRM.Platform.requestObject(
  3. function (platform) {
  4. /// <param name="platform" type="MobileCRM.Platform"></param>
  5. var result = "Platform Info : \n";
  6. for (var prop in platform) {
  7. result += prop + " : " + platform[prop] + "\n";
  8. }
  9. MobileCRM.bridge.alert(result);
  10. },
  11. MobileCRM.bridge.alert
  12. );

MobileCRM.Platform.scanBarCode Function

Activates the bar-code scanning.

If the current platform does not support the bar-code scanning, the failed handler is called with error "Unsupported".

Arguments

ArgumentTypeDescription
successfunction(result)A callback function for successful asynchronous result. The result will carry an array of strings with scanned codes.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to call Barcode scanner and get the barcode.

  1. MobileCRM.Platform.scanBarCode(
  2. function (barcodes) {
  3. /// <param name="barcode" type="Array">Array of scanned barcode</param>
  4. barcode = "";
  5. for (var i in barcodes)
  6. barcode += "\n barcode " + i + " : " + barcodes[i];
  7. MobileCRM.bridge.alert(barcode);
  8. },
  9. MobileCRM.bridge.alert
  10. );

MobileCRM.Platform.scanBarCodeRequiredLength Function

Activates the bar-code scanning.

If the current platform does not support the bar-code scanning, the failed handler is called with error "Unsupported".

Arguments

ArgumentTypeDescription
requiredLengthNumberSet required length of scanned barcode.
successfunction(result)A callback function for successful asynchronous result. The result will carry an array of strings with scanned codes.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Platform.sendSMS Function

[v11.2.3] Opens the platform-specific sms application with specified phone number and pre-fill text.

Arguments

ArgumentTypeDescription
phoneNumberStringPhone number
textStringSMS text
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for errorCallback.

Example 1

This example demonstrates how to open sms application with predefined telephone number and message text.

  1. MobileCRM.Platform.sendSMS("123-456-789", "This sms was sent using RESCO MobileCRM JSBridge api.",
  2. function (err) {
  3. MobileCRM.bridge.alert("Send SMS failed.\nErr: " + err);
  4. }
  5. );

MobileCRM.Questionnaire Object

Provides a functionality for questionnaires.

Functions

FunctionDescription
getGroupNameGenerates the real name of repeatable question group.
getQuestionNameGenerates the real name of question from repeatable group.
showForm[v10.2] Shows the questionnaire form.

MobileCRM.Questionnaire.getGroupName Function

Generates the real name of repeatable question group.

Arguments

ArgumentTypeDescription
nameStringBase question group name from questionnaire template.
repeatIndexNumberRepeat index of the group.

MobileCRM.Questionnaire.getQuestionName Function

Generates the real name of question from repeatable group.

Arguments

ArgumentTypeDescription
nameStringBase question name from questionnaire template.
repeatIndexNumberRepeat index of the group containing the question.

MobileCRM.Questionnaire.showForm Function

[v10.2] Shows the questionnaire form.

Arguments

ArgumentTypeDescription
idStringId (guid) of the questionnaire.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Reference Object

Represents an entity reference which provides the minimum information about an entity.

Properties

PropertyTypeDescription
entityNameStringThe logical name of the reference, e.g. "account".
idStringGUID of the existing entity or null for new one.
isNewBooleanIndicates whether the entity is newly created.
primaryNameStringThe human readable name of the reference, e.g. "Alexandro".

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.Reference object.
toStringPrints the reference primary name into string.

Functions

FunctionDescription
loadAsyncAsynchronously loads the CRM reference.
loadByIdAsynchronously loads the CRM reference.

MobileCRM.Reference.constructor Method

Constructs an instance of MobileCRM.Reference object.

Arguments

ArgumentTypeDescription
entityNameStringThe logical name of the reference, e.g. "account".
idStringGUID of the existing entity or null for new one.
primaryNameStringThe human readable name of the reference, e.g "Alexandro".

MobileCRM.Reference.toString Method

Prints the reference primary name into string.

Return value

Type: String

A string with primary name of this entity reference.


MobileCRM.Reference.loadAsync Function

Asynchronously loads the CRM reference.

Arguments

ArgumentTypeDescription
entityNameStringAn entity name
idStringThe reference ID.

Return value

Type: Promise<MobileCRM.Reference>

A Promise object which will be resolved with an instance of Reference object representing entity record reference.


MobileCRM.Reference.loadById Function

Asynchronously loads the CRM reference.

Arguments

ArgumentTypeDescription
entityNameStringAn entity name
idStringThe reference ID.
successfunction(result)A callback function for successful asynchronous result. The result will carry an instance of MobileCRM.Reference object.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.Relationship Object

Represents a relationship between two entities.

Properties

PropertyTypeDescription
sourcePropertyStringGets the name of the source of the relationship.
targetMobileCRM.ReferenceGets the target of the relationship.
intersectEntityStringGets the intersect entity if any. Used when displaying entities that are associated through a Many to Many relationship.
intersectPropertyStringGets the intersect entity property if any. Used when displaying entities that are associated through a Many to Many relationship.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.Relationship object.

MobileCRM.Relationship.constructor Method

Constructs an instance of MobileCRM.Relationship object.

Arguments

ArgumentTypeDescription
sourcePropertyStringGets the name of the source of the relationship.
targetMobileCRM.ReferenceGets the target of the relationship.
intersectEntityStringGets the intersect entity if any. Used when displaying entities that are associated through a Many to Many relationship.
intersectPropertyStringGets the intersect entity property if any. Used when displaying entities that are associated through a Many to Many relationship.

MobileCRM._DeviceInfo Object

Represents the device information.

To obtain this object, use MobileCRM.Platform.getDeviceInfo function.

Properties

PropertyTypeDescription
nameStringGets the name identifying the device.
oSVersionStringGets name and version of operating system.
modelStringGets device model identifying the real device hardware.
buildInfoStringGets the build info (bundle ID on iOS)

MobileCRM._Settings Object

Internal object representing the application settings.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.Configuration.requestObject function. See MobileCRM.Configuration

Properties

PropertyTypeDescription
absoluteUrlStringGets the absolute URL (including the CrmOrganization).
activityListInitialEntityStringGets or sets the last active entity in the ActivityList.
applicationLockNumberGets or sets the application lock state (0=None, 1=Soft, 2=Permanent).
appointmentViewModeNumberGets or sets the last active view mode in Calendar view.
authenticationTypeNumberGets or sets the CRM server authentication method (0=ActiveDirectory, 1=CRM Online, 2=Internet facing., 3=CRM Online EMEA, 4=CRM Online APAC).
autoSyncNumberGets or sets when the application starts to sync on the background (0=Never, 1=OnStart, 2=OnChange, 3=OnStartAndChange).
autoSyncAfterChangeNumberGets the number of seconds to wait before syncing after data change. Negative to disable.
autoSyncAfterChangeOnlineNumberGets the number of seconds to wait before syncing after data change in online mode. 0 or negative to disable, default is 1.
autoSyncDelayNumberGets or sets the automatic sync delay in seconds.
autoSyncAfterStartNumberGets the number of seconds to wait before syncing after application start. Negative to disable.
canUsePasswordBooleanIndicates whether there is a valid password and whether it can be used.
clientCertificateThumbprintStringGets or sets the thumbprint of client certificate which should be used for client authentication.
clientCustomizeBooleanGets or sets whether entities can be disabled on the client.
createCallEntityBooleanGets or sets whether to create the call entity after a call has been made from MobileCRM.
crm2011AuthUrlStringGets or sets the discovered CRM service authentication server url.
crm2011AuthTypeStringGets or sets the discovered CRM service authentication type.
crmOnlineDeviceTokenStringGets or sets the token (cookie) issued by LiveId services identifying this device.
crmOnlineDeviceTokenExpiresDateGets or sets when the "CrmOnlineDeviceToken" expires (in UTC).
crmOrganizationStringGets or sets the CRM organization (Absolute path in org url).
crmWebServiceVersionNumberGets or sets the discovered CRM service version (4 or 5).
crmWebServiceMinorVersionNumberGets or sets the the discovered CRM service minor version (13 - for CRM 2011 Rollup 13 and up).
currencyDecimalPrecisionNumberGets or sets the organization Pricing Decimal Precision configuration option (0..4).
currencyDisplayOptionNumberGets or sets the currency field display option 0- Symbol ($), 1 - Code (USD).
customizationDirectoryStringGets or sets the customization directory.
databaseLocaleStringGets or sets the database local language (for case-insensitive and language dependent compare). E.g. "en-US".
databaseSchemaHashStringGets or sets the database schema hash.
density (Android only)NumberGets or sets the application Density (120=Low, 160=Medium, 240=High, 320=ExtraHigh, 480=ExtraExtraHigh).
deviceFriendlyNameStringGets or sets the device friendly name (Steve's iPhone).
deviceIdentifierStringGets or sets the hardware unique id.
deviceInfoStringGets or sets the device system an hw information (OS, etc.)
deviceNameStringGets or sets the device name (Base64 encoded "InternalDeviceId").
disabledEntitiesBooleanGets the names of the disabled entities. Use for limited runtime customization.
domainStringGets or sets the user domain.
emailSignatureStringGets or sets the email signature.
enableCallImport (Android, Windows Mobile)BooleanEnables the Call Import form (appears on the Home form)
enableDashboardBooleanEnables the Dashboard form (appears on the Home form).
enableMapBooleanEnables the Map form (appears on the Home form).
enableListButtonsBooleanEnables list buttons. Default is true.
forcedFullSyncDateDateGets or sets the date when the device must be full synced. If the last sync was before this date, the next sync must be full.
forgetPasswordBooleanPrevents remembered password to be used for next login.
fullNameConventionCodeNumberGets or sets the option for generating the entity full name (contact, lead) e.g. how to combine the first, middle and last name (0="L,F", 1="F L", 2="L,F m", 3="F m L", 4="L,F M", 5="F M L", 6="L F", 7="LF").
hasSyncErrorsBooleanGets or sets whether there were any synchronization errors encountered.
hasTaskReminder (Android, iOS, Windows Phone)BooleanGets or sets whether reminders should be scheduled for tasks.
homeRealmStringGets or sets the URL of the authentication server (ADFS) in case of multi domain deployment.
ignoreCertificateErrorsBooleanGets or sets whether to ignore HTTPS certificate errors. (Should be used for evaluation and DEBUG only!)
invalidLoginCountNumberGets or sets the invalid login count.
internalDeviceIdStringGets or sets the device id (GUID).
isDarkTheme (WP7 only)BooleanGets or sets the UI theme (Dark or Light).
isDemoDatabaseBooleanGets or sets whether the current database contains demo data and should not be synced.
isCrmOnlineBooleanGets whether the login is for a CRM Online instance.
isValidBooleanGets whether the login information is valid and complete. Indicates whether the user name and password are non-empty. Whether they are correct is up to the we service. Also checks whether the web service url is non-empty.
languageStringGets or sets the UI text language.
lastProcessedCallTime (Android, Windows Mobile)DateGets or sets the time of the last processed call history entry.
lastServerContactDateGets or sets the time of the last server contact (either sync or security policy).
lastSyncDateDateGets or sets the last synchronization end date.
lastUserInteractionDateGets or sets the last user interaction time.
legacyPasswordStringGets or sets the synchronization service password.
lockReasonStringGets or sets the reason of the application lock.
loginTimeoutNumberGets or sets the time in seconds after which the password expires and application login is required.
maxAttachmentSizeNumberGets or sets the maximum attachment size to sync (in KB).
maxSyncCountNumberGets or sets the maximum number of records (per entity) to download.
multiThreadSyncBooleanGets or sets whether to use multi-threaded synchronization. Default true.
onlineModeNumberGets or sets when and how the application is switched to online mode (0=Always, 1=WifiOnly, 2=Manual, 3=Never).
organizationStringGets or sets the organization name. Obsolete, only for compatibility.
organizationIdStringGets or sets the current user's organization GUID (given by the server).
passwordStringGets or sets the synchronization service password.
passwordHashStringGets or sets the password hash.
phoneApplicationStringGets or sets the URL scheme of application used for making calls.
pushId (Android, iOS)StringGets or sets the push id used for push notification send to this device.
readonlySettingsArrayGets the list of read-only settings.
requireSyncLoginBooleanGets or sets whether the user must login at sync start.
savePasswordBooleanGets or sets whether to store the encrypted password in the config file.
saveSignatureAsImageBooleanGets or sets whether to store signature attachments as SVG (vector) or PNG (image).
secRulesHashNumberGets or sets the hash code of the last downloaded security policy (zero for no policy).
serverHostNameStringGets the CRM server host name.
serverSettingsVersionStringGets or sets the version of the settings file as send with the customization.
serverVersionNumberGets or sets the server version, either 4 for CRM 4.0 or 5 for CRM 2011.
syncCountNumberGets or sets the number of incremental synchronizations performed so far.
incSyncUsesVersionNumberSortingBooleanGets or sets whether incremental sync fetches use "order by versionnumber" wherever possible. Since 10.2, default true.
syncEmailAsTextBooleanGets or sets whether to convert email to text during sync. Since 6.4, default false.
syncFilterHashStringGets or sets the sync filter file hash code.
systemUserIdStringGets or sets the current user GUID (given by the server).
tourplanInitialEntityStringGets or sets the last active entity in the Tourplan (Calendar).
updateObjectTypeCodesBooleanGets or sets whether to update entity objectypecodes on first sync.
useCrmEmailBooleanGets or sets whether to create a CRM email entity or use the platform email service.
useDatabaseBlobStoreBooleanGets or sets whether to store attachment blobs in database or in files. If you change this setting you must perform a full sync!
useDatabaseEncryptionBooleanGets or sets whether the database is encrypted. Only used when the database is created (full sync). Default true.
userDefaultCurrencyIdStringGets or sets the user's default currency GUID. If not set use the organization default.
userLoginStringGets or sets the full user name (domain slash name).
userNameStringGets or sets the user name.
useRowVersionChangeTrackingBooleanGets or sets whether to use RowVersion or ModifiedOn based sync. Default is true.
urlStringGets or sets the web service URL used for synchronization.
verifyServerCertificateBooleanGets or sets whether to verify server SSL certificate. Since 6.3, default false (don't verify SSL).

MobileCRM.FetchXml Namespace

Contains a set of objects implementing the FetchXML request methods

Objects

ObjectDescription
AttributeRepresents a FetchXml select statement (CRM field).
ConditionRepresents a FetchXml attribute condition statement.
EntityRepresents a FetchXml query root entity.
FetchRepresents a FetchXml query object.
FilterRepresents a FetchXml filter statement. A logical combination of Conditions and child-filters.
LinkEntityRepresents a FetchXml query linked entity.
OrderRepresents a FetchXml order statement.

MobileCRM.FetchXml.Attribute Object

Represents a FetchXml select statement (CRM field).

Properties

PropertyTypeDescription
aggregateStringAn aggregation function.
aliasStringDefines an attribute alias.
dategroupingStringA date group by modifier (year, quarter, month, week, day).
groupbyBooleanIndicates whether to group by this attribute.
nameStringA lower-case entity attribute name (CRM logical field name).

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.FetchXml.Attribute object.

MobileCRM.FetchXml.Attribute.constructor Method

Constructs an instance of MobileCRM.FetchXml.Attribute object.

Arguments

ArgumentTypeDescription
nameStringA lower-case entity attribute name (CRM logical field name).

MobileCRM.FetchXml.Condition Object

Represents a FetchXml attribute condition statement.

Properties

PropertyTypeDescription
attributeStringThe attribute name (CRM logical field name).
operatorStringThe condition operator. "eq", "ne", "in", "not-in", "between", "not-between", "lt", "le", "gt", "ge", "like", "not-like", "null", "not-null", "eq-userid", "eq-userteams", "today", "yesterday", "tomorrow", "this-year", "last-week", "last-x-hours", "next-x-years", "olderthan-x-months", ...
uinameStringThe lookup target entity display name.
uitypeStringThe lookup target entity logical name.
valueThe value to compare to.
valuesArrayThe list of values to compare to.

MobileCRM.FetchXml.Entity Object

Represents a FetchXml query root entity.

Properties

PropertyTypeDescription
attributesArrayAn array of MobileCRM.FetchXml.Attribute objects.
filterMobileCRM.FetchXml.FilterA query filter.
linkentitiesArrayAn array of MobileCRM.FetchXml.LinkEntity objects.
nameStringAn entity logical name.
orderArrayAn array of MobileCRM.FetchXml.Order objects.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.FetchXml.Entity object.
addAttributeAdds an entity attribute to the fetch query.
addAttributesAdds all entity attributes to the fetch query.
addFilterAdds a filter for this fetch entity.
addLinkAdds an entity link (join) to the fetch query.
orderByAdds an order by statement to the fetch query.
removeLinkRemoves an entity link from the fetch query.

MobileCRM.FetchXml.Entity.constructor Method

Constructs an instance of MobileCRM.FetchXml.Entity object.

Arguments

ArgumentTypeDescription
nameStringAn entity logical name.

MobileCRM.FetchXml.Entity.addAttribute Method

Adds an entity attribute to the fetch query.

Arguments

ArgumentTypeDescription
nameStringThe attribute (CRM logical field name) to order by.
aliasStringOptional parameter defining an attribute alias.
aggregateStringOptional parameter defining an aggregation function.

Return value

Type: MobileCRM.FetchXml.Attribute

The newly created MobileCRM.FetchXml.Attribute object

Example 1

Following example creates the fetch entity for account with two attributes.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttribute("accountid");
  3. entity.addAttribute("name");
  4. entity.addAttribute("address1_line1");

MobileCRM.FetchXml.Entity.addAttributes Method

Adds all entity attributes to the fetch query.


MobileCRM.FetchXml.Entity.addFilter Method

Adds a filter for this fetch entity.

Return value

Type: MobileCRM.FetchXml.Filter

Existing or newly created entity filter.


MobileCRM.FetchXml.Entity.orderBy Method

Adds an order by statement to the fetch query.

Arguments

ArgumentTypeDescription
attributeStringThe attribute (CRM logical field name) to order by.
descendingBooleanfalse, for ascending order; true, for descending order.

Return value

Type: MobileCRM.FetchXml.Order

The newly created MobileCRM.FetchXml.Order object.

Example 1

Following example creates the fetch entity for account with ascending order by "name" field.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. entity.orderBy("name", false);

MobileCRM.FetchXml.Fetch Object

Represents a FetchXml query object.

Properties

PropertyTypeDescription
aggregateBooleanIndicates whether the fetch is aggregated.
countintthe maximum number of records to retrieve.
entityMobileCRM.FetchXml.EntityAn entity object.
pageint1-based index of the data page to retrieve.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.FetchXml.Fetch object.
executePerforms the asynchronous CRM Fetch request.
executeAsyncPerforms the asynchronous CRM Fetch request.
executeOffline[v8.0] Performs the offline CRM Fetch request regardless of the app online/offline mode.
executeOnline[v8.0] Performs the online CRM Fetch request regardless of the app online/offline mode.
serializeToXml[v10.0] Serializes the Fetch object to XML.
serializeToXmlAsync[v10.0] Serializes the Fetch object to XML.

Functions

FunctionDescription
deserializeFromXmlDeserializes the Fetch object from XML.
deserializeFromXmlAsyncDeserializes the Fetch object from XML.
executeFromXMLPerforms the asynchronous CRM Fetch command.

MobileCRM.FetchXml.Fetch.constructor Method

Constructs an instance of MobileCRM.FetchXml.Fetch object.

Arguments

ArgumentTypeDescription
entityMobileCRM.FetchXml.EntityAn entity object.
countintthe maximum number of records to retrieve.
pageint1-based index of the data page to retrieve.

MobileCRM.FetchXml.Fetch.execute Method

Performs the asynchronous CRM Fetch request.

Arguments

ArgumentTypeDescription
outputStringA string defining the output format: Array, JSON, XML or DynamicEntities.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to fetch a list of accounts and process their names.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttribute("accountid");
  3. entity.addAttribute("name");
  4. var fetch = new MobileCRM.FetchXml.Fetch(entity);
  5. fetch.execute(
  6. "Array", // Take the results as an array of arrays with field values
  7. function (result) {
  8. // "result" is
  9. // [["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"],
  10. // ["All Cycles","0FDBF212-4F72-4019-A9B6-59F0695EB646"],...];
  11. for (var i in result) {
  12. // "account" is ["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"]
  13. var account = result[i];
  14. // Pass accountid and name for processing
  15. processAccount(account[0], account[1]);
  16. }
  17. },
  18. function (err) {
  19. MobileCRM.bridge.alert("Error fetching accounts: " + err);
  20. },
  21. null
  22. );

MobileCRM.FetchXml.Fetch.executeAsync Method

Performs the asynchronous CRM Fetch request.

Arguments

ArgumentTypeDescription
outputStringA string defining the output format: Array, JSON, XML or DynamicEntities.
onlineBooleanOptional parameter determining whether the fetch should be executed online or offline. If omitted, function respects current online/offline mode of the app.

Return value

Type: Promise<any[]>

A Promise object which will be resolved with array of objects having type specified by output argument.

Example 1

This example demonstrates how to fetch a list of accounts and process their names.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttribute("accountid");
  3. entity.addAttribute("name");
  4. var fetch = new MobileCRM.FetchXml.Fetch(entity);
  5. fetch.executeAsync(null) // "null" stands for default "DynamicEntities" result format
  6. .then(function (result) {
  7. // Promise was fulfilled and we obtained an array of DynamicEntities
  8. for (var i in result) {
  9. var account = result[i];
  10. // Pass account id and name for further processing
  11. processAccount(account.id, account.primaryName);
  12. }
  13. })
  14. .catch(function (err) {
  15. // Promise was rejected with error
  16. MobileCRM.bridge.alert("Error fetching accounts: " + err);
  17. });

MobileCRM.FetchXml.Fetch.executeOffline Method

[v8.0] Performs the offline CRM Fetch request regardless of the app online/offline mode.

Arguments

ArgumentTypeDescription
outputStringA string defining the output format: Array, JSON, XML or DynamicEntities.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.executeOnline Method

[v8.0] Performs the online CRM Fetch request regardless of the app online/offline mode.

Arguments

ArgumentTypeDescription
outputStringA string defining the output format: Array, JSON, XML or DynamicEntities.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.serializeToXml Method

[v10.0] Serializes the Fetch object to XML.

Arguments

ArgumentTypeDescription
successfunction(String)A callback function for successful asynchronous result. The result argument will carry the XML representation of the Fetch object.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.serializeToXmlAsync Method

[v10.0] Serializes the Fetch object to XML.

Return value

Type: Promise<string>

A Promise object which will be resolved with the XML representation of this Fetch object.


MobileCRM.FetchXml.Fetch.deserializeFromXml Function

Deserializes the Fetch object from XML.

Arguments

ArgumentTypeDescription
xmlStringA string defining the fetch XML request.
successfunction(result: MobileCRM.FetchXml.Fetch)A callback function for successful asynchronous result. The result argument will carry the Fetch object.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to convert a fetch XML string into MobileCRM.FetchXml.Fetch object.

  1. var xml =
  2. '<fetch>\
  3. <entity name="account">\
  4. <attribute name="accountid" />\
  5. <attribute name="name" />\
  6. <order attribute="name" descending="false" />\
  7. <filter type="and">\
  8. <condition attribute="statecode" operator="eq" value="0" />\
  9. </filter>\
  10. </entity>\
  11. </fetch>';
  12.  
  13. MobileCRM.FetchXml.Fetch.deserializeFromXml(xml, function (fetch) {
  14. /// <param name="fetch" type="MobileCRM.FetchXml.Fetch" />
  15. fetch.entity.filter.startsWith("name", "B"); // Modify deserialized fetch...
  16. fetch.execute("DynamicEntities", function (res) { // ... and execute it
  17. var report = res.join("\r\n");
  18. MobileCRM.bridge.alert(report);
  19. }, MobileCRM.bridge.alert);
  20. }, MobileCRM.bridge.alert);

MobileCRM.FetchXml.Fetch.deserializeFromXmlAsync Function

Deserializes the Fetch object from XML.

Arguments

ArgumentTypeDescription
xmlStringA string defining the fetch XML request.

Return value

Type: Promise<MobileCRM.FetchXml.Fetch>

A Promise object which will be resolved with the Fetch object.


MobileCRM.FetchXml.Fetch.executeFromXML Function

Performs the asynchronous CRM Fetch command.

Arguments

ArgumentTypeDescription
fetchXmlDataStringCRM fetch in XML representation.
successfunction(result)A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by resultformat XML attribute (Array, JSON, XML or DynamicEntities).
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

Example 1

This example demonstrates how to fetch a list of accounts and process their names using XML fetch query.

  1. var xmlData = '<fetch resultformat="Array"><entity name="account"><attribute name="accountid"/>' +
  2. '<attribute name="name"/></entity></fetch>';
  3. MobileCRM.FetchXml.Fetch.executeFromXML(
  4. xmlData,
  5. function (result) {
  6. for (var i in result) {
  7. var props = result[i];
  8. processAccount(props[0], props[1]);
  9. }
  10. },
  11. function (err) {
  12. MobileCRM.bridge.alert("Error fetching accounts: " + err);
  13. },
  14. null
  15. );

MobileCRM.FetchXml.Filter Object

Represents a FetchXml filter statement. A logical combination of Conditions and child-filters.

Properties

PropertyTypeDescription
conditionsArrayAn array of Condition objects.
filtersArrayAn array of Filter objects representing child-filters.
typeStringDefines the filter operator ("or" / "and").

Methods

MethodDescription
betweenAdds a condition that the passed attribute is between the passed bounds.
containsAdds a condition that the passed column starts with the passed string.
isInAdds a attribute inclusion condition to the filter.
notInAdds a attribute inclusion condition to the filter.
startsWithAdds a condition that the passed column value contains the passed string.
whereAdds a attribute condition to the filter.

MobileCRM.FetchXml.Filter.between Method

Adds a condition that the passed attribute is between the passed bounds.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
lowDepends on attribute typeThe lower bound.
highDepends on attribute typeThe higher bound.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.

Example 1

Following example creates the fetch entity for account with filter on entities modified on June 2013.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. var filter = new MobileCRM.FetchXml.Filter();
  4. filter.between("modifiedon", new Date(2013, 5, 1), new Date(2013, 6, 1));
  5. entity.filter = filter;

MobileCRM.FetchXml.Filter.contains Method

Adds a condition that the passed column starts with the passed string.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
valueStringThe value to compare to.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.

Example 1

Following example creates the fetch entity for account with filter on entities containing "555" in phone number.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. var filter = new MobileCRM.FetchXml.Filter();
  4. filter.contains("telephone1", "555");
  5. entity.filter = filter;

MobileCRM.FetchXml.Filter.isIn Method

Adds a attribute inclusion condition to the filter.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
valuesArrayAn array of values.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.

Example 1

Following example creates the fetch entity for account with filter on entities with address in Boston and Redmond.

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. var filter = new MobileCRM.FetchXml.Filter();
  4. filter.isIn("address1_city", ["Boston", "Redmond"]);
  5. entity.filter = filter;

MobileCRM.FetchXml.Filter.notIn Method

Adds a attribute inclusion condition to the filter.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
valuesArrayAn array of values.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.


MobileCRM.FetchXml.Filter.startsWith Method

Adds a condition that the passed column value contains the passed string.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
valueStringThe value to compare to.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.

Example 1

Following example creates the fetch entity for account with filter on entities starting with letter "a".

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. var filter = new MobileCRM.FetchXml.Filter();
  4. filter.startsWith("name", "a");
  5. entity.filter = filter;

MobileCRM.FetchXml.Filter.where Method

Adds a attribute condition to the filter.

Arguments

ArgumentTypeDescription
attributeStringThe attribute name (CRM logical field name).
opStringThe condition operator. "eq", "ne", "lt", "le", "gt", "ge", "like"
valueDepends on attribute typeThe values to compare to.

Return value

Type: MobileCRM.FetchXml.Condition

The condition instance.

Example 1

Following example creates the fetch entity for account with filter on entities starting with letter "a".

  1. var entity = new MobileCRM.FetchXml.Entity("account");
  2. entity.addAttributes();
  3. var filter = new MobileCRM.FetchXml.Filter();
  4. filter.where("name", "like", "a%");
  5. entity.filter = filter;

MobileCRM.FetchXml.LinkEntity Object

Represents a FetchXml query linked entity.

This object is derived from MobileCRM.FetchXml.Entity

Properties

PropertyTypeDescription
aliasStringA link alias.
fromStringThe "from" field (if parent then target entity primary key).
linkTypeStringThe link (join) type ("inner" or "outer").
toStringThe "to" field.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.FetchXml.LinkEntity object.

MobileCRM.FetchXml.LinkEntity.constructor Method

Constructs an instance of MobileCRM.FetchXml.LinkEntity object.

Arguments

ArgumentTypeDescription
nameStringAn entity name

MobileCRM.FetchXml.Order Object

Represents a FetchXml order statement.

Properties

PropertyTypeDescription
aliasStringDefines an order alias.
attributeStringAn attribute name (CRM logical field name).
descendingBooleantrue, for descending order; false, for ascending order.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.FetchXml.Order object.

MobileCRM.FetchXml.Order.constructor Method

Constructs an instance of MobileCRM.FetchXml.Order object.

Arguments

ArgumentTypeDescription
attributeStringAn attribute name (CRM logical field name).
descendingBooleantrue, for descending order; false, for ascending order

MobileCRM.UI Namespace

Contains a set of objects implementing the Javascript equivalent of the MobileCRM application UI components.

Objects

ObjectDescription
EntityFormRepresents the Javascript equivalent of native entity form object.
EntityList[v9.2] Represents the Javascript equivalent of native entity list object.
EntityListCellActionEnumeration class holding constants for MobileCRM.UI.EntityListClickEvent.
EntityListClickContextRepresents a context for the MobileCRM.UI.EntityList.onClick handler.
EntityListClickEventRepresents an event object for MobileCRM.UI.EntityListClickContext.
Form[v8.0] Represents the Javascript equivalent of the form object.
FormManagerA static object with functions allowing to open the entity forms.
HomeForm[v8.0] Represents the Javascript equivalent of the home form object which contains the Home/UI replacement iFrame.
IFrameForm[v9.0] Represents the iFrame form object.
ListDataSourceThe data source loading routine implementation.
LookupFormThis object allows user to select an entity from a configurable list of entity types.
MediaTabRepresents the MediaTab controller.
MessageBoxThis object allows the user to show a popup window and choose one of the actions.
MultiLookupForm[v9.3] This object allows user to select a list of entities from a configurable list of entity types. Derived from LookupForm so you can use the addView() and addEntityFilter() methods.
ProcessController[v8.2] Represents the Javascript equivalent of view process controller.
QuestionnaireForm[v10.3] Represents the Javascript equivalent of native questionnaire form object.
ReportForm[v8.1] Represents the Dynamics CRM report form object.
TourplanFormRepresents the Javascript equivalent tourplan form object.
TourplanViewModeEnumeration class holding constants for MobileCRM.UI.TourplanForm.
ViewControllerRepresents the Javascript equivalent of view controller (map/web content).
ViewDefinitionRepresents the entity view definition.
_AppointmentViewRepresents the Javascript equivalent view of tourplan form object.
_ControllerRepresents the Javascript equivalent of the view controller object.
_DetailItemRepresents the Javascript equivalent of detail item which is controlling the field editing.
_DetailViewRepresents the Javascript equivalent of detail view with set of items responsible for fields editing.
_EntityListRepresents the Javascript equivalent of the entity list controller object.
_ListViewRepresents the Javascript equivalent of the list view (control) object.
_ViewRepresents the Javascript equivalent of the view (control) object.

MobileCRM.UI.EntityForm Object

Represents the Javascript equivalent of native entity form object.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.UI.EntityForm.requestObject function.

Properties

PropertyTypeDescription
associatedViewsArrayGets the associated views as an array of MobileCRM.UI._EntityList objects.
canEditBooleanGets whether the form can be edited.
canCloseBooleanDetermines if form can be closed, i.e. there are no unsaved data being edited.
contextObjectGets the specific context object for onChange and onSave handlers. The onChange context contains single property "changedItem" with the name of the changed detail item and the onSave context contains property "errorMessage" which can be used to break the save process with certain error message.
controllersArrayGets the form controllers (map, web) as an array of MobileCRM.UI._Controller objects.
detailViewsArrayGets the detailView controls as an array of MobileCRM.UI._DetailView objects.
entityMobileCRM.DynamicEntityGets or sets the entity instance the form is showing.
formMobileCRM.UI.FormGets the top level form.
iFrameOptionsObjectCarries the custom parameters that can be specified when opening the form using MobileCRM.UI.FormManager.
isDirtyBooleanIndicates whether the form has unsaved data.
relationshipMobileCRM.RelationshipDefines relationship with parent entity.
visibleBooleanGets whether the underlying form is visible.

Methods

MethodDescription
cancelValidationStops the onSave validation and optionally causes an error message to be displayed.
getControllerReturns the tab controller by its view name.
getDetailViewReturns the DetailView by its name.
getMediaTabGets the MediaTab object representing the media tab with given name.
reactivateEntityReactivates inactive entity and reloads the form.
selectTab[v8.0] Selects the form tab by its name.
selectViewSelects the associated entity list view by its name.
setTabVisibilitySets the visibility of the form tab defined by its name.
suspendPostSave[v8.2] Suspends current "onPostSave" operations and allows performing another asynchronous tasks before the form is closed.
suspendSaveSuspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result
updateAddressFieldsSets the address fields according to the current geo-location from platform-specific location service.

Functions

FunctionDescription
closeWithoutSavingCloses the form ignoring all changes that have been made on it.
enableCommandEnables or disables the form command.
executeCommandByName[v8.1] Execute the command with the passed name. The command must exist and must be enabled.
isViewMaximized[v8.1] Inspects whether the passed view is maximized or restored.
loadTab[v10.1] (Re)loads the tab of the passed name.
maximizeView[v8.1] Makes the passed view maximized/restored.
onCanExecuteCommandBinds or unbinds the handler called when the EntityForm needs to find out whether the command can be executed (is enabled).
onChangeBinds or unbinds the handler for onChange event on EntityForm.
onCommandBinds or unbinds the handler for EntityForm command.
onItemChange[v11.2] Binds or unbinds the handler for specific item change event on EntityForm.
onPostSave[v8.2] Binds or unbinds the handler for onPostSave event on EntityForm.
onSaveBinds or unbinds the handler for onSave event on EntityForm.
onSelectedViewChanged[v9.3] Binds or unbinds the handler for onSelectedViewChanged event on EntityForm.
openSalesEntityDetail[v8.2] Shows an entity edit dialog.
refreshFormReloads the form's edit state.
requestObjectRequests the managed EntityForm object.
save[v9.0]Saves the form entity and its children and refreshes the form.
saveAndCloseSaves edited entity and closes the form.
selectTabEx[v8.0] Selects the form tab by its name.
showPleaseWaitShows a please wait message, disabling the form except for the close command.

Objects

ObjectDescription
DetailCollectionProvides functions accessing the collection of the sales entity details (e.g. Order details)

MobileCRM.UI.EntityForm.cancelValidation Method

Stops the onSave validation and optionally causes an error message to be displayed.

Arguments

ArgumentTypeDescription
errorMsgStringAn error message to be displayed or "null" to cancel the validation without message.

Example 1

This example demonstrates how to cancel the validation during the on onSave event.

  1. MobileCRM.UI.EntityForm.onSave(
  2. function (entityForm) {
  3. var addressDetail = entityForm.getDetailView("Address");
  4. var addrItem = addressDetail.getItemByName("address1_line1");
  5. if (!addrItem.value) {
  6. // use cancelValidation method and set the error message to be displayed
  7. // or pass "null" to cancel the validation without any message.
  8. entityForm.cancelValidation("Street 1 line is empty.");
  9. // Return false to ignore all changes
  10. return false;
  11. }
  12. },
  13. true,
  14. null
  15. );

MobileCRM.UI.EntityForm.getController Method

Returns the tab controller by its view name.

Arguments

ArgumentTypeDescription
nameStringA name of controller's view.

Return value

Type: MobileCRM.UI._Controller

A MobileCRM.UI._Controller object with requested view name.

Example 1

This example demonstrates how to get the controller on edit form by its view name.

  1. function getController() {
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  5. var iframeController = entityForm.getController("iFrame");
  6. },
  7. MobileCRM.bridge.alert
  8. );
  9. }

MobileCRM.UI.EntityForm.getDetailView Method

Returns the DetailView by its name.

Arguments

ArgumentTypeDescription
nameStringA name of DetailView.

Return value

Type: MobileCRM.UI._DetailView

A MobileCRM.UI._DetailView object with requested name.

Example 1

This example demonstrates how to get the DetailView on edit form by its name.

  1. function getController() {
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  5. var generalView = entityForm.getDetailView("General");
  6. },
  7. MobileCRM.bridge.alert
  8. );
  9. }

MobileCRM.UI.EntityForm.getMediaTab Method

Gets the MediaTab object representing the media tab with given name.

Return value

Type: MobileCRM.UI.MediaTab

A MobileCRM.UI.MediaTab object representing the media tab, or "null", if the tab was not found.

Example 1

This example demonstrates how to work with media tab if media tab exist on form.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. // bind media tab operations handlers to button onclick event.
  6. document.getElementById("capturePhoto").onclick = function () {
  7. media.capturePhoto();
  8. }
  9. document.getElementById("selectPhoto").onclick = function () {
  10. media.selectPhoto();
  11. }
  12. document.getElementById("selectFile").onclick = function () {
  13. media.selectFile();
  14. }
  15. document.getElementById("recordAudio").onclick = function () {
  16. media.recordAudio();
  17. }
  18. document.getElementById("recordVideo").onclick = function () {
  19. media.recordVideo();
  20. }
  21. },
  22. MobileCRM.bridge.alert
  23. );

MobileCRM.UI.EntityForm.reactivateEntity Method

Reactivates inactive entity and reloads the form.

Arguments

ArgumentTypeDescription
statuscodeNumberActivation status code.

Example 1

This example demonstrate how to reactivate inactive entity and reloads the form.

  1. MobileCRM.UI.EntityForm.requestObject(function(entityForm){
  2. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  3. if (entityForm.entity.properties.statecode == 1) // check whether entity is inactive
  4. entityForm.reactivateEntity(new Number(1)); // contact status code.
  5. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityForm.selectTab Method

[v8.0] Selects the form tab by its name.

Arguments

ArgumentTypeDescription
tabNameStringThe name of the tab.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

Example 1

This example demonstrates how to select the associated contacts tab on the account entity form.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. entityForm.selectTab(
  4. // The name of the associated contacts tab consists of the entity logical name,
  5. // the lookup field name and the source entity name.
  6. "contact.parentcustomerid.account",
  7. MobileCRM.bridge.alert
  8. );
  9. },
  10. MobileCRM.bridge.alert,
  11. null
  12. );

MobileCRM.UI.EntityForm.selectView Method

Selects the associated entity list view by its name.

Arguments

ArgumentTypeDescription
tabNameStringThe name of the associated entity list tab.
viewNameStringThe view name.

Return value

Type: Boolean

true, if the view selection was initiated; false, if tab was not found.

Example 1

This example demonstrates how to obtain MobileCRM.UI.EntityForm object. It will select the tab with associated contact list and set the view by name

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. entityForm.selectView("contact.parentcustomerid.account", "View name");
  4. },
  5. MobileCRM.bridge.alert,
  6. null
  7. );

MobileCRM.UI.EntityForm.setTabVisibility Method

Sets the visibility of the form tab defined by its name.

Arguments

ArgumentTypeDescription
tabNameStringThe name of the tab
visibleBooleanDefines desired visibility state.

Return value

Type: Boolean

true, if the visibility change was initiated; false, if tab was not found.

Example 1

This example demonstrates how to set visibility for General tab on entity form.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // The name of the tab, and true to show or false to hide
  4. entityForm.setTabVisibility("General", true);
  5. },
  6. MobileCRM.bridge.alert,
  7. null
  8. );

MobileCRM.UI.EntityForm.suspendPostSave Method

[v8.2] Suspends current "onPostSave" operations and allows performing another asynchronous tasks before the form is closed.

Return value

Type: Object

A request object with single method "resumePostSave" which has to be called to resume the post-save operations.


MobileCRM.UI.EntityForm.suspendSave Method

Suspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result

Return value

Type: Object

A request object with single method "resumeSave" which has to be called with the validation result (either error message string or "null" in case of success). To cancel the validation without any message, pass "#NoMessage#" text to this method.

Example 1

This example demonstrates how to perform the asynchronous validation in "onSave" handler. This code suspends the validation and fetches the list of associated contacts. Then it resumes the validation and shows an error if no Contact is associated with currently edited Account.

  1. MobileCRM.UI.EntityForm.onSave(onSaveValidation, true, null);
  2.  
  3. function onSaveValidation(entityForm) {
  4. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  5. var editedAccount = entityForm.entity;
  6. var saveHandler = entityForm.suspendSave();
  7.  
  8. var fetchEntity = new MobileCRM.FetchXml.Entity("contact");
  9. fetchEntity.addAttribute("contactid");
  10. var filter = new MobileCRM.FetchXml.Filter();
  11. filter.where("parentcustomerid", "eq", editedAccount.id);
  12. fetchEntity.filter = filter;
  13. var fetch = new MobileCRM.FetchXml.Fetch(fetchEntity);
  14. fetch.execute(
  15. null, // Take the results as an array of arrays with field values
  16. function (result) {
  17. /// <param name="result" type="Array"/>
  18. if (result && result.length)
  19. saveHandler.resumeSave();
  20. else
  21. saveHandler.resumeSave("At least one contact is required");
  22. },
  23. function (error) {
  24. saveHandler.resumeSave("Contact fetch error: " + error);
  25. }
  26. );
  27. }

MobileCRM.UI.EntityForm.updateAddressFields Method

Sets the address fields according to the current geo-location from platform-specific location service.

Arguments

ArgumentTypeDescription
latitudeNumberThe latitude from geo-location from platform-specific location service
longitudeNumberlongitude from geo-location from platform-specific location service

Example 1

This example demonstrates how to obtain MobileCRM.UI.EntityForm object. Then use the MobileCRM.Platform and getLocation method to receive latitude and longitude what update the address fields.

  1. MobileCRM.Platform.getLocation(
  2. function (res) {
  3. if (res.latitude && res.longitude) {
  4. MobileCRM.UI.EntityForm.requestObject(
  5. function (entityForm) {
  6. entityForm.updateAddressFields(res.latitude, res.longitude);
  7. },
  8. MobileCRM.bridge.alert
  9. );
  10. }
  11. },
  12. MobileCRM.bridge.alert
  13. );

MobileCRM.UI.EntityForm.closeWithoutSaving Function

Closes the form ignoring all changes that have been made on it.


MobileCRM.UI.EntityForm.enableCommand Function

Enables or disables the form command.

Arguments

ArgumentTypeDescription
commandStringThe name of the command.
enableBooleanDetermines whether to enable or disable the command.
iParamNumber[v9.1] Optional parameter defining the additional command parameter (like status code value for "ChangeStatus" command).

Example 1

This example demonstrates how to enable/disable a custom command by name appended to the entity form via Woodford.

  1. MobileCRM.UI.EntityForm.enableCommand("custom_MyCommand", false);

Example 2

This example demonstrates how to enable/disable specific status command - in our case it disables the "Disqualified - Cannot Contact" status on Lead form.

  1. MobileCRM.UI.EntityForm.enableCommand("ChangeStatus", false, 5); // The value "5" is the status code for "Disqualified - Cannot Contact" status on Lead entity

MobileCRM.UI.EntityForm.executeCommandByName Function

[v8.1] Execute the command with the passed name. The command must exist and must be enabled.

Arguments

ArgumentTypeDescription
commandStringThe name of the EntityForm command.
callbackfunction(entityForm)The callback function that is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to execute command defined by its name. This function executes the default 'Qualify' command on the Lead entity edit form.

  1. function onQualifyLead() {
  2. MobileCRM.UI.EntityForm.executeCommandByName(
  3. "Qualify",
  4. function (entityForm) {
  5. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  6. },
  7. MobileCRM.bridge.alert
  8. );
  9. }

MobileCRM.UI.EntityForm.isViewMaximized Function

[v8.1] Inspects whether the passed view is maximized or restored.

Arguments

ArgumentTypeDescription
viewNameStringThe name of the view which has to be maximized/restored.
callbackfunction(Boolean)Asynchronous callback which is called with Boolean result: true, if the view is maximized; false, if it is restored.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.EntityForm.loadTab Function

[v10.1] (Re)loads the tab of the passed name.

Arguments

ArgumentTypeDescription
tabNameStringThe name of the tab.
loadBooleanWhether to (re)load or unload a view.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

MobileCRM.UI.EntityForm.maximizeView Function

[v8.1] Makes the passed view maximized/restored.

Arguments

ArgumentTypeDescription
viewNameStringThe name of the view which has to be maximized/restored.
maximizeBooleantrue, to maximize the view; false, to restore it.

Example 1

This options works only if the flexi form is enabled (new UI). This example demonstrates how to make sure that the view is maximized.

  1. var viewName = "MyView";
  2. MobileCRM.UI.EntityForm.isViewMaximized(
  3. viewName,
  4. function (isMaximized) {
  5. if (!isMaximized)
  6. MobileCRM.UI.EntityForm.maximizeView(viewName, true);
  7. },
  8. MobileCRM.bridge.alert
  9. );

MobileCRM.UI.EntityForm.onCanExecuteCommand Function

Binds or unbinds the handler called when the EntityForm needs to find out whether the command can be executed (is enabled).

Arguments

ArgumentTypeDescription
commandStringThe name of the EntityForm command. Optionally can contain the param value separated by slash (e.g. ChangeStatus/5).
handlerfunction(entityForm)The handler function that has to be bound or unbound. Handler's return value indicates whether the command is enabled (true/false).
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to control the visibility of the custom command "Scanner". It can be used for any product entity having the field "productnumber" empty. The custom command can be added onto the form via Woodford or Resco CRM.

  1. MobileCRM.UI.EntityForm.onCanExecuteCommand("custom_Scanner", function (entityForm) {
  2. var entity = entityForm.entity;
  3. return !entity.properties["productnumber"];
  4. }, true);

Example 2

This example demonstrates how to control the visibility of the command with parameter. In our case it is standard "ChangeStatus" command on the Lead form. Following code disables this command for specific status "Disqualified - Cannot Contact".

  1. MobileCRM.UI.EntityForm.onCanExecuteCommand(
  2. "ChangeStatus/5", // The value "5" is the status code for "Disqualified - Cannot Contact" status on Lead entity
  3. function (entityForm) {
  4. return false;
  5. },
  6. true
  7. );

MobileCRM.UI.EntityForm.onChange Function

Binds or unbinds the handler for onChange event on EntityForm.

Arguments

ArgumentTypeDescription
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to set an "onChange" handler to monitor changes on MobileCRM.UI.EntityForm object. It reacts on changes to "firstname" and "lastname" detail items and sets the "fullname" on edited entity

  1. MobileCRM.UI.EntityForm.onChange(
  2. function (entityForm) {
  3. // First check whether the change handler is called due to desired item change
  4. var changedItem = entityForm.context.changedItem;
  5. if (changedItem == "firstname" || changedItem == "lastname") {
  6. // Get desired DetailView and its items
  7. var detailView = entityForm.getDetailView("General");
  8. var firstNameItem = detailView.getItemByName("firstname");
  9. var lastNameItem = detailView.getItemByName("lastname");
  10. // Now get edited entity and set its property to the combination of detail items values
  11. var editedEntity = entityForm.entity;
  12. editedEntity.properties.fullname = firstNameItem.value + " " + lastNameItem.value;
  13. }
  14. },
  15. true,
  16. null
  17. );

MobileCRM.UI.EntityForm.onCommand Function

Binds or unbinds the handler for EntityForm command.

Arguments

ArgumentTypeDescription
commandStringThe name of the EntityForm command.
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to handle custom command "Scanner" to start the barcode scanner and store the result into currently edited "product" entity. The custom command can be added on the form via Woodford/Resco CRM.

  1. MobileCRM.UI.EntityForm.onCommand(
  2. "custom_Scanner",
  3. function (entityForm) {
  4. var entity = entityForm.entity;
  5. MobileCRM.Platform.scanBarCode(
  6. function (res) {
  7. if (!res || res.length <= 0) {
  8. sayError("No barcode");
  9. }
  10. else {
  11. storeBarCode(res[0]);
  12. }
  13. },
  14. function (err) { sayError(err); }
  15. );
  16. },
  17. true
  18. );
  19.  
  20. function storeBarCode(code) {
  21. MobileCRM.UI.EntityForm.requestObject(
  22. function (entityForm) {
  23. entityForm.entity.properties["productnumber"] = code;
  24. },
  25. function (err) { sayError(err); }
  26. );
  27. }

MobileCRM.UI.EntityForm.onItemChange Function

[v11.2] Binds or unbinds the handler for specific item change event on EntityForm.

Arguments

ArgumentTypeDescription
itemNameStringThe name of desired detail item (mostly logical name of the field).
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.EntityForm.onPostSave Function

[v8.2] Binds or unbinds the handler for onPostSave event on EntityForm.

Arguments

ArgumentTypeDescription
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to use Post Save method while the online mode is running. You are able to create children for parent entity while your parent doesn't exist yet.

  1. MobileCRM.UI.EntityForm.onPostSave(
  2. function (entityForm) {
  3. /// register event.
  4. var entity = entityForm.entity;
  5. var account = new MobileCRM.Reference(entity.entityName, entity.id, entity.primaryName);
  6. var postSuspend = entityForm.suspendPostSave();
  7. /// create associated contact.
  8. var contact = new MobileCRM.DynamicEntity.createNew("contact");
  9. contact.properties.lastname = "_child of " + account.primaryName;
  10. contact.properties.parentcustomerid = account;
  11. contact.save(
  12. function (err) {
  13. if (err)
  14. MobileCRM.bridge.alert(err);
  15. else {
  16. postSuspend.resumePostSave();
  17. }
  18. }
  19. );
  20. },
  21. true,
  22. MobileCRM.bridge.alert
  23. );

MobileCRM.UI.EntityForm.onSave Function

Binds or unbinds the handler for onSave event on EntityForm.

Arguments

ArgumentTypeDescription
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to set an "onSave" handler to perform a validation before saving edited value on entity form. It will cancel the validation and sets the error message if the address is incomplete.

  1. MobileCRM.UI.EntityForm.onSave(
  2. function (entityForm) {
  3. var addressDetail = entityForm.getDetailView("Address");
  4. var addrItem = addressDetail.getItemByName("address1_line1");
  5. if (!addrItem.value || addrItem.value.length == 0) {
  6. // Set the error message on detail item
  7. addrItem.errorMessage = "Street 1 line is empty.";
  8. // select second tab (zero-based)
  9. entityForm.form.selectedViewIndex = 1;
  10. entityForm.context.errorMessage = addrItem.errorMessage;
  11. // Return true to apply changed values
  12. return true;
  13. }
  14. // Return false to ignore all changes
  15. return false;
  16. },
  17. true,
  18. null
  19. );

MobileCRM.UI.EntityForm.onSelectedViewChanged Function

[v9.3] Binds or unbinds the handler for onSelectedViewChanged event on EntityForm.

Bound handler is called with the EntityForm object as an argument. The EntityForm context object contains "selectedView" property with the name of currently selected view.

Arguments

ArgumentTypeDescription
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to handle the tab (view) selection. It disables the address items when the Address tab is selected on Contact entity form having the parent customer defined.

  1. MobileCRM.UI.EntityForm.onSelectedViewChanged(function (entityForm) {
  2. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  3. if (entityForm.context.selectedView == "Address") {
  4. var entity = entityForm.entity;
  5. var dv = entityForm.getDetailView("Address");
  6. var bEnable = !entity.properties.parentcustomerid;
  7. dv.getItemByName("address1_line1").isEnabled = bEnable;
  8. dv.getItemByName("address1_city").isEnabled = bEnable;
  9. }
  10. }, true, null);

MobileCRM.UI.EntityForm.openSalesEntityDetail Function

[v8.2] Shows an entity edit dialog.

Arguments

ArgumentTypeDescription
detailMobileCRM.DynamicEntitydetail entity.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.

Example 1

This example demonstrates how to open a sales entity detail form (like OrderDetail or InvoiceDetail).

  1. function getDetails() {
  2. MobileCRM.UI.EntityForm.DetailCollection.getAll(function (details) {
  3. /// <param name='details' type='Array'/>
  4. var len = details.length;
  5. if (len <= 0)
  6. return;
  7. // Open the form for the first sales entity detail (e.g. the first OrderDetail)
  8. openDetail(details[0]);
  9. }, MobileCRM.bridge.alert, null);
  10. }
  11.  
  12. function openDetail(detail) {
  13. /// <param name='detail' type='MobileCRM.DynamicEntity'/>
  14. /// open sales order detail
  15. var order = detail.properties.salesorderid;
  16. var relationShip = new MobileCRM.Relationship("salesorderid", order, null, null);
  17. MobileCRM.UI.EntityForm.openSalesEntityDetail(detail, relationShip);
  18. }

MobileCRM.UI.EntityForm.refreshForm Function

Reloads the form's edit state.

Example 1

This example demonstrates how to reload form's edit state.

  1. MobileCRM.UI.EntityForm.refreshForm();

MobileCRM.UI.EntityForm.requestObject Function

Requests the managed EntityForm object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of EntityForm object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(entityForm)The callback function that is called asynchronously with serialized EntityForm object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to obtain and modify MobileCRM.UI.EntityForm object. It sets the form caption to the primary name of currently edited entity

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  4. // Get the MobileCRM.DynamicEntity which is being edited on this form
  5. var entity = entityForm.entity;
  6. // Get the form control object
  7. var form = entityForm.form;
  8. // Set the form caption to the primary name of currently edited entity
  9. form.caption = entity.primaryName;
  10. // Return true to apply changed value.
  11. return true;
  12. },
  13. function (err) {
  14. MobileCRM.bridge.alert("An error occurred: " + err);
  15. },
  16. null
  17. );

MobileCRM.UI.EntityForm.save Function

[v9.0]Saves the form entity and its children and refreshes the form.


MobileCRM.UI.EntityForm.saveAndClose Function

Saves edited entity and closes the form.

Example 1

This example demonstrate how to call save and close command while you are on form

  1. function saveAndCloseForm() {
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  5. if (entityForm)
  6. MobileCRM.UI.EntityForm.saveAndClose();
  7. },
  8. function (err) {
  9. MobileCRM.bridge.alert("An error occurred: " + err);
  10. },
  11. null
  12. );
  13. }

MobileCRM.UI.EntityForm.selectTabEx Function

[v8.0] Selects the form tab by its name.

Arguments

ArgumentTypeDescription
tabNameStringThe name of the tab.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

Example 1

This example demonstrates how to select the associated contacts tab on the account entity form without requesting its object.

  1. MobileCRM.UI.EntityForm.selectTabEx("contact.parentcustomerid.account", MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityForm.showPleaseWait Function

Shows a please wait message, disabling the form except for the close command.

Arguments

ArgumentTypeDescription
captionStringWait message.

Return value

Type: Object

An object representing the UI component with single method "close".

Example 1

This example demonstrates how to use the "Please Wait" window while performing the asynchronous operation.

  1. /// Try to get the device's geo coordinates and show please wait window while the operation is in progress.
  2. function getGPSCoords() {
  3. var wait = MobileCRM.UI.EntityForm.showPleaseWait("Getting the GPS coordinates...");
  4. MobileCRM.Platform.getLocation(
  5. function (coords) {
  6. wait.close();
  7. if (coords.latitude && coords.longitude)
  8. MobileCRM.bridge.alert("latitude : " + coords.latitude + " longitude : " + coords.longitude);
  9. },
  10. function (err) {
  11. wait.close();
  12. MobileCRM.bridge.alert(err);
  13. }
  14. );
  15. }

MobileCRM.UI.EntityForm.DetailCollection Object

Provides functions accessing the collection of the sales entity details (e.g. Order details)

Functions

FunctionDescription
addAppends the product into sales order collection.
addAsync[v10.0] Appends the product into sales order collection.
addProductWithQuantity[v10.0] Appends the product into sales order collection.
deleteByIdDeletes the sales entity detail (e.g. Order detail) by id.
deleteByIndexDeletes the sales entity detail (e.g. Order detail) by index.
getAsynchronously returns requested sales entity detail (e.g. Order detail)
getAllAsynchronously returns the collection of the sales entity details (e.g. Order details)
getAllAsyncAsynchronously returns the collection of the sales entity details (e.g. Order details)
getAsyncAsynchronously returns requested sales entity detail (e.g. Order detail)
onChange[v8.2] Binds or unbinds the handler which is called when the list of sales details changes.

MobileCRM.UI.EntityForm.DetailCollection.add Function

Appends the product into sales order collection.

Resulting MobileCRM.DynamicEntity object implements method "update" which can be used to update the entity properties in the sales detail collection.

Arguments

ArgumentTypeDescription
productMobileCRM.ReferenceA reference of the product to be appended.
callbackfunction(MobileCRM.DynamicEntity)The callback function which is called asynchronously with MobileCRM.DynamicEntity object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to add a new product into order details.

  1. function addNewProduct(productId, quantity) {
  2. var productRef = new MobileCRM.Reference("product", productId);
  3. MobileCRM.UI.EntityForm.DetailCollection.add(
  4. productRef,
  5. function (orderDetail) {
  6. /// <param name="orderDetail" type="MobileCRM.DynamicEntity"/>
  7. orderDetail.properties["quantity"] = quantity;
  8. orderDetail.update(
  9. function (err) {
  10. if (err)
  11. MobileCRM.bridge.alert(err);
  12. else
  13. MobileCRM.bridge.alert("Product added");
  14. });
  15. },
  16. MobileCRM.bridge.alert
  17. );
  18. }

MobileCRM.UI.EntityForm.DetailCollection.addAsync Function

[v10.0] Appends the product into sales order collection.

Resulting MobileCRM.DynamicEntity object implements method "update" which can be used to update the entity properties in the sales detail collection.

Arguments

ArgumentTypeDescription
productMobileCRM.ReferenceA reference of the product to be appended.
quantityNumberProduct quantity.

Return value

Type: Promise<MobileCRM.DynamicEntity>

A Promise object which will be resolved with the DynamicEntity object representing new sales entity detail record.

Example 1

This example demonstrates how to add a new product with given quantity into order details.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function addNewProduct(productId, quantity) {
  4. try {
  5. var productRef = new MobileCRM.Reference("product", productId);
  6. var orderDetail = await MobileCRM.UI.EntityForm.DetailCollection.addAsync(productRef, quantity);
  7. MobileCRM.bridge.alert("Product added");
  8. }
  9. catch (err) {
  10. MobileCRM.bridge.alert(err);
  11. }
  12. }

MobileCRM.UI.EntityForm.DetailCollection.addProductWithQuantity Function

[v10.0] Appends the product into sales order collection.

Resulting MobileCRM.DynamicEntity object implements method "update" which can be used to update the entity properties in the sales detail collection.

Arguments

ArgumentTypeDescription
productMobileCRM.ReferenceA reference of the product to be appended.
quantityNumberProduct quantity.
callbackfunction(MobileCRM.DynamicEntity)The callback function which is called asynchronously with MobileCRM.DynamicEntity object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to add a new product with quantity 2 into order detail.

  1. function addNewProduct() {
  2. var product = new MobileCRM.FetchXml.Entity("product");
  3. product.addAttributes();
  4.  
  5. var fetch = new MobileCRM.FetchXml.Fetch(product, 1); // only one product will be fetched.
  6. fetch.execute("DynamicEntities", function (res) {
  7. var productReference = new MobileCRM.Reference(res[0].entityName, res[0].id, res[0].primaryName);
  8. // add product to detail collection.
  9. MobileCRM.UI.EntityForm.DetailCollection.addProductWithQuantity(
  10. productReference,
  11. 2,
  12. function (orderDetail) {
  13. /// <param name="orderDetail" type="MobileCRM.DynamicEntity"/>
  14. // in success callback of function.
  15. // order detail will be updated automatically.
  16. // display info about current order detail
  17. MobileCRM.bridge.alert(JSON.stringify(orderDetail));
  18. },
  19. MobileCRM.bridge.alert // Alert an error (if any)
  20. );
  21. }, MobileCRM.bridge.alert, null);
  22. }

MobileCRM.UI.EntityForm.DetailCollection.deleteById Function

Deletes the sales entity detail (e.g. Order detail) by id.

Arguments

ArgumentTypeDescription
idStringAn id of the item to be deleted.
callbackFunctionThe callback function which is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to delete first existing product on order detail.

  1. function deleteProduct() {
  2. // retrieve first product if exist from order detail
  3. MobileCRM.UI.EntityForm.DetailCollection.getAll(
  4. function (details) {
  5. /// <param name="details" type="Array<MobileCRM.DynamicEntity>"/>
  6. if (details.length) {
  7. var product = details[0];
  8. MobileCRM.UI.EntityForm.DetailCollection.deleteById(
  9. product.id,
  10. function () {
  11. MobileCRM.bridge.alert("Product " + product.properties.productdescription + " successfully deleted.");
  12. },
  13. MobileCRM.bridge.alert
  14. );
  15. }
  16. else
  17. MobileCRM.bridge.alert("Order doesn't contain any product.");
  18. },
  19. MobileCRM.bridge.alert
  20. );
  21. }

MobileCRM.UI.EntityForm.DetailCollection.deleteByIndex Function

Deletes the sales entity detail (e.g. Order detail) by index.

Arguments

ArgumentTypeDescription
indexNumberAn index of the item to be deleted.
callbackFunctionThe callback function which is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to delete a sales entity detail (e.g. OrderDetail) by index.

  1. function deleteByIndex(index) {
  2. MobileCRM.UI.EntityForm.DetailCollection.getAll(
  3. function (details) {
  4. /// <param name="details" type="Array<MobileCRM.DynamicEntity>"/>
  5. if (details[index]) {
  6. var product = details[index];
  7. MobileCRM.UI.EntityForm.DetailCollection.deleteByIndex(
  8. index,
  9. function () {
  10. MobileCRM.bridge.alert("Product " + product.properties.productdescription + " successfully deleted.");
  11. },
  12. MobileCRM.bridge.alert
  13. );
  14. }
  15. else
  16. MobileCRM.bridge.alert("Order doesn't contain any product.");
  17. },
  18. MobileCRM.bridge.alert
  19. );
  20. }

MobileCRM.UI.EntityForm.DetailCollection.get Function

Asynchronously returns requested sales entity detail (e.g. Order detail)

Arguments

ArgumentTypeDescription
indexNumberAn index of requested item.
callbackfunction(MobileCRM.DynamicEntity)The callback function that is called asynchronously with the MobileCRM.DynamicEntity object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to update the order detail quantity.

  1. function increaseQuantity(orderDetailIndex, increment) {
  2. MobileCRM.UI.EntityForm.DetailCollection.get(
  3. orderDetailIndex,
  4. function (detail) {
  5. /// <param name="detail" type="MobileCRM.DynamicEntity"/>
  6. // work with numbers, not strings!
  7. detail.properties["quantity"] = new Number(detail.properties["quantity"]) + new Number(increment);
  8. // Update the SalesOrderDetail entity in order details collection
  9. detail.update();
  10. },
  11. MobileCRM.bridge.alert
  12. );
  13. }

MobileCRM.UI.EntityForm.DetailCollection.getAll Function

Asynchronously returns the collection of the sales entity details (e.g. Order details)

Arguments

ArgumentTypeDescription
callbackfunction(Array)The callback function that is called asynchronously with an array of MobileCRM.DynamicEntity objects as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get the list of order details.

  1. MobileCRM.UI.EntityForm.DetailCollection.getAll(function (orderDetails) {
  2. /// <param name="orderDetails" type="Array"/>
  3. var nDetails = orderDetails.length;
  4. var text = "";
  5. for (var i = 0; i < nDetails; i++) {
  6. var detail = orderDetails[i];
  7. var productName = detail.properties["productid"].primaryName;
  8. var quantity = detail.properties["quantity"];
  9. text += "Product: " + productName + " Quantity: " + quantity + " \n";
  10. }
  11. if (text.length > 0)
  12. MobileCRM.bridge.alert(text);
  13.  
  14. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityForm.DetailCollection.getAllAsync Function

Asynchronously returns the collection of the sales entity details (e.g. Order details)

Return value

Type: Promise<MobileCRM.DynamicEntity[]>

A Promise object which will be resolved with an array of DynamicEntity objects representing the sales entity detail records.

Example 1

This example demonstrates how to get the list of order details.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. try {
  4. var orderDetails = await MobileCRM.UI.EntityForm.DetailCollection.getAllAsync();
  5. var text = orderDetails.map(function(detail){
  6. return "Product: " + detail.properties["productid"].primaryName +
  7. ", Quantity: " + detail.properties["quantity"];
  8. }).join("\n");
  9. if (text.length > 0)
  10. MobileCRM.bridge.alert(text);
  11. }
  12. catch (err) {
  13. MobileCRM.bridge.alert(err);
  14. }

MobileCRM.UI.EntityForm.DetailCollection.getAsync Function

Asynchronously returns requested sales entity detail (e.g. Order detail)

Arguments

ArgumentTypeDescription
indexNumberAn index of requested item.

Return value

Type: Promise<MobileCRM.DynamicEntity>

A Promise object which will be resolved with the DynamicEntity object representing the sales entity detail record.

Example 1

This example demonstrates how to update the order detail quantity.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function increaseQuantity(orderDetailIndex, increment) {
  4. try {
  5. var detail = await MobileCRM.UI.EntityForm.DetailCollection.getAsync(orderDetailIndex);
  6. detail.properties["quantity"] =(+detail.properties["quantity"]) + increment; // work with numbers, not strings!
  7. // Update the SalesOrderDetail entity in order details collection
  8. detail.update();
  9. }
  10. catch (err) {
  11. MobileCRM.bridge.alert(err);
  12. }
  13. }

MobileCRM.UI.EntityForm.DetailCollection.onChange Function

[v8.2] Binds or unbinds the handler which is called when the list of sales details changes.

Arguments

ArgumentTypeDescription
handlerfunction(entityForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to use DetailCollection onChange handler and display the detail form of currently changed product.

  1. MobileCRM.UI.EntityForm.DetailCollection.onChange(
  2. function (entityForm) {
  3. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  4. /// retrieve last added product new index from context
  5. var changedProductIndex = entityForm.context.newIndex;
  6. if (changedProductIndex >= 0) {
  7. MobileCRM.UI.EntityForm.DetailCollection.get(
  8. changedProductIndex,
  9. function (detail) {
  10. /// open actually changed product.
  11. MobileCRM.UI.EntityForm.openSalesEntityDetail(detail, MobileCRM.bridge.alert, null);
  12. },
  13. MobileCRM.bridge.alert
  14. );
  15. }
  16. }, true);

MobileCRM.UI.EntityList Object

[v9.2] Represents the Javascript equivalent of native entity list object.

Properties

PropertyTypeDescription
allowAddExistingBooleanGets or sets whether adding an existing entity is allowed.
allowCreateNewBooleanGets or sets whether create a new entity (or managing the N:N entities in the case of N:N list) is allowed.
allowedDocActionsNumberGets or sets a mask of document actions (for Note and Sharepoint document lists).
allowSearchBooleanGets or sets whether to show the search bar.
autoWideWidthStringGets the view auto width pixel size.
contextObject[v10.0] Gets the specific context object for onChange, onSave and onCommand handlers.

The onSave context contains property "entities" with the list of all changed entities and property "errorMessage" which can be used to cancel the save process with certain error message.

The onChange handler context contains "entities" property with the list of currently changed entities (typically just one entity) and property "propertyName" with the field name that was changed.

Command handler context contains the "cmdParam" property and "entities" property with the list of currently selected entities.

entityNameStringGets the name of the entities in this list.
flipModeNumberGets or sets the flip configuration (which views to show and which one is the initial).
hasMapViewsBooleanGets whether the list has a view that can be displayed on map.
hasCalendarViewsBooleanGets or sets whether there is a view with "CalendarFields".
hasMoreButtonBooleanGets whether the list needs a more button.
internalNameStringGets the internal list name. Used for localization and image lookup.
isDirtyBooleanGets or sets whether the list is dirty.
isLoadedBooleanGets or sets whether the list is loaded.
isMultiSelectBooleanGets whether multi selection is active.
listButtonsArrayGets the read-only array of strings defining the list buttons.
listModeNumberGets the current list mode.
listViewMobileCRM.UI._ListViewGets the controlled listView control.
lookupSourceMobileCRM.RelationshipGets the lookup source. If the list is used for lookup this is the entity whose property is being "looked-up".
optionsNumberGets the kinds of views available on the list.
relationshipMobileCRM.RelationshipGets the relation source and related entity. "null", if there is no relationship (if it is not an associated list).
selectedEntityMobileCRM.DynamicEntityGets currently selected entity. "null", if there's no selection.
uniqueNameNumberGets or sets the unique name of the list. Used to save/load list specific settings.

Methods

MethodDescription
suspendSave[v10.0] Suspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result

Functions

FunctionDescription
clickCell
onChange[v10.0] Binds or unbinds the handler for onChange event on EntityList.
onClick[v10.1] Binds or unbinds the handler for onClick event on EntityList.
onCommandBinds or unbinds the handler for EntityList command.
onSave[v10.0] Binds or unbinds the handler for onSave event on EntityList.
reloadInitiates asynchronous entity list reload.
requestEditedEntities[v10.0] Asynchronously gets the list of entities that were changed on the list.
requestObjectRequests the EntityList object.
runCommandExecutes the list/button command attached to this entity list.
selectViewSelects specified EntityList view.
setDataSourceSets the entity list data source replacement.
setDataSourceFactory[v11.0.2] Sets the entity list data source replacement factory.
setEntityProperty[v10.1] Sets the value of the entity property.
setPrimaryCommandOverrides the entity list's primary command button.
startEditCell

MobileCRM.UI.EntityList.suspendSave Method

[v10.0] Suspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result

Return value

Type: Object

A request object with single method "resumeSave" which has to be called with the validation result (either error message string or "null" in case of success). To cancel the validation without any message, pass "#NoMessage#" text to this method.


MobileCRM.UI.EntityList.clickCell Function

Opens an entity form for lookup content record. Performs appropriate action for cells bound to the phone/email/web formatted fields.

Arguments

ArgumentTypeDescription
rowIndexNumberThe index of the row to click on.
cellIndexNumberThe index of the cell.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

MobileCRM.UI.EntityList.onChange Function

[v10.0] Binds or unbinds the handler for onChange event on EntityList.

Bound handler is called with the EntityList object as an argument. The EntityList context object contains "entities" property with the list of currently changed entities (typically just one entity) and property "propertyName" with the field name that was changed.

Arguments

ArgumentTypeDescription
handlerfunction(entityList)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to set an "onChange" handler to perform the address field validation for editable rows on the entity list.

  1. MobileCRM.UI.EntityList.onChange(function (entityList) {
  2. /// <param name='entityList' type='MobileCRM.UI.EntityList'/>
  3. var context = entityList.context;
  4. if (context.propertyName == "address1_line1") {
  5. var editedEntities = entityList.context.entities;
  6. var props = editedEntities[0].properties;
  7. if (!props.address1_city)
  8. props.address1_city = "Boston";
  9. }
  10. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityList.onClick Function

[v10.1] Binds or unbinds the handler for onClick event on EntityList.

Bound handler is called with the EntityList object as an argument. The EntityList context property contains EntityListClickContext object.

Arguments

ArgumentTypeDescription
handlerfunction(entityList)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to handle a click to a clickable/editable cell on entity list. It works only from iFrame placed on entity view.

  1. MobileCRM.UI.EntityList.onClick(function (entityList) {
  2. /// <param name="entityList" type="MobileCRM.UI.EntityList" />
  3. var context = entityList.context;
  4. var eventInfo = JSON.stringify(context.event);
  5. var entity = context.entities.toString();
  6. var property = context.propertyName;
  7.  
  8. MobileCRM.bridge.alert("Entity: " + entity + " property: " + property + " was clicked.\nEvent info: " + eventInfo);
  9. }, true);

MobileCRM.UI.EntityList.onCommand Function

Binds or unbinds the handler for EntityList command.

Bound handler is called with the EntityList object as an argument. The EntityList context object contains the "cmdParam" property and "entities" property with the list of currently selected entities.

Arguments

ArgumentTypeDescription
commandStringThe name of the EntityList command.
handlerfunction(entityList)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to display the parent account form by pressing the custom contact list button 'OpenAccount'. The custom command can be added on the view via Woodford/Resco CRM.

  1. MobileCRM.UI.EntityList.onCommand("custom_OpenAccount", function (entityList) {
  2. /// <param name='entityList' type='MobileCRM.UI.EntityList'>
  3. var customer = entityList.selectedEntity;
  4. if (customer != undefined) {
  5. MobileCRM.UI.FormManager.showDetailDialog(customer.entityName, customer.id);
  6. }
  7. }, true, null);

MobileCRM.UI.EntityList.onSave Function

[v10.0] Binds or unbinds the handler for onSave event on EntityList.

Bound handler is called with the EntityList object as an argument. The EntityList context object contains "entities" property with the list of all changed entities and property "errorMessage" that can be used to cancel save with an error.

Arguments

ArgumentTypeDescription
handlerfunction(entityList)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrates how to set an "onSave" handler to perform a validation before saving entities edited on the entity list. It will cancel the save process and sets the error message if the fax value is shorter than 4 characters.

  1. MobileCRM.UI.EntityList.onSave(function (entityList) {
  2. /// <param name='entityList' type='MobileCRM.UI.EntityList'/>
  3. var editedEntities = entityList.context.entities;
  4. var saveHandler = entityList.suspendSave();
  5. for (var i in editedEntities) {
  6. var entity = editedEntities[i];
  7. if (entity.properties.fax.length < 3) {
  8. saveHandler.resumeSave("record : " + entity.primaryName + " has short fax");
  9. return;
  10. }
  11. }
  12. saveHandler.resumeSave();
  13. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityList.reload Function

Initiates asynchronous entity list reload.

Example 1

This example demonstrates how to reload the entity list from entity list iFrame.

  1. MobileCRM.UI.EntityList.reload();

MobileCRM.UI.EntityList.requestEditedEntities Function

[v10.0] Asynchronously gets the list of entities that were changed on the list.

Arguments

ArgumentTypeDescription
callbackfunction(DynamicEntity[])Callback obtaining an array of dynamic entities that were changed on the list.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to obtain the list of entities edited on the entity list.

  1. MobileCRM.UI.EntityList.requestEditedEntities(function (editedEntities) {
  2. /// <param name='editedEntities' type='Array'>Array of edited DynamicEntities.<param/>
  3. var editedEntitiesRecord = [];
  4. for (var i in editedEntities) {
  5. editedEntitiesRecord.push(editedEntities[i]);
  6. }
  7. MobileCRM.bridge.alert("Edited entities : " + editedEntitiesRecord.toString());
  8. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityList.requestObject Function

Requests the EntityList object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of EntityList object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(entityList)The callback function that is called asynchronously with serialized EntityList object as argument See MobileCRM.UI.EntityList for further details.. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to obtain and modify MobileCRM.UI.EntityList object. It selects the first list record and runs the first available button command on that record.

  1. MobileCRM.UI.EntityList.requestObject(function (entityList) {
  2. /// <param name='entityList' type='MobileCRM.UI.EntityList'>
  3. var listView = entityList.listView;
  4. // Select the first record.
  5. listView.selectedIndex = 0;
  6. // Take the first button (if any).
  7. var button = entityList.listButtons[0];
  8. if (button){
  9. MobileCRM.bridge.alert("button '" + button + "' was clicked.")
  10. MobileCRM.UI.EntityList.runCommand(button); // Run its command.
  11. }
  12. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityList.runCommand Function

Executes the list/button command attached to this entity list.

Arguments

ArgumentTypeDescription
commandNameStringA name of the command. It can be either custom command or one of following predefined commands:
parameterNumberA command parameter (e.g. the status code value for ChangeStatus command).
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

MobileCRM.UI.EntityList.selectView Function

Selects specified EntityList view.

Arguments

ArgumentTypeDescription
viewNameStringThe name of the entity view which has to be selected.

Example 1

This example demonstrates how to retrieve views for entity and select first different view on the entity list.

  1. MobileCRM.UI.EntityList.requestObject(function (entityList) {
  2. /// <param name='entityList' type='MobileCRM.UI.EntityList'>
  3. var entityName = entityList.entityName;
  4. var currentView = entityList.currentView;
  5. // load another views for entity
  6. MobileCRM.UI.ViewDefinition.loadEntityViews(
  7. entityName,
  8. function (views) {
  9. /// <param name="views" type="Array"/>
  10. if (views != undefined && views.length > 0) {
  11. for (var i in views) {
  12. var viewName = views[i].name;
  13. if (viewName !== currentView) {
  14. MobileCRM.UI.EntityList.selectView(viewName);
  15. return;
  16. }
  17. }
  18. }
  19. },
  20. MobileCRM.bridge.alert,
  21. null
  22. );
  23. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.EntityList.setDataSource Function

Sets the entity list data source replacement.

Data source must be set during the document load stage and must not be delayed.

It is used only if the entity view iFrame is marked as data source provider in Woodford.

Arguments

ArgumentTypeDescription
dataSourceMobileCRM.UI.ListDataSourceA data source object implementing the DynamicEntity list loading routine.

Example 1

This example demonstrates how to provide a custom data source for entity list. It modifies the current entity view fetch and provides the array of DynamicEntity objects that has to be fed into the entity list.

  1. var dataSource = new MobileCRM.UI.ListDataSource();
  2. // loadNextChunk method must be implemented explicitly
  3. dataSource.loadNextChunk = function (page, count) {
  4. var fetch = this.fetch; // Take a fetch provided for current entity view
  5. // Specify explicit page and count requested by application (optional - it's pre-set before this method is called).
  6. fetch.count = count;
  7. fetch.page = page;
  8. if (page == 1) {
  9. // Specify custom filter or link entities.
  10. // Do it just for the first page!
  11. // WARNING: Do not add new attributes to the fetch - they will be ignored.
  12. var filter = new MobileCRM.FetchXml.Filter();
  13. filter.where("parentcustomerid", "not-null");
  14.  
  15. var originalFilter = fetch.entity.filter;
  16. if (originalFilter && originalFilter.conditions.length > 0) {
  17. // Combine new filter with original filter which came from the view definition.
  18. var combinedFilter = new MobileCRM.FetchXml.Filter();
  19. combinedFilter.type = "and";
  20. combinedFilter.filters = [filter, originalFilter];
  21. fetch.entity.filter = combinedFilter;
  22. }
  23. else
  24. fetch.entity.filter = filter; // Set the new filter to fetch entity
  25. }
  26. // Execute fetch asynchronously and force the output type DynamicEntities.
  27. // When the array of DynamicEntity objects is ready, call chunkReady (don't forget to call it in scope of this ListDataSource).
  28. fetch.execute("DynamicEntities", function (entities) {
  29. // This is the final place to manipulate with the array of loaded entities before it is passed to the EntityList.
  30. this.chunkReady(entities); // Callback is called in scope of our dataSource, so we can call it's method chunkReady to pass the data.
  31. }, MobileCRM.bridge.alert, this);
  32. };
  33. MobileCRM.UI.EntityList.setDataSource(dataSource);

MobileCRM.UI.EntityList.setDataSourceFactory Function

[v11.0.2] Sets the entity list data source replacement factory.

Data source must be set during the document load stage and must not be delayed.

It is used only if the entity view iFrame is marked as data source provider in Woodford.

Arguments

ArgumentTypeDescription
dataSourceFactoryFunctionA function that returns an object implementing the DynamicEntity list loading routine.

MobileCRM.UI.EntityList.setEntityProperty Function

[v10.1] Sets the value of the entity property.

Arguments

ArgumentTypeDescription
rowIndexNumberThe index of the entity in the list.
propertyNameStringThe name of the property.
editValueanythe new property value.
saveImmediatelyBooleanIndicates whether to save entity immediately or whether to just make it dirty.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

MobileCRM.UI.EntityList.setPrimaryCommand Function

Overrides the entity list's primary command button.

Arguments

ArgumentTypeDescription
labelsArray/StringAn array of labels or single label (e.g. "New").
callbackFunctionA callback which is called when command is launched.
scopeObjectA scope, in which the callback has to be called.

MobileCRM.UI.EntityList.startEditCell Function

Arguments

ArgumentTypeDescription
rowIndexNumberThe index of the row to edit.
cellIndexNumberThe index of the cell.
saveImmediatelyBooleanIndicates whether to save entity immediately after change or whether to just make it dirty.
bindingNumberOptional, if null the binding from the cell index will be used.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

MobileCRM.UI.EntityListCellAction Object

Enumeration class holding constants for MobileCRM.UI.EntityListClickEvent.

Properties

PropertyTypeDescription
TextNumberCell displaying data bound or constant text.
ImageNumber Cell displaying data bound or constant image.
ButtonNumber Clickable button cell.
InlineButtonNumber The inline button. iOS only.
EditableNumber The cell is editable. Or together with Text kind.
ClickableNumber The cell is clickable. Or together with Text kind.
DirectEditNumber The cell is editable and will be saved right after change. Or together with Text kind.
ActionMaskNumber The cell is editable or clickable.

MobileCRM.UI.EntityListClickContext Object

Represents a context for the MobileCRM.UI.EntityList.onClick handler.

Properties

PropertyTypeDescription
entitiesArraySingle item array containing the DynamicEntity object representing clicked entity.
propertyNameStringThe field name that was clicked within the list item.
eventMobileCRM.UI.EntityListClickEventEvent details.

MobileCRM.UI.EntityListClickEvent Object

Represents an event object for MobileCRM.UI.EntityListClickContext.

Properties

PropertyTypeDescription
cellNumberAn index of the cell in row template.
rowNumberThe row index.
bindingNumberA binding value.
actionNumberClick action flags. Use constant from MobileCRM.UI.EntityListCellAction enumeration.

MobileCRM.UI.Form Object

[v8.0] Represents the Javascript equivalent of the form object.

Properties

PropertyTypeDescription
canMaximizeBooleanGets or sets whether form can be maximized to fullscreen (full application frame).
isMaximizedBooleanGets or sets whether form is currently maximized to fullscreen (full application frame).
captionStringGets or sets the form caption.
selectedViewIndexNumberGets or sets the selected view (tab) index.
showTitleBoolean[v8.1] Determines whether the form caption bar should be visible.
viewCountNumberGets the count of views in the form.
visibleBooleanGets whether the form is visible.

Functions

FunctionDescription
requestObject[v8.0] Requests the currently opened Form object.
showPleaseWaitShows a please wait message, disabling the form except for the close command.
showToastShows a toast window over the app window which is dismissed after a few seconds.

MobileCRM.UI.Form.requestObject Function

[v8.0] Requests the currently opened Form object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of Form object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(form)The callback function that is called asynchronously with serialized Form object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to request MobileCRM.UI.Form object and change caption and maximize.

  1. MobileCRM.UI.Form.requestObject(
  2. function (form) {
  3. /// <param name='form' type='MobileCRM.UI.Form'/>
  4. form.caption = "Custom caption";
  5. if (form.canMaximize)
  6. form.isMaximized = true;
  7. },
  8. MobileCRM.bridge.alert
  9. );

MobileCRM.UI.Form.showPleaseWait Function

Shows a please wait message, disabling the form except for the close command.

Arguments

ArgumentTypeDescription
captionStringWait message.

Return value

Type: Object

An object representing the UI component with single method "close".


MobileCRM.UI.Form.showToast Function

Shows a toast window over the app window which is dismissed after a few seconds.

Arguments

ArgumentTypeDescription
messageStringA toast content message.
iconStringValid app image name (e.g. Home.Now.png).

Example 1

This example demonstrate how to display toast window with text and home icon, which is dismissed after few seconds.

  1. MobileCRM.UI.Form.showToast("MCRM say hello", "Home.Now.png");

MobileCRM.UI.FormManager Object

A static object with functions allowing to open the entity forms.

Functions

FunctionDescription
showDetailDialogShows an entity detail dialog.
showEditDialogShows an entity edit dialog.
showNewDialogShows a new entity dialog.

MobileCRM.UI.FormManager.showDetailDialog Function

Shows an entity detail dialog.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
idStringGUID of the existing entity.
relationshipMobileCRM.RelationShipThe optional relationship with a parent entity.

Example 1

This example demonstrates how to open account detail form.

  1. function openAccountDetail() {
  2. var account = new MobileCRM.FetchXml.Entity("account");
  3. account.addAttribute("accountid");
  4. // only one record will be fetched
  5. var fetch = new MobileCRM.FetchXml.Fetch(account, 1);
  6. fetch.execute(
  7. "Array", // Take the results as an array of arrays with field values
  8. function (res) {
  9. MobileCRM.UI.FormManager.showDetailDialog("account", res[0][0], null);
  10. },
  11. MobileCRM.bridge.alert
  12. );
  13. }

MobileCRM.UI.FormManager.showEditDialog Function

Shows an entity edit dialog.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
idStringGUID of the existing entity or null for new one.
relationshipMobileCRM.RelationShipThe optional relationship with a parent entity.
optionsObjectA JSON object containing a form-specific properties like pre-defined field values, peer iFrame options or document options.

Example 1

This example demonstrates how to open active account detail form.

  1. function openAccountEditDetail() {
  2. var account = new MobileCRM.FetchXml.Entity("account");
  3. account.addAttribute("accountid");
  4. // only active record can have edit form
  5. account.filter = new MobileCRM.FetchXml.Filter();
  6. account.filter.where("statecode", "eq", "0");
  7. // only one record will be fetched
  8. var fetch = new MobileCRM.FetchXml.Fetch(account, 1);
  9. fetch.execute(
  10. "Array", // Take the results as an array of arrays with field values
  11. function (res) {
  12. MobileCRM.UI.FormManager.showEditDialog("account", res[0][0], null);
  13. },
  14. MobileCRM.bridge.alert
  15. );
  16. }

MobileCRM.UI.FormManager.showNewDialog Function

Shows a new entity dialog.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
relationshipMobileCRM.RelationShipThe optional relationship with a parent entity.
optionsObjectA JSON object containing a form-specific properties like pre-defined field values, peer iFrame options or document options.

Example 1

This example demonstrates how to append the new associated contact from Account form. This code opens the new Contact form and pre-fills the parent customer field to currently edited Account.

  1. function addAssociatedContact() {
  2. // Request entity form (currently edited Account form).
  3. MobileCRM.UI.EntityForm.requestObject(
  4. function (entityForm) {
  5. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  6. var editedAcount = entityForm.entity;
  7. var target = new MobileCRM.Reference(editedAcount.entityName, editedAcount.id);
  8. var relationShip = new MobileCRM.Relationship("parentcustomerid", target, null, null);
  9. MobileCRM.UI.FormManager.showNewDialog(
  10. "contact",
  11. relationShip, {
  12. "@initialize": { // force the form to pre-fill certain fields
  13. telephone1: editedAcount.properties.telephone1, // new contact will have the same phone as account
  14. address1_line1: editedAcount.properties.address1_line1, // ... and address too
  15. address1_city: editedAcount.properties.address1_city
  16. },
  17. // These props will be passed to all iFrames on the contact form which is being opened
  18. iFrameOptions: {
  19. doNotRequirePhone: true
  20. }
  21. }
  22. );
  23. },
  24. MobileCRM.bridge.alert
  25. );
  26. }

MobileCRM.UI.HomeForm Object

[v8.0] Represents the Javascript equivalent of the home form object which contains the Home/UI replacement iFrame.

This class works only from Home/UI replacement iFrame.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.UI.HomeForm.requestObject function.

Properties

PropertyTypeDescription
formMobileCRM.UI.FormGets the top level form.
itemsArrayGets the list of the home items.
listViewMobileCRM.UI._ListControllerGets the list view with home items.
lastSyncResultMobileCRM.Services.SynchronizationResult[v8.1] An object with last sync results. Contains following boolean properties: newCustomizationReady, customizationDownloaded, dataErrorsEncountered, appWasLocked, syncAborted, adminFullSync, wasBackgroundSync
syncResultTextString[v8.1] The last synchronization error text.
syncProgressObject[v8.1] An object with current sync progress. Contains following properties: labels, percent. It is undefined if no sync is running.

Functions

FunctionDescription
closeForms[v8.0] Close all opened forms.
closeHomeItemAsync[v8.0] Close the specified HomeItem.
hideUIReplacement[v8.0] Hides the UI replacement iframe and shows the classic home form.
onSyncFinished[v8.1] Binds the new handler to the synchronization finish event.
openHomeGroupItemAsync[v10.1.1] Opens the specified HomeItem in specific group.
openHomeItemAsync[v8.0] Opens the specified HomeItem.
requestObject[v8.0] Requests the managed HomeForm object.
restoreUIReplacement[v11.0] Restores previously hidden UI replacement iframe and hides the classic home form.
updateHomeItemAsync[v10.2] Updates specified HomeItem in specific group.
updateHomeItems[v10.3] Updates specified home items.

MobileCRM.UI.HomeForm.closeForms Function

[v8.0] Close all opened forms.

Arguments

ArgumentTypeDescription
callbackfunction()The callback function that is called asynchronously after forms were closed successfully.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.HomeForm.closeHomeItemAsync Function

[v8.0] Close the specified HomeItem.

Arguments

ArgumentTypeDescription
nameStringThe name of the HomeItem to be opened. It can be either the entity logical name (e.g. "contact") or one of following special forms names: "@Dashboard", "@Map", "@activity", "@Tourplan","@CallImport","@Setup","@About".
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to close Dashboard item from the home form replacement iFrame.

  1. MobileCRM.UI.HomeForm.closeHomeItemAsync("@Dashboard", MobileCRM.bridge.alert, null);

MobileCRM.UI.HomeForm.hideUIReplacement Function

[v8.0] Hides the UI replacement iframe and shows the classic home form.

Example 1

This example demonstrates how to hide the home form replacement iFrame and display the legacy Home Form.

  1. MobileCRM.UI.HomeForm.hideUIReplacement();

MobileCRM.UI.HomeForm.onSyncFinished Function

[v8.1] Binds the new handler to the synchronization finish event.

Arguments

ArgumentTypeDescription
handlerfunction(homeForm)A function which will be called when the synchronization finished event occurs with current instance of the MobileCRM.UI.HomeForm as parameter.
scopeObjectA scope in which the handler should be called.

Example 1

This example demonstrates how to handle the synchronization finished event from the home form replacement iFrame.

  1. MobileCRM.UI.HomeForm.onSyncFinished(
  2. function (homeForm) {
  3. /// <param name="homeForm" type="MobileCRM.UI.HomeForm"/>
  4. if (homeForm.newCustomizationReady && !homeForm.customizationDownloaded) {
  5. MobileCRM.bridge.alert("Application update is available");
  6. }
  7. },
  8. null
  9. );

MobileCRM.UI.HomeForm.openHomeGroupItemAsync Function

[v10.1.1] Opens the specified HomeItem in specific group.

Arguments

ArgumentTypeDescription
itemsArrayA list of group and subgroups representing the path to the home item.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to open an iFrame form located in a sub-group of the home item.

  1. var items = ['#Main Group', '#Subgroup', '@@My html;file://myIFrame.html'];
  2. MobileCRM.UI.HomeForm.openHomeGroupItemAsync(items, MobileCRM.bridge.alert, null);

MobileCRM.UI.HomeForm.openHomeItemAsync Function

[v8.0] Opens the specified HomeItem.

Arguments

ArgumentTypeDescription
nameStringThe name of the HomeItem to be opened. It can be either the entity logical name (e.g. "contact") or one of following special forms names: "@Dashboard", "@Map", "activity", "@Tourplan","@CallImport","@Setup","@About".
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to open Dashboard item from the home form replacement iFrame.

  1. MobileCRM.UI.HomeForm.openHomeItemAsync("@Dashboard", MobileCRM.bridge.alert, null);

MobileCRM.UI.HomeForm.requestObject Function

[v8.0] Requests the managed HomeForm object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of HomeForm object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(homeForm)The callback function that is called asynchronously with serialized HomeForm object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to change the Home Form title.

  1. function changeTitle(newTitle) {
  2. MobileCRM.UI.HomeForm.requestObject(
  3. function (homeForm) {
  4. /// <param name="homeForm" type="MobileCRM.UI.HomeForm"/>
  5. homeForm.form.caption = "My Changed Caption";
  6. return true;
  7. },
  8. MobileCRM.bridge.alert
  9. );
  10. }

MobileCRM.UI.HomeForm.restoreUIReplacement Function

[v11.0] Restores previously hidden UI replacement iframe and hides the classic home form.


MobileCRM.UI.HomeForm.updateHomeItemAsync Function

[v10.2] Updates specified HomeItem in specific group.

Arguments

ArgumentTypeDescription
itemsArrayA list of group and subgroups representing the path to the home item.
titleStringThe title for the home item.
subTitleStringThe title for the home item.
badgeStringThe title for the home item.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to update title, subtitle and badge of a home form item.

  1. var items = ['#Main Group', '#Subgroup', '@@My html;file://myIFrame.html'];
  2. MobileCRM.UI.HomeForm.updateHomeItemAsync(items, "My iFrame", "My subtitle", "1", MobileCRM.bridge.alert);

MobileCRM.UI.HomeForm.updateHomeItems Function

[v10.3] Updates specified home items.

Arguments

ArgumentTypeDescription
itemsArrayA list of home item that has to be changed. Each home item is an object with following properties: path, title, subTitle, badge, isVisible.

Example 1

This example demonstrates how to update title, subtitle, badge and visibility for a list of home items

  1. MobileCRM.UI.HomeForm.updateHomeItems([{
  2. path: "@Dashboard",
  3. title: "Sales Summary",
  4. subTitle: "Monthly statistics"
  5. }, {
  6. path: "contact",
  7. isVisible: false
  8. }, {
  9. path: "opportunity",
  10. isVisible: true
  11. }
  12. ]);

MobileCRM.UI.IFrameForm Object

[v9.0] Represents the iFrame form object.

Properties

PropertyTypeDescription
formMobileCRM.UI.FormGets the form hosting the iFrame.
isDirtyBoolean[v10.0] Controls whether the form is dirty and requires save, or whether it can be closed.
optionsObjectCarries the custom parameters that can be specified when opening the form using MobileCRM.UI.IFrameForm.show function.
preventCloseMessageString[v9.3] Prevents closing the form if non-empty string is set. No other home-item can be opened and synchronization is not allowed to be started. Provided message is shown when user tries to perform those actions.
saveBehaviorNumber[v10.0] Controls the behavior of the Save command on this form (0=Default, 1=SaveOnly, 2=SaveAndClose).

Methods

MethodDescription
suspendSave[v10.0] Suspends current "onSave" process and allows performing asynchronous tasks to save the data.

Functions

FunctionDescription
onSave[v10.0] Binds or unbinds the handler for saving content of this iFrame.
preventClose[v10.0] Sets the warning message that should be shown when user tries to close the form.
requestObject[v9.0] Asynchronously requests the IFrameForm object.
setDirty[v10.0] Sets the dirty flag which prevents the form being closed. App asks to save the form before saving and if user chooses to save it, it calls the save routine defined in IFrameForm.saveCommand.
showShows a new iFrame form.
showModalShows a new iFrame form in modal window.

MobileCRM.UI.IFrameForm.suspendSave Method

[v10.0] Suspends current "onSave" process and allows performing asynchronous tasks to save the data.

Return value

Type: Object

A request object with single method "resumeSave" which has to be called with the result (either error message string or "null" in case of success). To cancel the validation without any message, pass "#NoMessage#" text to this method.


MobileCRM.UI.IFrameForm.onSave Function

[v10.0] Binds or unbinds the handler for saving content of this iFrame.

Bound handler is called with the IFrameForm object as an argument.

The IFrameForm context object contains property "errorMessage" that can be used to cancel save with an error.

Use suspendSave method to suspend the save process if an asynchronous operation is required.

Arguments

ArgumentTypeDescription
handlerfunction(IFrameForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.IFrameForm.preventClose Function

[v10.0] Sets the warning message that should be shown when user tries to close the form.

Set to "null" to allow the form close.


MobileCRM.UI.IFrameForm.requestObject Function

[v9.0] Asynchronously requests the IFrameForm object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of IFrameForm object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(iFrameForm)The callback function that is called asynchronously with serialized MobileCRM.UI.IFrameForm object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrate how to asynchronously requests the IFrameForm object.

  1. function requestiFrame() {
  2. MobileCRM.UI.IFrameForm.requestObject(function (iFrame) {
  3. /// <param name='iFrame' type='MobileCRM.UI.IFrameForm'/>
  4. var p = document.createElement("p");
  5. p.innerText = "IFrameForm form properties = "
  6. for (var prop in iFrame.form) {
  7. p.innerText += prop + " : " + iFrame.form[prop];
  8. }
  9. document.appendChild(p);
  10. }, MobileCRM.bridge.alert, null);
  11. }

MobileCRM.UI.IFrameForm.setDirty Function

[v10.0] Sets the dirty flag which prevents the form being closed. App asks to save the form before saving and if user chooses to save it, it calls the save routine defined in IFrameForm.saveCommand.


MobileCRM.UI.IFrameForm.show Function

Shows a new iFrame form.

Arguments

ArgumentTypeDescription
captionStringDefines the form caption.
urlStringDefines the URL of the HTML document.
maximizedBooleanIndicates whether the new form should be maximized.
optionsObjectGeneric object passed to the new iFrame (see MobileCRM.UI.IFrameForm.requestObject).

Example 1

This example demonstrate how to show a new iFrame form. Method must be called from another iFrame with some options.

  1. function show() {
  2. MobileCRM.UI.IFrameForm.requestObject(function (iFrame) {
  3. /// <param name='iFrame' type='MobileCRM.UI.IFrameForm'/>
  4. MobileCRM.UI.IFrameForm.show("TestIframe", "http://www.google.com/", false, options = { text: "Some Text as option." });
  5. }, MobileCRM.bridge.alert, null);
  6. }

MobileCRM.UI.IFrameForm.showModal Function

Shows a new iFrame form in modal window.

Arguments

ArgumentTypeDescription
captionStringDefines the form caption.
urlStringDefines the URL of the HTML document.
optionsObjectGeneric object passed to the new iFrame.

Example 1

This example demonstrate how to show a new iFrame form in modal window.

  1. function showModal() {
  2. MobileCRM.UI.IFrameForm.showModal("TestIframe", "http://www.google.com/", options = { text: "Some Text as option." });
  3. }

MobileCRM.UI.ListDataSource Object

The data source loading routine implementation.

An instance of this object can be used to supply the data source for MobileCRM.UI.EntityList.setDataSource function.

The instance of this object is valid only if the method loadNextChunk is implemented. See example here.

Properties

PropertyTypeDescription
chunkSizeNumberControls the number of entities loaded in once.
fetchMobileCRM.FetchXml.FetchGets the original fetch request for this list view.
loadNextChunkfunction(page, count)Controls the number of entities loaded in once. It is called from native code to get chunk (array) of DynamicEntities. The chunk is defined by 1-based page number and the desired count which corresponds to the value of chunkSize property.

Methods

MethodDescription
chunkReadyThis method has to be called from within the "loadNextChunk" routine when it loads chunk (array) of DynamicEntities.

MobileCRM.UI.ListDataSource.chunkReady Method

This method has to be called from within the "loadNextChunk" routine when it loads chunk (array) of DynamicEntities.

Data source enumeration ends when the chunkReady method is called with empty array (no more records are available).

Arguments

ArgumentTypeDescription
entitiesArray[MobileCRM.DynamicEntity]A chunk (array) of DynamicEntities that has to be passed back to the native code to fill in to the list view.

MobileCRM.UI.LookupForm Object

This object allows user to select an entity from a configurable list of entity types.

Properties

PropertyTypeDescription
entitiesArrayAn array of allowed entity kinds (schema names).
allowedViewsStringOBSOLETE: Allowed views, or null if all are allowed.
sourceMobileCRM.RelationshipThe entity whose property will be set to the chosen value.
prevSelectionMobileCRM.ReferenceThe entity whose property will be set to the chosen value.
allowNullBooleanWhether to allow selecting no entity.
preventCloseBooleanWhether to prevent closing form without choosing a value.

Methods

MethodDescription
addEntityFilterDefines a fetch XML filter for entity records.
addViewAppends an entity view to the list of allowed views.
showShows a dialog which allows the user to select an entity from a configurable list of entity types.
showAsyncShows a dialog which allows the user to select an entity from a configurable list of entity types.

MobileCRM.UI.LookupForm.addEntityFilter Method

Defines a fetch XML filter for entity records.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
filterXmlstringA string defining the fetch XML which has to be applied as filter for entity records.

MobileCRM.UI.LookupForm.addView Method

Appends an entity view to the list of allowed views.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
viewNamestringA name of the view.
isDefaultBooleantrue, if the view should be set as default.

Example 1

This example demonstrates how to Add the view to lookupform and set if it is default or not.

  1. lookupForm.addView("contact", "Default", "true");

MobileCRM.UI.LookupForm.show Method

Shows a dialog which allows the user to select an entity from a configurable list of entity types.

Arguments

ArgumentTypeDescription
successfunction(obj)The callback function that is called with chosen MobileCRM.Reference object.
failedfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to choose the parent customer from Contact form. This code opens up the Account list and sets chosen Account into the parent customer field of the currently edited Contact.

  1. function chooseParentCustomer() {
  2. var lookupForm = new MobileCRM.UI.LookupForm();
  3. // HOW TO ADD ADDITIONAL FILTERING TO LOOKUP FORM.
  4. var customXMLView = '<fetch version="1.0"><entity name="account">' +
  5. '<filter type="and"><condition attribute="address1_city" operator="like" value="Bratislava"/></filter></entity></fetch>';
  6. lookupForm.addEntityFilter("account", customXMLView)
  7. lookupForm.addView("account", "Default");
  8. lookupForm.allowNull = true; // Allow choosing empty value
  9. lookupForm.show(onLookupFinished, MobileCRM.bridge.alert, null);
  10. }
  11.  
  12. function onLookupFinished(accountRef) {
  13. /// <param name="accountRef" type="MobileCRM.Reference"/>
  14. // Change the parent customer on currently edited contact entity
  15. MobileCRM.UI.EntityForm.requestObject(
  16. function (entityForm) {
  17. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  18. var editedContact = entityForm.entity;
  19. var newCustomer = accountRef ? new MobileCRM.Reference(accountRef.entityName, accountRef.id, accountRef.primaryName) : null;
  20. editedContact.properties["parentcustomerid"] = newCustomer;
  21. },
  22. MobileCRM.bridge.alert
  23. );
  24. }

MobileCRM.UI.LookupForm.showAsync Method

Shows a dialog which allows the user to select an entity from a configurable list of entity types.

Return value

Type: Promise<MobileCRM.Reference>

A Promise object which will be resolved with a Reference object representing chosen entity record.

Example 1

This example demonstrates how to choose the parent customer from Contact form. This code opens up the Account list and sets chosen Account into the parent customer field.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function chooseParentCustomer() {
  4. try {
  5. var lookupForm = new MobileCRM.UI.LookupForm();
  6. // HOW TO ADD ADDITIONAL FILTERING TO LOOKUP FORM.
  7. var customXMLView = '<fetch version="1.0"><entity name="account">' +
  8. '<filter type="and"><condition attribute="address1_city" operator="like" value="Bratislava"/></filter></entity></fetch>';
  9. lookupForm.addEntityFilter("account", customXMLView)
  10. lookupForm.addView("account", "Default");
  11. lookupForm.allowNull = true; // Allow choosing empty value
  12. var accountRef = await lookupForm.showAsync();
  13.  
  14. // Change the parent customer on currently edited contact entity
  15. MobileCRM.UI.EntityForm.requestObject(
  16. function (entityForm) {
  17. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  18. var editedContact = entityForm.entity;
  19. var newCustomer = accountRef ? new MobileCRM.Reference(accountRef.entityName, accountRef.id, accountRef.primaryName) : null;
  20. editedContact.properties["parentcustomerid"] = newCustomer;
  21. },
  22. MobileCRM.bridge.alert
  23. );
  24. }
  25. catch (err) {
  26. MobileCRM.bridge.alert(err);
  27. }
  28. }

MobileCRM.UI.MediaTab Object

Represents the MediaTab controller.

An instance of this class can only be obtained by calling the MobileCRM.UI.EntityForm.getMediaTab method.

Methods

MethodDescription
capturePhotoCaptures photo on this media tab.
clearClears the content of this media tab.
exportSaves to file to disk.
getData[v8.0] Gets the media tab document in form of base64 string.
getDataAsync[v8.0] Gets the media tab document in form of base64 string.
getDocumentInfo[v8.0.1] Asynchronously gets the media tab view object.
getNoteSubject[v10.1] Asynchronously gets the subject text of the note loaded on the media tab.
isEmpty[v9.0.2] Asynchronously gets the boolean value indicating whether the media tab content is empty or not.
openOpens the loaded document in a external application. Which application is platform specific.
printPrints the document.
recordAudioExecutes the record audio command on this media tab.
recordVideoExecutes the record video command on this media tab.
selectFileExecutes the select file command on this media tab.
selectPhotoExecutes the select photo command on this media tab.
setCommandsMask[v11.1] Sets the mask of allowed document actions.
setEditable[v11.1] Marks the MediaTab as editable.
setNoteSubject[v10.1] Asynchronously sets the name of the note to load (and save).

Functions

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

MobileCRM.UI.MediaTab.capturePhoto Method

Captures photo on this media tab.

Example 1

This example demonstrates how to initiate photo capture on the media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.capturePhoto();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.clear Method

Clears the content of this media tab.

Example 1

This example demonstrates how to clear the media tab content.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.clear();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.export Method

Saves to file to disk.


MobileCRM.UI.MediaTab.getData Method

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

Arguments

ArgumentTypeDescription
callbackfunction(String)The callback function that is called asynchronously with the base64-encoded document data.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

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.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.getData(
  6. function (base64String) {
  7. MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
  8. var img = document.getElementById("imgTarget");
  9. if (img)
  10. // Construct data URL from base64 data and set it as a source to <img> element.
  11. img.src = "data:;base64," + base64String;
  12. },
  13. MobileCRM.bridge.alert
  14. );
  15. }, MobileCRM.bridge.alert, null );

MobileCRM.UI.MediaTab.getDataAsync Method

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

Return value

Type: Promise<string>

A Promise object which will be resolved with the base64-encoded document data.

Example 1

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.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. MobileCRM.UI.EntityForm.requestObject(
  4. async function (entityForm) {
  5. // get media tab by its name
  6. var media = entityForm.getMediaTab("DocumentAction");
  7. var base64String = await media.getData();
  8. MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
  9. var img = document.getElementById("imgTarget");
  10. if (img)
  11. // Construct data URL from base64 data and set it as a source to <img> element.
  12. img.src = "data:;base64," + base64String;
  13. }
  14. );

MobileCRM.UI.MediaTab.getDocumentInfo Method

[v8.0.1] Asynchronously gets the media tab view object.

Arguments

ArgumentTypeDescription
callbackfunction(Object)The callback function that is called asynchronously with the document info object.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to get the document info from media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.getDocumentInfo(
  6. function (info) {
  7. // 0=None, 1=Signature, 2=WebPage, 3=Image, 4=File
  8. var documentInfo = JSON.stringify(info);
  9. MobileCRM.bridge.alert("Document info : \n\n" + documentInfo);
  10. },
  11. MobileCRM.bridge.alert
  12. );
  13. },
  14. MobileCRM.bridge.alert, null);

MobileCRM.UI.MediaTab.getNoteSubject Method

[v10.1] Asynchronously gets the subject text of the note loaded on the media tab.

Arguments

ArgumentTypeDescription
callbackfunction(String)The callback function that is called asynchronously with the media tab note subject.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.MediaTab.isEmpty Method

[v9.0.2] Asynchronously gets the boolean value indicating whether the media tab content is empty or not.

Arguments

ArgumentTypeDescription
callbackfunction(Boolean)The callback function that is called asynchronously with the boolean value indicating whether the content is empty or not.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.MediaTab.open Method

Opens the loaded document in a external application. Which application is platform specific.


MobileCRM.UI.MediaTab.print Method

Prints the document.


MobileCRM.UI.MediaTab.recordAudio Method

Executes the record audio command on this media tab.

Example 1

Example demonstrate how to execute the audio record command on media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.recordAudio();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.recordVideo Method

Executes the record video command on this media tab.

Example 1

Example demonstrate how to execute the video record command on media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.recordVideo();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.selectFile Method

Executes the select file command on this media tab.

Example 1

Example demonstrate how to execute the select file command on media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.selectFile();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.selectPhoto Method

Executes the select photo command on this media tab.

Example 1

Example demonstrate how to execute the select photo command on media tab.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.selectPhoto();
  6. },
  7. MobileCRM.bridge.alert,
  8. null
  9. );

MobileCRM.UI.MediaTab.setCommandsMask Method

[v11.1] Sets the mask of allowed document actions.

Arguments

ArgumentTypeDescription
commandMaskNumberSpecifies the mask of allowed commands.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.

Example 1

This example demonstrates how to to filter media tab document action commands.

  1. var DocumentAction = {
  2. /** No action.*/
  3. None: 0x0000,
  4. /** Configures the view for ink input.*/
  5. CaptureInk: 0x0001,
  6. /** Asks the user to capture a photo and loads the choosen media into the view.*/
  7. CapturePhoto: 0x0002,
  8. /** Asks the user to choose a media (image, video, depending on what the platform supports) and loads the choosen media into the view.*/
  9. SelectPhoto: 0x0004,
  10. /** Asks the user to choose a file and loads it into the view.*/
  11. SelectFile: 0x0008,
  12. /** Asks the user to record an audio note and loads it into the view.*/
  13. RecordAudio: 0x0010,
  14. /** Asks the user to record a video and loads it into the view.*/
  15. RecordVideo: 0x0020,
  16. /** Gets last photo taken and loads it into the view.*/
  17. UseLastPhotoTaken: 0x0040,
  18. /** Asks the user to choose file from either online or offline location and loads it into the view.*/
  19. LoadFrom: 0x0080,
  20.  
  21. /** Clears the view and marks it as empty.*/
  22. Clear: 0x1000,
  23. /** Shows a preview of the loaded document (fullscreen, etc.).*/
  24. View: 0x2000,
  25. /** Opens the loaded document in a external application. Which application is platform specific.*/
  26. OpenExternal: 0x4000,
  27. /** Sends the document to another application. This command is implemented only on Android.*/
  28. SendTo: 0x8000,
  29. /** Virtual action handled in common code.*/
  30. Download: 0x10000,
  31. /** Copy image to clipboard.*/
  32. Copy: 0x20000,
  33. /** Paste image from clipboard.*/
  34. Paste: 0x40000,
  35. /** Prints the document.*/
  36. Print: 0x80000,
  37. /** Let user to choose smaller image resolution.*/
  38. ResizeImage: 0x100000,
  39. /** Let user import VCard attachment (handled in common code).*/
  40. Import: 0x200000,
  41. /** Pass document to edit in external app (Microsoft office so far[15.6.2015]).*/
  42. Edit: 0x400000,
  43. /** Send document as attachment.*/
  44. Email: 0x800000,
  45. /** Ask the user to choose multiple images.*/
  46. SelectMultiplePhotos: 0x1000000,
  47. /** Asks the user to choose multiple files from either online or offline location and loads it into the view.*/
  48. LoadFromMultiple: 0x2000000,
  49. /** Opens image in the image editor.*/
  50. EditImage: 0x4000000,
  51. /** Saves to file to disk.*/
  52. Export: 0x8000000,
  53. /** Actions that are non-destructive.*/
  54. ReadOnlyMask: 0x88AE000 // SendTo | View | OpenExternal | Print | Email | Copy | Export
  55. };
  56.  
  57. MobileCRM.UI.EntityForm.requestObject(
  58. function (entityForm) {
  59. // get media tab by its name
  60. var media = entityForm.getMediaTab("DocumentAction");
  61. media.setCommandsMask(DocumentAction.CapturePhoto | DocumentAction.SelectPhoto, MobileCRM.bridge.alert);
  62. },
  63. MobileCRM.bridge.alert, null
  64. );

MobileCRM.UI.MediaTab.setEditable Method

[v11.1] Marks the MediaTab as editable.

Arguments

ArgumentTypeDescription
editableBooleanIndicates whether to mark MediaTab as editable.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.

Example 1

This example demonstrates how to set the media tab editable or read-only.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.setEditable(true, MobileCRM.bridge.alert); // set false to make it read-only
  6. },
  7. MobileCRM.bridge.alert, null
  8. );

MobileCRM.UI.MediaTab.setNoteSubject Method

[v10.1] Asynchronously sets the name of the note to load (and save).

Arguments

ArgumentTypeDescription
subjectStringThe name of the note to load (and save).
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.MediaTab.getData Function

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

Arguments

ArgumentTypeDescription
viewNameStringThe name of the media tab.
callbackfunction(String)The callback function that is called asynchronously with the base64-encoded document data.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

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.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. // get media tab by its name
  4. var media = entityForm.getMediaTab("DocumentAction");
  5. media.getData(
  6. function (base64String) {
  7. MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
  8. var img = document.getElementById("imgTarget");
  9. if (img)
  10. // Construct data URL from base64 data and set it as a source to <img> element.
  11. img.src = "data:;base64," + base64String;
  12. },
  13. MobileCRM.bridge.alert
  14. );
  15. }, MobileCRM.bridge.alert, null );

MobileCRM.UI.MediaTab.getDataAsync Function

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

Arguments

ArgumentTypeDescription
viewNameStringThe name of the media tab.

Return value

Type: Promise<string>

A Promise object which will be resolved with the base64-encoded document data.

Example 1

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.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. MobileCRM.UI.EntityForm.requestObject(
  4. async function (entityForm) {
  5. // get media tab by its name
  6. var media = entityForm.getMediaTab("DocumentAction");
  7. var base64String = await media.getData();
  8. MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
  9. var img = document.getElementById("imgTarget");
  10. if (img)
  11. // Construct data URL from base64 data and set it as a source to <img> element.
  12. img.src = "data:;base64," + base64String;
  13. }
  14. );

MobileCRM.UI.MessageBox Object

This object allows the user to show a popup window and choose one of the actions.

Properties

PropertyTypeDescription
itemsArrayAn array of button names.
titlestringThe message box title.
defaultTextstringThe cancel button title text.
multiLineBooleanIndicates whether the message is multi line.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.MessageBox object.
showShows a popup window which allows the user to choose one of the actions.
showAsyncShows a popup window allowing user to choose one of actions.

Functions

FunctionDescription
sayTextShows a simple popup window with a multi-line text.
sayTextAsyncShows a simple popup window with a multi-line text.

MobileCRM.UI.MessageBox.constructor Method

Constructs an instance of MobileCRM.UI.MessageBox object.

Arguments

ArgumentTypeDescription
titlestringThe message box title.
defaultTextstringThe cancel button title text.

MobileCRM.UI.MessageBox.show Method

Shows a popup window which allows the user to choose one of the actions.

Arguments

ArgumentTypeDescription
successfunction(obj)The callback function that is called with chosen item string.
failedfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to create and display the message box with buttons "YES" and "No".MobileCRM.UI.MessageBox object.

  1. var popup = new MobileCRM.UI.MessageBox("title");
  2. /// Add the buttons for message box
  3. popup.items = ["Yes", "No"];
  4. /// If title is too long set the 'multi-line' to true
  5. popup.multiLine = true;
  6. popup.show(
  7. function (button) {
  8. if (button == "Yes")
  9. MobileCRM.bridge.alert("You taped on 'Yes' button");
  10. else
  11. MobileCRM.bridge.alert("You taped on 'NO' button");
  12. return;
  13. }
  14. );

MobileCRM.UI.MessageBox.showAsync Method

Shows a popup window allowing user to choose one of actions.

Return value

Type: Promise<string>

A Promise object which will be resolved with chosen item string.

Example 1

This example demonstrates how to create and display the message box with buttons "YES" and "No".

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function confirmMsg(title) {
  4. var popup = new MobileCRM.UI.MessageBox(title);
  5. /// Add the buttons for message box
  6. popup.items = ["Yes", "No"];
  7. /// If title is too long set the 'multi-line' to true
  8. popup.multiLine = true;
  9. var button = await popup.showAsync();
  10. if (button == "Yes")
  11. MobileCRM.bridge.alert("You taped on 'Yes' button");
  12. else
  13. MobileCRM.bridge.alert("You taped on 'NO' button");
  14. }

MobileCRM.UI.MessageBox.sayText Function

Shows a simple popup window with a multi-line text.

Arguments

ArgumentTypeDescription
textStringA text to be shown.
successfunctionThe callback function that is called after user closes the message box.
failedfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to display simple popup with multi-line text.

  1. var text = "Thank you for using this method\nPress OK to continue."
  2. MobileCRM.UI.MessageBox.sayText(text, function () {
  3. // ... continue execution
  4. });

MobileCRM.UI.MessageBox.sayTextAsync Function

Shows a simple popup window with a multi-line text.

Arguments

ArgumentTypeDescription
textStringA text to be shown.

Return value

Type: Promise<void>

A Promise object which will be resolved when user closes the message box.

Example 1

This example demonstrates how to display simple popup with multi-line text.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. var text = "Thank you for using this method\nPress OK to continue."
  4. await MobileCRM.UI.MessageBox.sayText(text);
  5. // ... execution continues after user closes the message box

MobileCRM.UI.MultiLookupForm Object

[v9.3] This object allows user to select a list of entities from a configurable list of entity types. Derived from LookupForm so you can use the addView() and addEntityFilter() methods.

Properties

PropertyTypeDescription
entitiesArrayAn array of allowed entity kinds (schema names).
sourceMobileCRM.RelationshipThe entity whose property will be set to the chosen value.
dataSourceMobileCRM.Reference[]The list of entities that should be displayed as selected.
prevSelectionMobileCRM.ReferenceThe entity whose property will be set to the chosen value.
allowNullBooleanWhether to allow selecting no entity.
preventCloseBooleanWhether to prevent closing form without choosing a value.

Methods

MethodDescription
addEntityFilterDefines a fetch XML filter for entity records.
addViewAppends an entity view to the list of allowed views.
showShows a dialog which allows the user to select a list of entities from a configurable list of entity types.
showAsyncShows a dialog which allows the user to select a list of entities from a configurable list of entity types.

MobileCRM.UI.MultiLookupForm.addEntityFilter Method

Defines a fetch XML filter for entity records.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
filterXmlstringA string defining the fetch XML which has to be applied as filter for entity records.

MobileCRM.UI.MultiLookupForm.addView Method

Appends an entity view to the list of allowed views.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
viewNamestringA name of the view.
isDefaultBooleantrue, if the view should be set as default.

MobileCRM.UI.MultiLookupForm.show Method

Shows a dialog which allows the user to select a list of entities from a configurable list of entity types.

Arguments

ArgumentTypeDescription
successfunction(obj)The callback function that is called with chosen array of MobileCRM.Reference objects.
failedfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to select products from multi-lookup form. It opens the multi-lookup form with products matching specified filter fetch.

  1. function openMultiLookUp(orderRef) {
  2. /// <param name='orderRef' type='MobileCRM.Reference'>A reference to a sales order entity.</param>
  3. var filteredLeadXML =
  4. '<fetch version="1.0">' +
  5. '<entity name="product">' +
  6. '<filter type="and">' +
  7. '<condition attribute="name" operator="like" value="H%" />' +
  8. '</filter>' +
  9. '</entity>' +
  10. '</fetch>';
  11.  
  12. var ml = new MobileCRM.UI.MultiLookupForm("product");
  13. ml.source = new MobileCRM.Relationship("salesorderid", orderRef);
  14. ml.addEntityFilter("product", filteredLeadXML);
  15. ml.allowNull = true;
  16. ml.addView("product", "Active Products", true); // requires "Active Products" view for "product" entity in your mobile project
  17.  
  18. ml.show(function (selected) {
  19. /// <param name='selected' type='Array<MobileCRM.Reference>'/>
  20. }, MobileCRM.bridge.alert, null);
  21. }

MobileCRM.UI.MultiLookupForm.showAsync Method

Shows a dialog which allows the user to select a list of entities from a configurable list of entity types.

Return value

Type: Promise<MobileCRM.Reference[]>

A Promise object which will be resolved with an array of Reference objects representing chosen entity records.

Example 1

This example demonstrates how to select products from multi-lookup form. It opens the multi-lookup form with products matching specified filter fetch.

  1. // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
  2. // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
  3. async function openMultiLookUp(orderRef) {
  4. /// <param name='orderRef' type='MobileCRM.Reference'>A reference to a sales order entity.</param>
  5. var filteredLeadXML =
  6. '<fetch version="1.0">' +
  7. '<entity name="product">' +
  8. '<filter type="and">' +
  9. '<condition attribute="name" operator="like" value="H%" />' +
  10. '</filter>' +
  11. '</entity>' +
  12. '</fetch>';
  13. try {
  14. var ml = new MobileCRM.UI.MultiLookupForm("product");
  15. ml.source = new MobileCRM.Relationship("salesorderid", orderRef);;
  16. ml.addEntityFilter("product", filteredLeadXML);
  17. ml.allowNull = true;
  18. ml.addView("product", "Active Products", true); // requires "Active Products" view for "product" entity in your mobile project
  19. var selected = await ml.showAsync();
  20. MobileCRM.bridge.alert(selected.primaryName);
  21. }
  22. catch (err) {
  23. MobileCRM.bridge.alert(err);
  24. }
  25. }

MobileCRM.UI.ProcessController Object

[v8.2] Represents the Javascript equivalent of view process controller.

It is not intended to create an instance of this class. To obtain this object, use EntityForm.requestObject function and locate the controller in form's "controllers" list.

Properties

PropertyTypeDescription
currentStateInfoObjectGets the information about the current process flow state (active stage, visible stage and process).

Methods

MethodDescription
changeProcess[v8.2] Changes (or clears) the business process flow for the current entity.

MobileCRM.UI.ProcessController.changeProcess Method

[v8.2] Changes (or clears) the business process flow for the current entity.

Arguments

ArgumentTypeDescription
processRefMobileCRM.ReferenceA reference to the workflow entity defining the process to use, or null to disable BusinessProcessFlow.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callback.

Example 1

This example demonstrates how to get an entity form process controller and retrieve current state information. Finally, it changes the process to visible stage.

  1. MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
  2. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  3. var processController = entityForm.getController("process");
  4. if (processController) {
  5. var info = processController.currentStateInfo;
  6. var activeStageRef = new MobileCRM.Reference("workflow", info.ActiveStage, info.ActiveStageName);
  7. var visibleStageRef = new MobileCRM.Reference("workflow", info.VisibleStage, info.VisibleStageName);
  8. var processId = prContr.currentStateInfo.ProcessId;
  9. // NOTE: null reference disables BusinessProcessFlow.
  10. processController.changeProcess(visibleStageRef, MobileCRM.bridge.alert, null);
  11. }
  12. }, MobileCRM.bridge.alert, null);

MobileCRM.UI.QuestionnaireForm Object

[v10.3] Represents the Javascript equivalent of native questionnaire form object.

Properties

PropertyTypeDescription
formMobileCRM.UI.FormGets the form which hosts the questionnaire.
groupsMobileCRM.UI.QuestionnaireForm.Group[]A list of QuestionnaireForm.Group objects.
questionsMobileCRM.UI.QuestionnaireForm.Question[]A list of QuestionnaireForm.Question objects.
relationshipMobileCRM.RelationshipGets the relation source and related entity. "null", if there is no relationship.

Methods

MethodDescription
cancelValidationStops the onSave validation and optionally causes an error message to be displayed.
findGroupByIdReturns the question group with given id.
findGroupByNameReturns the question group with given name.
findQuestionByIdReturns the question item with given id.
findQuestionByNameReturns the question item with given name.
suspendPostSaveSuspends current "onPostSave" operations and allows performing another asynchronous tasks before the form is closed.
suspendSaveSuspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result

Functions

FunctionDescription
changeLookupQuestionSetupSets the views and filters for specified lookup question.
deleteGroupDeletes an instance of repeatable group with all its questions and adjusts the repeatIndex for all instances of the same template group with higher index.
focusQuestionAsynchronously sets the focus on given question.
getQuestionnaireEntityRequests the Questionnaire entity.
onAnswerChanged[v11.2] Binds or unbinds the handler for specific question change event on QuestionnaireForm.
onChangeBinds or unbinds the handler for onChange event on QuestionnaireForm.
onDeleteGroupBinds or unbinds the handler for onDeleteGroup event on QuestionnaireForm.
onPostSaveBinds or unbinds the handler for onPostSave event on QuestionnaireForm.
onRepeatGroupBinds or unbinds the handler for onRepeatGroup event on QuestionnaireForm.
onSaveBinds or unbinds the handler for onSave event on QuestionnaireForm.
overridePicklistOptionsOverrides the list of options for given picklist question.
repeatGroupDuplicates repeatable group with all its questions. The name of the group will contain the lowest available repeatIndex and suffix in form #00X.
requestObjectRequests the managed QuestionnaireForm object.
trySetAnswerAsynchronously sets the answer value for given question.

Objects

ObjectDescription
Group
Question

MobileCRM.UI.QuestionnaireForm.cancelValidation Method

Stops the onSave validation and optionally causes an error message to be displayed.

Arguments

ArgumentTypeDescription
errorMsgStringAn error message to be displayed or "null" to cancel the validation without message.

MobileCRM.UI.QuestionnaireForm.findGroupById Method

Returns the question group with given id.

Arguments

ArgumentTypeDescription
nameStringAn id of the question group.

Return value

Type: MobileCRM.UI.QuestionnaireForm.Group


MobileCRM.UI.QuestionnaireForm.findGroupByName Method

Returns the question group with given name.

Arguments

ArgumentTypeDescription
nameStringA name of the question group.

Return value

Type: MobileCRM.UI.QuestionnaireForm.Group


MobileCRM.UI.QuestionnaireForm.findQuestionById Method

Returns the question item with given id.

Arguments

ArgumentTypeDescription
idStringAn id of the question item.

Return value

Type: MobileCRM.UI.QuestionnaireForm.Question


MobileCRM.UI.QuestionnaireForm.findQuestionByName Method

Returns the question item with given name.

Arguments

ArgumentTypeDescription
nameStringA name of the question item.

Return value

Type: MobileCRM.UI.QuestionnaireForm.Question


MobileCRM.UI.QuestionnaireForm.suspendPostSave Method

Suspends current "onPostSave" operations and allows performing another asynchronous tasks before the form is closed.

Return value

Type: Object

A request object with single method "resumePostSave" which has to be called to resume the post-save operations.


MobileCRM.UI.QuestionnaireForm.suspendSave Method

Suspends current "onSave" validation and allows performing another asynchronous tasks to determine the validation result

Return value

Type: Object

A request object with single method "resumeSave" which has to be called with the validation result (either error message string or "null" in case of success). To cancel the validation without any message, pass "#NoMessage#" text to this method.


MobileCRM.UI.QuestionnaireForm.changeLookupQuestionSetup Function

Sets the views and filters for specified lookup question.

Arguments

ArgumentTypeDescription
questionNameStringA name of the question.
dialogSetupMobileCRM.UI.DetailViewItems.LookupSetupLookup setup for modal lookup dialog.
inlinePickSetupMobileCRM.UI.DetailViewItems.LookupSetupOptional setup for inline lookup picker. Leave empty to use the same setup as modal dialog.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.deleteGroup Function

Deletes an instance of repeatable group with all its questions and adjusts the repeatIndex for all instances of the same template group with higher index.

Arguments

ArgumentTypeDescription
idStringId of the source group.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.focusQuestion Function

Asynchronously sets the focus on given question.

Arguments

ArgumentTypeDescription
questionNameStringA name of the question.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.getQuestionnaireEntity Function

Requests the Questionnaire entity.

Arguments

ArgumentTypeDescription
callbackfunction(entity)The callback function that is called asynchronously with a DynamicEntity object representing currently opened questionnaire. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.onAnswerChanged Function

[v11.2] Binds or unbinds the handler for specific question change event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
questionNameStringThe name of desired question.
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onChange Function

Binds or unbinds the handler for onChange event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onDeleteGroup Function

Binds or unbinds the handler for onDeleteGroup event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onPostSave Function

Binds or unbinds the handler for onPostSave event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onRepeatGroup Function

Binds or unbinds the handler for onRepeatGroup event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onSave Function

Binds or unbinds the handler for onSave event on QuestionnaireForm.

Arguments

ArgumentTypeDescription
handlerfunction(questionnaireForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

MobileCRM.UI.QuestionnaireForm.overridePicklistOptions Function

Overrides the list of options for given picklist question.

Arguments

ArgumentTypeDescription
questionNameStringA name of the picklist question.
allowNullBooleanIndicates whether the empty answer is allowed.
optionsObjectAn object with label-to-value mappings, e.g. {"Option 1":1,"Option 2":2}.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.repeatGroup Function

Duplicates repeatable group with all its questions. The name of the group will contain the lowest available repeatIndex and suffix in form #00X.

Arguments

ArgumentTypeDescription
idStringId of the source group.
copyValuesBooleanOptional paramater determining whether the group values should be copied to the new instance of this group.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.requestObject Function

Requests the managed QuestionnaireForm object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of QuestionnaireForm object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(questionnaireForm)The callback function that is called asynchronously with serialized QuestionnaireForm object as argument. Callback should return true to apply changed properties.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.trySetAnswer Function

Asynchronously sets the answer value for given question.

Arguments

ArgumentTypeDescription
questionNameStringA name of the question.
answeranyA value that has to be set as answer. It must correspond to the type of question.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Group Object

Properties

PropertyTypeDescription
idStringGets the id of this question group.
nameStringGets the name of the question group.
indexNumberGets the index of the question group.
labelStringGets the question group label.
descriptionStringGet the question group description.
templateGroupStringGets the id of parent group from questionnaire template.
repeatIndexNumberIndex of this instance of repeatable group. Zero for non-repeatable groups.
repeatEnabledBooleanIndicates whether the group is repeatable.
isVisibleBooleanGets or sets whether the group is visible.
isEnabledBooleanGets or sets whether the group is enabled.
isExpandedBooleanGets or sets whether the group is expanded (true) or collapsed (false).

Methods

MethodDescription
deleteGroupDeletes this instance of repeatable group with all its questions and adjusts the repeatIndex for all instances of the same template group with higher index.
repeatGroupDuplicates repeatable group with all its questions. The name of the group will contain the lowest available repeatIndex and suffix in form #00X.

MobileCRM.UI.QuestionnaireForm.Group.deleteGroup Method

Deletes this instance of repeatable group with all its questions and adjusts the repeatIndex for all instances of the same template group with higher index.

Arguments

ArgumentTypeDescription
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Group.repeatGroup Method

Duplicates repeatable group with all its questions. The name of the group will contain the lowest available repeatIndex and suffix in form #00X.

Arguments

ArgumentTypeDescription
copyValuesBooleanOptional parameter determining whether the group values should be copied to the new instance of this group.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Question Object

Properties

PropertyTypeDescription
idStringGets the id of this question record.
nameStringGets the name of the question item.
labelStringGets or sets the question item label.
indexNumberGets the index of the question item.
groupIdStringGets the id of parent question group (may be empty).
descriptionStringGet or sets the question item description.
typeNumberGets the value type of the question item.
valueAnyGets current answer value. To change it, use trySetAnswer method.
styleStringGets or sets the question item style name.
isVisibleBooleanIndicates whether the item is visible.
isEnabledBooleanIndicates whether the item is enabled.
focusBooleanSet to true to focus the question item.
validateBooleanIndicates whether the item should be validated.
errorMessageStringHolds the error message text related to current value of the question item.

Methods

MethodDescription
focusAsynchronously sets the focus on this question.
trySetAnswerAsynchronously sets the answer value for this question.

MobileCRM.UI.QuestionnaireForm.Question.focus Method

Asynchronously sets the focus on this question.

Arguments

ArgumentTypeDescription
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Question.trySetAnswer Method

Asynchronously sets the answer value for this question.

Arguments

ArgumentTypeDescription
answeranyA value that has to be set as answer. It must correspond to the type of question (String/Number/Reference/Guid).
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.ReportForm Object

[v8.1] Represents the Dynamics CRM report form object.

Properties

PropertyTypeDescription
allowedReportIdsArrayThe list of report entity ids that has to be included in the report form selector.
allowedLanguagesArrayThe list of LCID codes of the languages that has to be included into the report form selector. The number -1 stands for "Any language".
defaultReportStringThe primary name of the report entity that should be pre-selected on the report form.

Methods

MethodDescription
showShows the Dynamics CRM report form.

MobileCRM.UI.ReportForm.show Method

Shows the Dynamics CRM report form.

Arguments

ArgumentTypeDescription
successfunction(obj)The callback function that is called if the report form was successfully opened.
failedfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to open the report form with reports in specified languages and pre-select one of them.

  1. var reportForm = new MobileCRM.UI.ReportForm();
  2. reportForm.allowedLanguages = [-1, 1033, 1031]; // Allow "Any language", English and German reports only
  3. reportForm.defaultReport = "Default" // Pre-select the report with the name "Default"
  4. reportForm.show(null, MobileCRM.bridge.alert); // Do nothing on success, say error on failure

Example 2

This example demonstrates how to implement custom command for opening specific set of reports for current entity.

  1. // Register command handler for custom command which was appended to form in Woodford
  2. MobileCRM.UI.EntityForm.onCommand(
  3. "custom_PrintReport",
  4. function (entityForm) {
  5. fetchReports(3); // 3 is object type code for Opportunity entity (for demonstration)
  6. },
  7. true
  8. );
  9.  
  10. function fetchReports(objectTypeCode) {
  11. // fetch desired reports - Requires "Report" entity being enabled in Woodford!!!
  12. var entity = new MobileCRM.FetchXml.Entity("report");
  13. entity.addAttribute("reportid");
  14.  
  15. var filter = entity.addFilter();
  16. filter.where("parentreportid", "null", null); // take just root reports
  17.  
  18. // link reportentity filtering just reports for our object type code (Opportunity)
  19. var linkEntity = entity.addLink("reportentity", "reportid", "reportid", "inner");
  20. linkEntity.addFilter().where("objecttypecode", "eq", objectTypeCode);
  21.  
  22. // Take only reports owned by our business unit (optional)
  23. linkEntity = entity.addLink("businessunit", "businessunitid", "owningbusinessunit", "inner");
  24. linkEntity.addFilter().where("businessunitid", "eq-businessid", null);
  25.  
  26. // TBD: Optionally define order: entity.orderBy("name", false);
  27.  
  28. // Execute online fetch request
  29. var fetch = new MobileCRM.FetchXml.Fetch(entity);
  30. fetch.executeOnline(
  31. "Array", // Take the results as an array of arrays with field values
  32. function (result) {
  33. // "result" is array of arrays [[id1],[id2],...[idn]]
  34. var ids = [];
  35. for (var i in result) {
  36. var record = result[i];
  37. ids.push(record[0]); // take just first (and only) field which is reportid
  38. }
  39. showReport(ids);
  40. },
  41. function (err) {
  42. MobileCRM.bridge.alert("Error fetching accounts: " + err);
  43. },
  44. null
  45. );
  46. }
  47.  
  48. function showReport(ids) {
  49. var reportForm = new MobileCRM.UI.ReportForm();
  50. reportForm.allowedReportIds = ids;
  51. //reportForm.defaultReport = "Default"; // Optionally pre-select the report with the name "Default"
  52. reportForm.show(null, MobileCRM.bridge.alert); // Do nothing on success, say error on failure
  53. }

MobileCRM.UI.TourplanForm Object

Represents the Javascript equivalent tourplan form object.

This object cannot be created directly. To obtain/modify this object, use MobileCRM.UI.TourplanForm.requestObject function.

Properties

PropertyTypeDescription
isDirtyBooleanIndicates whether the form has been modified.
isLoadedBooleanGets or sets whether the form is loaded.
viewMobileCRM.UI._AppointmentViewGets tourplan form view MobileCRM.UI.AppointmentView.

Functions

FunctionDescription
onCreateNew[v11.3] Binds or unbinds the handler for creating new appointment after long-pressing on calendar.
requestObjectRequests the managed TourplanForm object.
setDateSets the current date in calendar view (Tourplan).
setModeSets the calendar view (Tourplan) mode.

MobileCRM.UI.TourplanForm.onCreateNew Function

[v11.3] Binds or unbinds the handler for creating new appointment after long-pressing on calendar.

Bound handler is called with the TourplanForm object as an argument. The context object contains "start", "end", "entityName" properties and optionally "subject" property.

Arguments

ArgumentTypeDescription
handlerfunction(tourplanForm)The handler function that has to be bound or unbound.
bindBooleanDetermines whether to bind or unbind the handler.
scopeObjectThe scope for handler calls.

Example 1

This example demonstrate how to bind handler for creating new appointment on tour plan form.

  1. /// Register handler on tourplan form for create new event.
  2. MobileCRM.UI.TourplanForm.onCreateNew(function (tourPlanForm) {
  3. ///<param name='tourPlanForm' type='MobileCRM.UI.TourplanForm' />
  4. /// The context of tour plan form object contains "start", "end", "entityName" properties and optionally "subject" property.
  5. MobileCRM.bridge.alert("Current Date: " + tourPlanForm.view.currentDate + "\n\nOn Create new: " + JSON.stringify(tourPlanForm.context));
  6. }, true, null);

MobileCRM.UI.TourplanForm.requestObject Function

Requests the managed TourplanForm object.

Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of Platform object. See MobileCRM.Bridge.requestObject for further details.

Arguments

ArgumentTypeDescription
callbackfunction(platform)The callback function that is called asynchronously with serialized TourplanForm object as argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.UI.TourplanForm.setDate Function

Sets the current date in calendar view (Tourplan).

Arguments

ArgumentTypeDescription
dateDateA date to set.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.

MobileCRM.UI.TourplanForm.setMode Function

Sets the calendar view (Tourplan) mode.

Arguments

ArgumentTypeDescription
modeMobileCRM.UI.TourplanViewModeA mode to set.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.

MobileCRM.UI.TourplanViewMode Object

Enumeration class holding constants for MobileCRM.UI.TourplanForm.

Properties

PropertyTypeDescription
AgendaNumberAgenda view.
DayNumber Day view.
WeekNumber Week view.
MonthNumber Month view.

MobileCRM.UI.ViewController Object

Represents the Javascript equivalent of view controller (map/web content).

Functions

FunctionDescription
createCommandOverrides the form's primary/secondary command button.

MobileCRM.UI.ViewController.createCommand Function

Overrides the form's primary/secondary command button.

Arguments

ArgumentTypeDescription
primaryBooleantrue, for primary button; false, for secondary button.
labelsArray/StringAn array of labels or single label.
callbackFunctionA callback which is called when command is launched.
scopeObjectA scope, in which the callback has to be called.

Example 1

This example demonstrates how to set the command buttons for a WebController. It will set two commands on primary command button for switching to previous/next tab on a form.

  1. // Create primary command on form with two options
  2. MobileCRM.UI.ViewController.createCommand(
  3. true,
  4. ['Previous', 'Next'],
  5. function (command) {
  6. MobileCRM.UI.EntityForm.requestObject(
  7. function (entityForm) {
  8. // Handle command and select previous/next tab on the form
  9. if (command == 'Previous')
  10. entityForm.form.selectedViewIndex--;
  11. else
  12. entityForm.form.selectedViewIndex++;
  13. return true;
  14. }
  15. );
  16. },
  17. null
  18. );

MobileCRM.UI.ViewDefinition Object

Represents the entity view definition.

Properties

PropertyTypeDescription
entityNameStringGets the entity this view is for.
nameStringGets the name of the view.
fetchStringGets the fetchXml query.
kindNumberGets the kind of the view (public, associated, etc.).
versionNumberGets the version.
buttonsStringGets the view buttons.
selectorStringGets the view template selector workflow.

Functions

FunctionDescription
loadEntityViewsAsynchronously loads all view definitions for given entity.

MobileCRM.UI.ViewDefinition.loadEntityViews Function

Asynchronously loads all view definitions for given entity.

Arguments

ArgumentTypeDescription
entityNameStringThe entity name.
callbackfunction(viewDefArray)The callback function which is called asynchronously. Callback will obtain an array of ViewDefinition objects.
errorCallbackfunction(errorMsg)The errorCallback which is called asynchronously in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to load entity existing views.

  1. function loadViews(entityName) {
  2. MobileCRM.UI.ViewDefinition.loadEntityViews(
  3. entityName,
  4. function (views) {
  5. /// <param name="views" type="Array"/>
  6. if (views != undefined && views.length > 0) {
  7. var viewNames = "";
  8. for (var i in views) {
  9. viewNames += views[i].name;
  10. }
  11. MobileCRM.bridge.alert(viewNames);
  12. }
  13. },
  14. MobileCRM.bridge.alert,
  15. null
  16. );
  17. }

MobileCRM.UI._AppointmentView Object

Represents the Javascript equivalent view of tourplan form object.

Properties

PropertyTypeDescription
nameStringGets the name of view.
isVisibleBooleanGets or sets whether the view is visible.
modeMobileCRM.UI.TourplanViewModeGets a view mode MobileCRM.UI.TourplanViewMode.
currentDateDateGets the current date of displayed view.

MobileCRM.UI._Controller Object

Represents the Javascript equivalent of the view controller object.

Properties

PropertyTypeDescription
isDirtyBooleanGets or sets whether the controller contains dirty data that should be saved.
isLoadedBooleanGets or sets whether the controller is loaded.
viewMobileCRM.UI._ViewGets or sets the view (control) instance.

MobileCRM.UI._DetailItem Object

Represents the Javascript equivalent of detail item which is controlling the field editing.

Properties

PropertyTypeDescription
dataMemberStringGets or sets the item data binding.
errorMessageStringGets or sets the item error message displayed during validation.
isEnabledBooleanGets or sets whether the item is editable.
isNullableBoolean Gets or sets whether the item value can be "null".
isVisibleBooleanGets or sets whether the item is visible.
labelStringGets or sets the item label.
nameStringGets or sets the item name.
validateBooleanGets or sets whether the item needs validation.
 
isPassword (text items only)BooleanGets or sets whether the text value should be masked. Used for password entry.
kind (text items only)NumberGets or sets the value kind (0 for Text, 1 for Email, 2 for Url, 3 for Phone).
maxLength (text items only)NumberGets to sets the maximum text length.
numberOfLines (text items only)NumberNumber of lines to display. Default is one.
value (text items only)StringGets or sets the bound item value.
 
decimalPlaces (numeric items only)NumberGets or sets the number of decimal places.
displayFormat (numeric items only)String
increment (numeric items only)NumberGets or sets the increment (if the Up/Down control is visible).
maximum (numeric items only)NumberGets or sets the maximum allowed value.
minimum (numeric items only)NumberGets or sets the minimum allowed value.
upDownVisible (numeric items only)BooleanGets or sets whether the up/down control is visible.
value (numeric items only)NumberGets or sets the bound item value.
 
textChecked (boolean items only)StringGets or sets the text for checked state.
textUnchecked (boolean items only)StringGets or sets the text for unchecked state.
value (boolean items only)BooleanGets or sets the bound item value.
 
parts (DateTime items only)NumberGets or sets whether to display and edit the date, time or both (0=both, 1=date only, 2=time only).
value (DateTime items only)DateGets or sets the bound item value.
 
value (Duration items only)NumberGets or sets the bound item value (duration in minutes).
 
displayMember (OptionSet items only)StringGets or sets the name of the property whose value is used as the label of an option.
value (OptionSet items only)NumberGets or sets the bound item value (selected value).
valueMember (OptionSet items only)StringGets or sets the name of the property whose value is used as the value of an option. Set "null" to use the option object as the value.
 
isMultiline (Link items only)BooleanGets or sets whether the item is multiline. Default is false.
value (Link items only)MobileCRM.ReferenceGets or sets the bound item value (a MobileCRM.Reference object or "null").
 

MobileCRM.UI._DetailView Object

Represents the Javascript equivalent of detail view with set of items responsible for fields editing.

Properties

PropertyTypeDescription
isDirtyBooleanIndicates whether the value of an item has been modified.
isEnabledBooleanGets or sets whether the all items are enabled or disabled.
isVisibleBooleanGets or sets whether the view is visible.
itemsArrayAn array of MobileCRM.UI._DetailItem objects
nameStringGets the name of the view

Methods

MethodDescription
getItemByNameReturns the MobileCRM.UI._DetailItem with specified name or "null".
getItemIndexReturns index of MobileCRM.UI._DetailItem with specified name or -1.
insertItem[v8.0] Inserts the MobileCRM.UI.DetailViewItems.Item into this detailed view.
insertItems[v8.0] Inserts the MobileCRM.UI.DetailViewItems.Item into this detailed view.
registerClickHandler[v8.0] Installs the handler which has to be called when user clicks on the link item.
removeItem[v8.0] Removes the item from this detailed view.
removeItems[v8.0] Removes all items from this detailed view.
startEditItem[v9.2] Starts editing the detail item and sets the focus on it.
updateComboItemDataSource[v9.1] Changes the data source for CombobBoxitem MobileCRM.UI.DetailViewItems.ComboBoxItem.
updateLinkItemViews[v10.1] Changes the ComboBoxItem views and/or filters.

MobileCRM.UI._DetailView.getItemByName Method

Returns the MobileCRM.UI._DetailItem with specified name or "null".

Arguments

ArgumentTypeDescription
nameStringA name of requested detail item.

Return value

Type: MobileCRM.UI._DetailItem

An instance of MobileCRM.UI._DetailItem with specified name or "null".

Example 1

This example demonstrates how to get specific detail item object. In our case it takes the one with name "SaveLink"

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  4. var detailView = entityForm.getDetailView("General");
  5. var linkItem = detailView.getItemByName("SaveLink");
  6. // ...
  7. }, MobileCRM.bridge.alert, null);

MobileCRM.UI._DetailView.getItemIndex Method

Returns index of MobileCRM.UI._DetailItem with specified name or -1.

Arguments

ArgumentTypeDescription
nameStringA name of requested detail item.

Return value

Type: Number

Index of MobileCRM.UI._DetailItem with specified name or -1.


MobileCRM.UI._DetailView.insertItem Method

[v8.0] Inserts the MobileCRM.UI.DetailViewItems.Item into this detailed view.

Arguments

ArgumentTypeDescription
itemMobileCRM.UI.DetailViewItems.ItemAn item to be added.
indexNumberAn index on which the item should be placed. Set to -1 to append the item at the end.

Example 1

This example demonstrates how to insert the link/check box items on existing detail view tab, how to handle the changes and how to bind the click handler for link item.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var linkItem = detailView.getItemByName("SaveLink");
  5. if (linkItem) {
  6. // The item was already inserted on the form.
  7. // Just set the value property and bind the handler.
  8. linkItem.setTypedValue("value", "System.String", "Save"); // The type must be set explicitly for LinkItem
  9. detailView.registerClickHandler(linkItem, onLinkItemClick);
  10. }
  11. else {
  12. // create MobileCRM.UI.DetailViewItems.LinkItem
  13. linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", "Save");
  14. detailView.registerClickHandler(linkItem, onLinkItemClick);
  15. detailView.insertItem(linkItem, -1); // Place the item as the last one.
  16. }
  17. var checkBoxItem = detailView.getItemByName("ShowDetails");
  18. if (checkBoxItem) {
  19. // The item was already inserted on the form.
  20. // Just set the value property.
  21. checkBoxItem.value = true;
  22. }
  23. else {
  24. // create MobileCRM.UI.DetailViewItems.CheckBoxItem
  25. checkBoxItem = new MobileCRM.UI.DetailViewItems.CheckBoxItem("ShowDetails", "Show Details");
  26. checkBoxItem.value = true;
  27. detailView.insertItem(checkBoxItem, 0); // Place the item as the first one.
  28. }
  29. }, MobileCRM.bridge.alert, null);
  30.  
  31. function onLinkItemClick(itemName, detailViewName) {
  32. MobileCRM.UI.EntityForm.saveAndClose();
  33. }
  34.  
  35. MobileCRM.UI.EntityForm.onChange(
  36. function (entityForm) {
  37. if (entityForm.context.changedItem == "ShowDetails") {
  38. var detailView = entityForm.getDetailView("General");
  39. var checkBoxItem = detailView.getItemByName("ShowDetails");
  40. if (checkBoxItem.value) {
  41. // Show your details
  42. }
  43. else {
  44. // Hide your details.
  45. }
  46. }
  47. },
  48. MobileCRM.bridge.alert, null);

MobileCRM.UI._DetailView.insertItems Method

[v8.0] Inserts the MobileCRM.UI.DetailViewItems.Item into this detailed view.

Arguments

ArgumentTypeDescription
itemsArray(MobileCRM.UI.DetailViewItems.Item)An array of items to be added.
indexNumberAn index on which the items should be placed. Set to -1 to append the items at the end.

MobileCRM.UI._DetailView.registerClickHandler Method

[v8.0] Installs the handler which has to be called when user clicks on the link item.

Arguments

ArgumentTypeDescription
itemMobileCRM.UI.DetailViewItems.LinkItemAn item
callbackfunction(String, String)A callback which is called when user clicks on the link item. It obtains the link item name and the detail view name as arguments.
scopeObjectA scope, in which the callback has to be called.

Example 1

This example demonstrates how to register the event handler on the detail link item.

  1. function registerEvent(itemName){
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. var detailView = entityForm.getDetailView("General");
  5. var linkItem = detailView.getItemByName(itemName);
  6. if (linkItem) {
  7. // The item was already inserted on the form.
  8. // Just set the value property and bind the handler.
  9. linkItem.setTypedValue("value", "System.String", itemName); // The type must be set explicitly for LinkItem
  10. detailView.registerClickHandler(linkItem, onLinkItemClick);
  11. }
  12. else {
  13. // create MobileCRM.UI.DetailViewItems.LinkItem
  14. linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", itemName);
  15. detailView.registerClickHandler(linkItem, onLinkItemClick);
  16. detailView.insertItem(linkItem, -1); // Place the item as the last one.
  17. }
  18. },
  19. MobileCRM.bridge.alert
  20. );
  21. }
  22. function onLinkItemClick(itemName, detailViewName) {
  23. /// <param name="itemName" type="String">The name of detail view item which has been clicked.</params>
  24. /// <param name="detailViewName" type="String">The name of detail view which contains the clicked item.</params>
  25. MobileCRM.UI.EntityForm.saveAndClose();
  26. }

MobileCRM.UI._DetailView.removeItem Method

[v8.0] Removes the item from this detailed view.

Arguments

ArgumentTypeDescription
indexNumberAn index of the item which has to be removed.

Example 1

This example demonstrates how to remove the detail item from the detail view by its name.

  1. function removeItem(itemName) {
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. var detailView = entityForm.getDetailView("General");
  5. var items = detailView.items;
  6. for (var i in items) {
  7. if (items[i].name == itemName) {
  8. detailView.removeItem(i);
  9. return;
  10. }
  11. }
  12. },
  13. MobileCRM.bridge.alert
  14. );
  15. }

MobileCRM.UI._DetailView.removeItems Method

[v8.0] Removes all items from this detailed view.

Arguments

ArgumentTypeDescription
indexesArrayAn array of item indexes that has to be removed.

Example 1

This example demonstrates how to remove detail items with name 'SaveLink' and 'TextItem' from the detail view if exists.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var items = detailView.items;
  5. var indexes = [];
  6. for (var i in items) {
  7. if (items[i].name == "SaveLink")
  8. indexes.push(i);
  9. else if (items[i].name == "TextItem")
  10. indexes.push(i);
  11. else if (indexes.length == 2)
  12. break;
  13. }
  14. detailView.removeiItems(indexes);
  15. },
  16. MobileCRM.bridge.alert
  17. );

MobileCRM.UI._DetailView.startEditItem Method

[v9.2] Starts editing the detail item and sets the focus on it.

Arguments

ArgumentTypeDescription
indexNumberSelected item index.

Example 1

This example demonstrates how to focus specific item (with index 1) and initiate its editing.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  4. var detailView = entityForm.getDetailView("General");
  5. detailView.startEditItem(1);
  6. }, MobileCRM.bridge.alert, null);

MobileCRM.UI._DetailView.updateComboItemDataSource Method

[v9.1] Changes the data source for CombobBoxitem MobileCRM.UI.DetailViewItems.ComboBoxItem.

Arguments

ArgumentTypeDescription
indexNumberItem index on the view.
listDataSourceObjectThe data source object (e.g. {"label1":1, "label2":2}).
valueTypeStringType of list data source element value. Default is string, allowed int, string.
defaultValueStringNew data source default value. If not defined, the first item from listDataSource will be used.

Example 1

This example demonstrates how to change the data source of a custom combo box item. Refer to MobileCRM.UI.DetailViewItems.ComboBoxItem object to see how to create a custom combo-box item.

  1. function updateCustomComboboxSource(name) {
  2. MobileCRM.UI.EntityForm.requestObject(
  3. function (entityForm) {
  4. /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
  5. var detailView = entityForm.getDetailView("General");
  6. var itemIndex = detailView.getItemIndex(name);
  7. if (itemIndex >= 0)
  8. detailView.updateComboItemDataSource(itemIndex, { "New Option 1": "1", "New Option 2": "2" });
  9. }, true, null);
  10. }

MobileCRM.UI._DetailView.updateLinkItemViews Method

[v10.1] Changes the ComboBoxItem views and/or filters.

Arguments

ArgumentTypeDescription
indexNumberItem index on the view.
dialogSetupMobileCRM.UI.DetailViewItems.LookupSetupLookup setup for modal lookup dialog.
inlinePickSetupMobileCRM.UI.DetailViewItems.LookupSetupOptional setup for inline lookup picker. Leave empty to use the same setup as modal dialog.

Example 1

This example demonstrates how change the view for the detail view link item. It sets the view or fetch XML for ParentCustomer field on Contact entity.

  1. MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
  2. /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
  3. // Take detail view with name "General"
  4. var dv = entityForm.getDetailView("General");
  5. var inlineSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
  6. // Set Account entity view with name "ContactParents" defining the filter for accounts
  7. // that should be present in the inline lookup for this field.
  8. inlineSetup.addView("account", "ContactParents", true);
  9. // Alternatively, specify the explicit fetch XML filter for inline lookup
  10. // inlineSetup.addFilter("account", '<fetch version="1.0"><entity name="account">...</entity></fetch>');
  11.  
  12. var dialogSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
  13. // Set "Default" view for expanded lookup form
  14. dialogSetup.addView("account", "Default", true);
  15. //dialogSetup.addFilter("account", '<fetch version="1.0"><entity name="account">...</entity></fetch>');
  16.  
  17. var dialogOnly = false; // Allow both inline lookup and expanded lookup dialog
  18. dv.updateLinkItemViews(0, dialogSetup, inlineSetup, dialogOnly);
  19. }, onError, null);
  20.  
  21. function onError(error) {
  22. /// <param name="error" type="String"/>
  23. if (error) MobileCRM.bridge.alert(error);
  24. }

MobileCRM.UI._EntityList Object

Represents the Javascript equivalent of the entity list controller object.

Properties

PropertyTypeDescription
allowAddExistingBooleanGets or sets whether adding an existing entity is allowed. If false only the creation of new entities is allowed, otherwise the user can selected an existing entity. Adding an existing entity works only when the list is displaying a list of related entities.
allowedViewsObjectGets or sets the allowed views (e.g. {"view1":"Label 1", "view2":"Label 2"};).
entityNameStringGets the name of the entities in this list.
hasMapViewsBooleanGets whether the list has a view that can be displayed on map.
internalNameStringGets the internal list name. Used for localization and image lookup.
isDirtyBooleanGets or sets whether the list is dirty.
isLoadedBooleanGets or sets whether the list is loaded.
listButtonsArrayGets or sets the list buttons.
listViewMobileCRM.UI._ListViewGets the list view control.

MobileCRM.UI._ListView Object

Represents the Javascript equivalent of the list view (control) object.

Properties

PropertyTypeDescription
isVisibleBooleanGets or sets whether the view is visible.
nameStringGets the name of the view.
selectedIndexNumberGets or sets the index of the selected row.
templateIndexNumberGets or sets the index of the template used to paint rows in the normal state.
selectedTemplateIndexNumberGets or sets the index of the template used to paint rows in the selected state.
isScrollEnabledBooleanGets or sets whether list can scroll. Default true.

MobileCRM.UI._View Object

Represents the Javascript equivalent of the view (control) object.

Properties

PropertyTypeDescription
isVisibleBooleanGets or sets whether the view is visible.
nameStringGets the name of the view.

MobileCRM.UI.DetailViewItems Namespace

Contains a set of objects representing particular detail view items.

Objects

ObjectDescription
CheckBoxItem[8.0] Represents the checkbox item.
ComboBoxItem[8.0] Represents the combobox item.
DateTimeItem[8.0] Represents the date/time item.
DropDownFormatAn enumeration defining the values of LinkItem's dropdown format.
DurationItem[8.0] Represents the duration item.
Item[8.0] Represents the item.
LinkItem[8.0] Represents the link item.
LookupSetupRepresents a configuration for lookup and inline lookup.
NumericItem[8.0] Represents the numeric item.
SeparatorItem[8.0] Represents the separator item.
TextBoxItem[8.0] Represents the text item.

MobileCRM.UI.DetailViewItems.CheckBoxItem Object

[8.0] Represents the checkbox item.

Properties

PropertyTypeDescription
textCheckedStringGets or sets the text for checked state.
textUncheckedStringGets or sets the text for unchecked state.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.CheckBoxItem object.

MobileCRM.UI.DetailViewItems.CheckBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.CheckBoxItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to append the new 'ShowDetails' CheckBoxItem on the form and handle its changes.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var checkBoxItem = detailView.getItemByName("ShowDetails");
  5. if (checkBoxItem)
  6. checkBoxItem.value = true;
  7. else {
  8. checkBoxItem = new MobileCRM.UI.DetailViewItems.CheckBoxItem("ShowDetails", "Show Details");
  9. checkBoxItem.value = true;
  10. checkBoxItem.textChecked = "Checked";
  11. checkBoxItem.textUnchecked = "Unchecked";
  12. checkBoxItem.isNullable = false;
  13. detailView.insertItem(checkBoxItem, 0); // Place the item as the fist one.
  14. }
  15. },
  16. MobileCRM.bridge.alert,
  17. null
  18. );
  19.  
  20. MobileCRM.UI.EntityForm.onChange(
  21. function (entityForm) {
  22. if (entityForm.context.changedItem == "ShowDetails") {
  23. var detailView = entityForm.getDetailView("General");
  24. var checkBoxItem = detailView.getItemByName("ShowDetails");
  25. if (checkBoxItem.value) {
  26. // Show your details
  27. }
  28. else {
  29. // Hide your details.
  30. }
  31. }
  32. },
  33. MobileCRM.bridge.alert,
  34. null
  35. );

MobileCRM.UI.DetailViewItems.ComboBoxItem Object

[8.0] Represents the combobox item.

Properties

PropertyTypeDescription
listDataSourceObjectGets or sets the object with props and values to be displayed in the combo list (e.g. {"label1":1, "label2":2}).

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.ComboBoxItem object.

MobileCRM.UI.DetailViewItems.ComboBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.ComboBoxItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new ComboBoxItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var comboItem = detailView.getItemByName("MyOptions");
  5. if (comboItem)
  6. comboItem.value = "val1";
  7. else {
  8. comboItem = new MobileCRM.UI.DetailViewItems.ComboBoxItem("MyOptions", "Choose Options");
  9. comboItem.value = "val1";
  10. comboItem.listDataSource = {
  11. "Label 1": "val1",
  12. "Label 2": "val2",
  13. };
  14. detailView.insertItem(comboItem, -1); // Place the item as the last one.
  15. }
  16. },
  17. MobileCRM.bridge.alert
  18. );
  19.  
  20. MobileCRM.UI.EntityForm.onChange(
  21. function (entityForm) {
  22. if (entityForm.context.changedItem == "MyOptions") {
  23. var detailView = entityForm.getDetailView("General");
  24. var item = detailView.getItemByName("MyOptions");
  25. MobileCRM.bridge.alert(item.value); // Show an alert with currently chosen value
  26. }
  27. },
  28. MobileCRM.bridge.alert
  29. );

MobileCRM.UI.DetailViewItems.DateTimeItem Object

[8.0] Represents the date/time item.

Properties

PropertyTypeDescription
minimumDateGets or sets the minimum allowed value.
maximumDateGets or sets the maximum allowed value.
partsNumber Gets or sets whether to display and edit the date, time or both.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.DateTimeItem object.

MobileCRM.UI.DetailViewItems.DateTimeItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.DateTimeItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new DateTimeItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var dateItem = detailView.getItemByName("StartTime");
  5. if (dateItem)
  6. dateItem.value = new Date(); // Set current time
  7. else {
  8. dateItem = new MobileCRM.UI.DetailViewItems.DateTimeItem("StartTime", "Start Time");
  9. dateItem.value = new Date(); // Set current time
  10. dateItem.parts = 1;
  11. detailView.insertItem(dateItem, -1); // Place the item as the last one.
  12. }
  13. },
  14. MobileCRM.bridge.alert,
  15. null
  16. );
  17.  
  18. MobileCRM.UI.EntityForm.onChange(
  19. function (entityForm) {
  20. if (entityForm.context.changedItem == "StartTime") {
  21. var detailView = entityForm.getDetailView("General");
  22. var item = detailView.getItemByName("StartTime");
  23. MobileCRM.bridge.alert(item.value); // Show an alert with changed date&time
  24. }
  25. },
  26. MobileCRM.bridge.alert,
  27. null
  28. );

MobileCRM.UI.DetailViewItems.DropDownFormat Object

An enumeration defining the values of LinkItem's dropdown format.

Properties

PropertyTypeDescription
StringListNumberStringList dropdown format.
StringListInputNumberStringListInput dropdown format.
MultiStringListNumberMultiStringList dropdown format.
MultiStringListInputNumberMultiStringListInput dropdown format.

MobileCRM.UI.DetailViewItems.DurationItem Object

[8.0] Represents the duration item.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.DurationItem object.

MobileCRM.UI.DetailViewItems.DurationItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.DurationItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new DurationItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var item = detailView.getItemByName("EventDuration");
  5. if (item)
  6. item.value = 65; // value is in seconds.
  7. else {
  8. item = new MobileCRM.UI.DetailViewItems.DurationItem("EventDuration", "Duration");
  9. item.value = 65;
  10. detailView.insertItem(item, -1); // Place item as the last one.
  11. }
  12. },
  13. MobileCRM.bridge.alert, null
  14. );
  15.  
  16. MobileCRM.UI.EntityForm.onChange(
  17. function (entityForm) {
  18. if (entityForm.context.changedItem == "EventDuration") {
  19. var detailView = entityForm.getDetailView("General");
  20. var item = detailView.getItemByName("EventDuration");
  21. MobileCRM.bridge.alert(item.value + " seconds."); // Show an alert with changed duration in seconds.
  22. }
  23. },
  24. MobileCRM.bridge.alert,
  25. null
  26. );

MobileCRM.UI.DetailViewItems.Item Object

[8.0] Represents the item.

Properties

PropertyTypeDescription
nameStringGets or sets the item name.
labelStringGets or sets the item label.
dataMemberStringGets or sets the name of the property containing the item value in data source objects.
errorMessageStringGets or sets the item error message.
isEnabledBooleanGets or sets whether the item is editable.
isVisibleBooleanGets or sets whether the item is visible.
valueObjectGets or sets the bound item value.
isNullableBooleanGets or sets whether the item value can be "null".
validateBooleanGets or sets whether the item needs validation.
styleStringThe name of the Woodford item style.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.Item object.

MobileCRM.UI.DetailViewItems.Item.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.Item object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

MobileCRM.UI.DetailViewItems.LinkItem Object

[8.0] Represents the link item.

Properties

PropertyTypeDescription
isMultiLineBooleanGets or sets whether the item is multiline. Default is false.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.LinkItem object.

MobileCRM.UI.DetailViewItems.LinkItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.LinkItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.
listDropDownFormatMobileCRM.UI.DetailViewItems.DropDownFormatDefines item's drop down format.

Example 1

This example demonstrates how to get detail view and create new LinkItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var linkItem = detailView.getItemByName("SaveLink");
  5. if (linkItem) {
  6. // The item was already inserted on the form.
  7. // Just set the value property and bind the handler.
  8. linkItem.setTypedValue("value", "System.String", "Save"); // The type must be set explicitly for LinkItem
  9. detailView.registerClickHandler(linkItem, onLinkItemClick);
  10. }
  11. else {
  12. // create MobileCRM.UI.DetailViewItems.LinkItem
  13. linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", "Save");
  14. detailView.registerClickHandler(linkItem, onLinkItemClick);
  15. detailView.insertItem(linkItem, -1); // Place the item as the last one.
  16. }
  17. }, MobileCRM.bridge.alert, null);
  18.  
  19. function onLinkItemClick(itemName, detailViewName) {
  20. MobileCRM.UI.EntityForm.saveAndClose();
  21. }

MobileCRM.UI.DetailViewItems.LookupSetup Object

Represents a configuration for lookup and inline lookup.

Defines the lookup records filter for updateLinkItemViews

Methods

MethodDescription
addFilterDefines a fetch XML filter for entity records.
addViewAppends an entity view to the list of allowed views.

MobileCRM.UI.DetailViewItems.LookupSetup.addFilter Method

Defines a fetch XML filter for entity records.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
filterXmlstringA string defining the fetch XML which has to be applied as filter for entity records.

MobileCRM.UI.DetailViewItems.LookupSetup.addView Method

Appends an entity view to the list of allowed views.

Arguments

ArgumentTypeDescription
entityNamestringEntity logical name.
viewNamestringA name of the view.
isDefaultBooleantrue, if the view should be set as default.

MobileCRM.UI.DetailViewItems.NumericItem Object

[8.0] Represents the numeric item.

Properties

PropertyTypeDescription
minimumNumberGets or sets the minimum allowed value.
maximumNumberGets or sets the maximum allowed value.
incrementNumberGets or sets the increment (if the upDownVisible is true).
upDownVisibleBooleanGets or sets whether the up/down control is visible.
decimalPlacesNumberGets or sets the number of decimal places.
displayFormatStringGets or sets the value format string.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.NumericItem object.

MobileCRM.UI.DetailViewItems.NumericItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.NumericItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new NumericItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var item = detailView.getItemByName("Length");
  5. if (item)
  6. item.value = 55.333;
  7. else {
  8. item = new MobileCRM.UI.DetailViewItems.NumericItem("Length", "Length in meters");
  9. item.decimalPlaces = 2;
  10. item.value = 55.333;
  11. detailView.insertItem(item, -1); // Place the item as the last one.
  12. }
  13. },
  14. MobileCRM.bridge.alert, null
  15. );
  16.  
  17. MobileCRM.UI.EntityForm.onChange(
  18. function (entityForm) {
  19. if (entityForm.context.changedItem == "Length") {
  20. var detailView = entityForm.getDetailView("General");
  21. var item = detailView.getItemByName("Length");
  22. MobileCRM.bridge.alert(item.value); // Show an alert with changed length
  23. }
  24. },
  25. MobileCRM.bridge.alert,
  26. null
  27. );

MobileCRM.UI.DetailViewItems.SeparatorItem Object

[8.0] Represents the separator item.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.SeparatorItem object.

MobileCRM.UI.DetailViewItems.SeparatorItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.SeparatorItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new SeparatorItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var item = detailView.getItemByName("SectionSeparator");
  5. if (!item) {
  6. item = new MobileCRM.UI.DetailViewItems.SeparatorItem("SectionSeparator", "Next Section");
  7. detailView.insertItem(item, 2); // Insert item on the third place (index is zero-based). Index -1 puts item as the last one.
  8. }
  9. },
  10. MobileCRM.bridge.alert, null
  11. );

MobileCRM.UI.DetailViewItems.TextBoxItem Object

[8.0] Represents the text item.

Properties

PropertyTypeDescription
numberOfLinesNumberGets or sets the number of lines to display. Default is one.
isPasswordBooleanGets or sets whether the text value should be masked. Used for password entry.
maxLengthNumberGets to sets the maximum text length.
kindNumberGets or sets the value kind (Text=0, Email=1, Url=2, Phone=3, Barcode=4).
placeholderTextNumberGets or sets the text that is displayed in the control until the value is changed by a user action or some other operation. Default is empty string.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.UI.DetailViewItems.TextBoxItem object.

MobileCRM.UI.DetailViewItems.TextBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.TextBoxItem object.

Arguments

ArgumentTypeDescription
nameStringDefines the item name.
labelStringDefines the item label.

Example 1

This example demonstrates how to get detail view and create new TextBoxItem.

  1. MobileCRM.UI.EntityForm.requestObject(
  2. function (entityForm) {
  3. var detailView = entityForm.getDetailView("General");
  4. var item = detailView.getItemByName("Description");
  5. if (item)
  6. item.value = "first line \n second line";
  7. else {
  8. item = new MobileCRM.UI.DetailViewItems.TextBoxItem("Description", "Description (max 2 lines)");
  9. item.value = "first line \n second line";
  10. item.numberOfLines = 2;
  11. detailView.insertItem(item, -1); // Place the item as the last one.
  12. }
  13. },
  14. MobileCRM.bridge.alert
  15. );
  16.  
  17. MobileCRM.UI.EntityForm.onChange(
  18. function (entityForm) {
  19. if (entityForm.context.changedItem == "Description") {
  20. var detailView = entityForm.getDetailView("General");
  21. var item = detailView.getItemByName("Description");
  22. MobileCRM.bridge.alert(item.value); // Show an alert with changed length
  23. }
  24. },
  25. MobileCRM.bridge.alert,
  26. null
  27. );

MobileCRM.Services Namespace

Contains non-UI classes for accessing documents...

Objects

ObjectDescription
AddressBookService[v9.1] Represents a service for accessing the address book.
AudioRecorder[v10.0] Represents a service for recording an audio.
ChatService[v9.3] Represents a service for sending instant messages to users or shared channels.
DocumentService[v8.1] Represents a service for acquiring the documents.
DynamicsReport[v10.0] Represents a service for downloading MS Dynamics reports.
FileInfoCarries the result of a DocumentService operation.
GeoAddress[v9.3] Represents a service for translating geo position into the civic address and back.
HttpWebRequest[v11.0] Instance of http web request.
SynchronizationResult[v8.1] Represents the synchronization result.

MobileCRM.Services.AddressBookService Object

[v9.1] Represents a service for accessing the address book.

Methods

MethodDescription
getContact[v9.1] Gets an address book contact by its ID.

Functions

FunctionDescription
getService[v9.1] Gets an instance of AddressBookService object.

Objects

ObjectDescription
AddressBookRecord

MobileCRM.Services.AddressBookService.getContact Method

[v9.1] Gets an address book contact by its ID.

Arguments

ArgumentTypeDescription
idStringRequested contact id.
callbackfunction(MobileCRM.Services.AddressBookService.AddressBookRecord)The callback function which is called asynchronously with MobileCRM.Services.AddressBookService.AddressBookRecord object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.AddressBookService.getService Function

[v9.1] Gets an instance of AddressBookService object.

Arguments

ArgumentTypeDescription
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Return value

Type: MobileCRM.Services.AddressBookService

An instance of AddressBookService object.

Example 1

This example demonstrates how to receive information about record from address book.

  1. function onAddressBookService() {
  2. var addressbook = MobileCRM.Services.AddressBookService.getService(MobileCRM.bridge.alert, null);
  3. addressbook.getContact("1", processContactRecord, MobileCRM.bridge.alert, null);
  4. }
  5.  
  6. function processContactRecord(contactRecord) {
  7. /// <param name='contactRecord' type='MobileCRM.Services.AddressBookService.AddressBookRecord'/>
  8. var jobTitle = contactRecord.jobTitle;
  9. var firstName = contactRecord.firstName;
  10. var lastName = contactRecord.lastName;
  11.  
  12. MobileCRM.bridge.alert("Contact : " + jobTitle + " " + lastName + " " + firstName);
  13. }

MobileCRM.Services.AddressBookService.AddressBookRecord Object

Properties

PropertyTypeDescription
recordIdStringRecord id.
firstNameStringRecord first name.
lastNameStringRecord last name.
middleNameStringRecord middle name.
nickNameStringRecord nick name.
jobTitleStringJob title.
organizationStringOrganization name.
prefixStringName prefix (Title) name.
suffixStringName suffix (Title) name.
geoArrayAddress GPS coordinates.
urlStringWeb page URL of record.

MobileCRM.Services.AudioRecorder Object

[v10.0] Represents a service for recording an audio.

Methods

MethodDescription
getRecordBase64[v10.0] Returns recorded audio from microphone as base64 string
getRecordFilePath[v10.0] Returns absolute path to the file containing the record
stopRecording[v10.0] Stops recording audio from microphone

Functions

FunctionDescription
startRecording[v10.0] Starts recording audio from microphone

MobileCRM.Services.AudioRecorder.getRecordBase64 Method

[v10.0] Returns recorded audio from microphone as base64 string

Arguments

ArgumentTypeDescription
callbackfunction(String)The callback function that is called asynchronously with the base64-encoded recording data.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.AudioRecorder.getRecordFilePath Method

[v10.0] Returns absolute path to the file containing the record

Arguments

ArgumentTypeDescription
callbackfunction(String)The callback function that is called asynchronously with the file path.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.AudioRecorder.stopRecording Method

[v10.0] Stops recording audio from microphone

Arguments

ArgumentTypeDescription
callbackfunctionThe callback function which is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.AudioRecorder.startRecording Function

[v10.0] Starts recording audio from microphone

Arguments

ArgumentTypeDescription
callbackfunctionThe callback function which is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to intialize audiorecording and how to use recorded data in HTML 5.

  1. var audioRecorder = MobileCRM.Services.AudioRecorder.startRecording(function (res) { }, MobileCRM.bridge.alert, null);
  2. audioRecorder.stopRecording(function () {
  3. var filePath = audioRecorder.getRecordFilePath(function (path) {
  4. if (path) {
  5. audioRecorder.getRecordBase64(function (base64) {
  6. // requires HTML 5
  7. var audioElemet = document.createElement("audio");
  8. if (audioElemet) {
  9. audioElemet.src = "data:audio/mp3:base64," + base64;
  10. }
  11. }, MobileCRM.bridge.alert, null);
  12. }
  13. }, MobileCRM.bridge.alert, null);
  14. }, MobileCRM.bridge.alert, null);

MobileCRM.Services.ChatService Object

[v9.3] Represents a service for sending instant messages to users or shared channels.

Instance of this object cannot be created directly. Use MobileCRM.Services.ChatService.getService to create new instance.

Properties

PropertyTypeDescription
chatUserMobileCRM.DynamicEntityAn instance of the resco_chatuser entity for current user (either system or external).
userEntityStringThe user entity name (either systemuser or external user entity name).
userIdStringPrimary key (id) of the current user (either system or external).

Methods

MethodDescription
attachNoteToPostCreates a note (annotation) entity with the file attachment related to specified post.
postMessageSubmits a new post into the channel defines by related entity reference.
subscribeToEntityChannelSubscribes current user to a channel specified by related entity.

Functions

FunctionDescription
getServiceAsynchronously creates the new instance of the ChatService.

MobileCRM.Services.ChatService.attachNoteToPost Method

Creates a note (annotation) entity with the file attachment related to specified post.

The file path can be either a relative path to application data or a full path to a file being attached.

Arguments

ArgumentTypeDescription
postIdStringAn id of the resco_chatpost entity which should have the note attached.
filePathStringA path to a file that has to be attached.
mimeTypeStringA MIME type of the file.
subjectStringA text which will be used as note's subject.
callbackfunction(MobileCRM.DynamicEntity)The callback function which is called asynchronously with MobileCRM.DynamicEntity representing newly created annotation record.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.ChatService.postMessage Method

Submits a new post into the channel defines by related entity reference.

Use reference to resco_chattopic entity to specify a shared channel or reference to a peer user to specify the private channel.

Arguments

ArgumentTypeDescription
regardingEntityMobileCRM.ReferenceA reference to an entity that the post should relate to.
textStringThe post content.
callbackfunction(MobileCRM.DynamicEntity)The callback function which is called asynchronously with MobileCRM.DynamicEntity representing newly created resco_chatpost record.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.ChatService.subscribeToEntityChannel Method

Subscribes current user to a channel specified by related entity.

Use reference to resco_chattopic entity to specify a shared channel.

Arguments

ArgumentTypeDescription
regardingEntityMobileCRM.ReferenceReference to an entity that has to be subscribed/unsubscribed.
subscribeBooleanDetermines whether to subscribe or unsubscribe entity channel.
callbackFunctionThe callback function which is called asynchronously in case of success.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how subscribe current chat user to an entity channel.

  1. function joinChannel(entityRef) {
  2. /// <param name="entityRef" type="MobileCRM.Reference">
  3. /// Reference to an entity whose channel we want to join.
  4. /// </param>
  5. MobileCRM.Services.ChatService.getService(function (service) {
  6. service.subscribeToEntityChannel(entityRef, true, function () {
  7. MobileCRM.UI.MessageBox.sayText("You've joined the channel " + entityRef.primaryName);
  8. }, MobileCRM.bridge.alert);
  9. }, MobileCRM.bridge.alert);
  10. }

MobileCRM.Services.ChatService.getService Function

Asynchronously creates the new instance of the ChatService.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.ChatService)The callback function which is called asynchronously with MobileCRM.Services.ChatService instance as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.DocumentService Object

[v8.1] Represents a service for acquiring the documents.

Properties

PropertyTypeDescription
maxImageSizeNumberGets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size.
recordQualityNumberGets or sets the record quality for audio/video recordings.
allowChooseVideoBooleanIndicates whether the video files should be included into the image picker when selecting the photos. The default is true.
allowMultipleFilesBooleanIndicates whether to allow multiple files for DocumentActions SelectPhoto and SelectFile.[Not implemented on iOS.]

Methods

MethodDescription
capturePhotoAsks the user to capture a photo and calls the async callback with file info.
pasteFileTakes the file from clipboard and calls the async callback with file info.
print[v9.1] Prints the document defined by file path.
recordAudioAsks the user to record an audio note and calls the async callback with file info.
recordVideoAsks the user to record an video and calls the async callback with file info.
resizeImage[v11.1] Resize image defined by file path.
saveFileDialog[v11.2] Ask to user to choose a location and saves the passed data as a file at that location.
selectFileAsks the user to choose a file and calls the async callback with file info.
selectMultiplePhotos[v11.2.3] Asks the user to choose multiple photos and calls the async callback with linked list of file infos (see FileInfo.nextInfo).
selectPhotoAsks the user to choose a media (image, video, depending on the value of allowChooseVideo property) and calls the async callback with file info.

MobileCRM.Services.DocumentService.capturePhoto Method

Asks the user to capture a photo and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to capture the photo and place it into <img> element.

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.maxImageSize = "640x480"; // maxImageSize can have one of following values: "Default", "640x480", "1024x768", "1600x1200", "2048x1536", "2592x1936"
  3. service.capturePhoto(
  4. function (fileInfo) {
  5. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  6. if (fileInfo.url)
  7. testImg.src = fileInfo.url;
  8. },
  9. MobileCRM.bridge.alert
  10. );

MobileCRM.Services.DocumentService.pasteFile Method

Takes the file from clipboard and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to retrieve file from the clipboard (if platform supports this action).

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.pasteFile(
  3. function (fileInfo) {
  4. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  5. MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
  6. },
  7. MobileCRM.bridge.alert
  8. );

MobileCRM.Services.DocumentService.print Method

[v9.1] Prints the document defined by file path.

Arguments

ArgumentTypeDescription
filePathStringA file path.
landscapeBooleanTrue, to print the document in landscape. False, to print it in portrait
errorCallbackfunction(errorMsg)The error callback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to print a file.

  1. function printFile(filePath) {
  2. /// <param name="filePath" type="String">A relative path to the file based on the application data root.</param>
  3. var service = new MobileCRM.Services.DocumentService();
  4. service.print(filePath, false, MobileCRM.bridge.alert, null);
  5. }

MobileCRM.Services.DocumentService.recordAudio Method

Asks the user to record an audio note and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to record an audio file (if platform supports this action).

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.recordAudio(
  3. function (fileInfo) {
  4. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  5. MobileCRM.bridge.alert("Audio file recorded: " + fileInfo.filePath + '\n' + fileInfo.url);
  6. },
  7. MobileCRM.bridge.alert
  8. );

MobileCRM.Services.DocumentService.recordVideo Method

Asks the user to record an video and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to record a video (if platform supports this action).

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.recordVideo(
  3. function (fileInfo) {
  4. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  5. MobileCRM.bridge.alert("Video file recorded: " + fileInfo.filePath + '\n' + fileInfo.url);
  6. },
  7. MobileCRM.bridge.alert
  8. );

MobileCRM.Services.DocumentService.resizeImage Method

[v11.1] Resize image defined by file path.

Arguments

ArgumentTypeDescription
filePathStringA file path.
maxWidthNumberMax width.
maxHeightNumberMax height.
callbackfunction(result)A callback function for asynchronous result. In case of success result argument will be true otherwise false.
scopeObjectThe scope for callbacks.

MobileCRM.Services.DocumentService.saveFileDialog Method

[v11.2] Ask to user to choose a location and saves the passed data as a file at that location.

Arguments

ArgumentTypeDescription
fileNameStringA file name.
fileDataStringBase64 encoded file data.
callbackfunction(result)A callback function for asynchronous result. In case of success result argument will be true otherwise false.
scopeObjectThe scope for callbacks.

MobileCRM.Services.DocumentService.selectFile Method

Asks the user to choose a file and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how select a file.

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.allowChooseVideo = true;
  3. service.selectFile(
  4. function (fileInfo) {
  5. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  6. MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
  7. },
  8. MobileCRM.bridge.alert
  9. );

MobileCRM.Services.DocumentService.selectMultiplePhotos Method

[v11.2.3] Asks the user to choose multiple photos and calls the async callback with linked list of file infos (see FileInfo.nextInfo).

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.DocumentService.selectPhoto Method

Asks the user to choose a media (image, video, depending on the value of allowChooseVideo property) and calls the async callback with file info.

Arguments

ArgumentTypeDescription
callbackfunction(MobileCRM.Services.FileInfo)The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallbackfunction(errorMsg)The errorCallback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to select a photo.

  1. var service = new MobileCRM.Services.DocumentService();
  2. service.selectPhoto(
  3. function (fileInfo) {
  4. /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
  5. MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
  6. document.getElementById("imgElement").src = fileInfo.url;
  7. },
  8. MobileCRM.bridge.alert
  9. );

MobileCRM.Services.DynamicsReport Object

[v10.0] Represents a service for downloading MS Dynamics reports.

Methods

MethodDescription
constructorConstructs an instance of MobileCRM.Services.DynamicsReport object.
downloadDownloads the MS Dynamics report into a file.

MobileCRM.Services.DynamicsReport.constructor Method

Constructs an instance of MobileCRM.Services.DynamicsReport object.


MobileCRM.Services.DynamicsReport.download Method

Downloads the MS Dynamics report into a file.

Arguments

ArgumentTypeDescription
fileNameStringA file name for resulting file. Leave "null" to let app to safely generate the file name and extension.
formatStringOne of following formats (must be supported in Dynamics): XML, CSV, PDF, MHTML, EXCELOPENXML, WORDOPENXML, IMAGE.
successfunction(location)A callback function that is called with the full path to downloaded file.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

MobileCRM.Services.FileInfo Object

Carries the result of a DocumentService operation.

In case of canceled document service operation, all properties in this object will be set to "null".

Properties

PropertyTypeDescription
filePathStringGets the full path of the local file.
urlStringGets the local URL of the file which can be used from within this HTML document.
mimeTypeStringGets the file MIME type.
nextInfoMobileCRM.Services.FileInfoGets the next file info or "null".

MobileCRM.Services.GeoAddress Object

[v9.3] Represents a service for translating geo position into the civic address and back.

Properties

PropertyTypeDescription
streetNumberStringGets or sets the street number.
streetStringGets or sets the street.
cityStringGets or sets the city.
zipStringGets or sets the zip code.
stateOrProvinceStringGets or sets the state or province.
countryStringGets or sets the country.
isValidStringIndicates whether the address is valid.

Methods

MethodDescription
toLocationTranslates the civic address represented by GeoAddress object into GPS position.

Functions

FunctionDescription
fromLocationTranslates the geo position represented by latitude and longitude values into the GeoAddress object.

MobileCRM.Services.GeoAddress.toLocation Method

Translates the civic address represented by GeoAddress object into GPS position.

Arguments

ArgumentTypeDescription
successfunction(location)A callback function that is called with the location object having latitude and longitude properties.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to translate civic address into the GPS position.

  1. var addr = new MobileCRM.Services.GeoAddress();
  2. addr.country = "UK";
  3. addr.city = "London";
  4. addr.street = "Downing Street";
  5. addr.streetNumber = "10";
  6. addr.toLocation(function (location) {
  7. // location is {latitude: 51.50344025, longitude: -0.127708109585621}
  8. MobileCRM.bridge.alert(location.latitude + "\n" + location.longitude);
  9. }, MobileCRM.bridge.alert, null);

MobileCRM.Services.GeoAddress.fromLocation Function

Translates the geo position represented by latitude and longitude values into the GeoAddress object.

Arguments

ArgumentTypeDescription
latitudeNumberLatitude value of the GPS position.
longitudeNumberLongitude value of the GPS position.
successfunction(address)A callback function that is called with the GeoAddress object as argument.
failedfunction(errorMsg)A callback which is called in case of error.
scopeObjectThe scope for callbacks.

Example 1

This example demonstrates how to translate GPS position into the civic address.

  1. MobileCRM.Services.GeoAddress.fromLocation(51.50344025, -0.127708109585621, function (address) {
  2. /// <param name="address" type="MobileCRM.Services.GeoAddress"/>
  3. // Gets the GeoAddress: {streetNumber: "10", street: "Downing Street", city: "London", zip: "SW1A 2AA", stateOrProvice: "England", country: "UK", isValid: true}
  4. MobileCRM.bridge.alert(address.streetNumber + " " + address.street + "\n" + address.city);
  5. }, MobileCRM.bridge.alert, null);

MobileCRM.Services.HttpWebRequest Object

[v11.0] Instance of http web request.

Properties

PropertyTypeDescription
userNameStringThe authentication user name.
passwordStringThe authentication password.
methodStringThe http method to use for the request (e.g. "POST", "GET", "PUT").
headersObjectAn object of additional header key/value pairs to send along with requests using the HttpWebRequest.
contentTypeStringThe htt request data content type.
allowRedirectBooleanThe http allows servers to redirect a client request to a different location.
responseEncodingStringThe http web response encoding type. (default: UTF-8), e.g. Base64, ASCII, UTF-8, Binary in case of blob.
responseTypeStringThe HttpWebResponse content type.

Methods

MethodDescription
send[v11.0] Allow to send http web request against an HTTP server.
setBody[v11.0] Set content body of http web request.
setCredentials[v10.4] Set Network credentials information.
setResponseEncoding[v11.0] Set encoding for content type of http web response.

MobileCRM.Services.HttpWebRequest.send Method

[v11.0] Allow to send http web request against an HTTP server.

Arguments

ArgumentTypeDescription
urlStringThe Url of server where HTTP request will be sent.
callbackfunction(response)A callback function that is called with the web response having "responseCode" and "responseText" properties.
scopeObjectThe scope for callbacks.

MobileCRM.Services.HttpWebRequest.setBody Method

[v11.0] Set content body of http web request.

Arguments

ArgumentTypeDescription
bodyStringThe body content.
encodingStringThe encoding (e.g. UTF-8, ASCII, Base64, Binary)

MobileCRM.Services.HttpWebRequest.setCredentials Method

[v10.4] Set Network credentials information.

Arguments

ArgumentTypeDescription
userNameStringThe authentication user name.
passwordStringThe authentication password.

MobileCRM.Services.HttpWebRequest.setResponseEncoding Method

[v11.0] Set encoding for content type of http web response.

Arguments

ArgumentTypeDescription
encodingStringThe encoding (e.g. UTF-8, ASCII, Base64)

MobileCRM.Services.SynchronizationResult Object

[v8.1] Represents the synchronization result.

Properties

PropertyTypeDescription
newCustomizationReadyBooleanIndicates whether the new customization is ready.
customizationDownloadedBooleanIndicates whether the new customization was applied.
dataErrorsEncounteredBooleanIndicates whether some data errors were encountered during sync (cannot upload, delete, change status, owner, etc.).
appWasLockedBooleanApplication was locked.
syncAbortedBooleanSync was aborted.
adminFullSyncBooleanFull sync was requested so background sync was aborted.
webErrorBooleanIndicates whether sync failed due to a communication error (HttpException, for example).
connectFailedBooleanIndicates whether sync could not start because of a connection failure.
wasBackgroundSyncBooleanIndicates whether the last sync was background sync or foreground sync.

MobileCRM.Services.Workflow Namespace

Contains objects accessing the Dynamics 365 workflow.

Objects

ObjectDescription
Action[v11.2] Represents custom workfow action.

MobileCRM.Services.Workflow.Action Object

[v11.2] Represents custom workfow action.

Functions

FunctionDescription
execute[v11.2] Asynchronously executes custom workfow action on the server.

MobileCRM.Services.Workflow.Action.execute Function

[v11.2] Asynchronously executes custom workfow action on the server.

Arguments

ArgumentTypeDescription
actionNameStringThe unique name of the custom action to execute.
parametersObjectThe object containing the parameters for the custom action.
successfunction(string)A callback function for successful asynchronous result. The result argument will carry the serialized response from the server.
failedfunction(error)A callback function for command failure. The error argument will carry the error message.
scopeA scope for calling the callbacks; set "null" to call the callbacks in global scope.

API Changes

Version 12.0

New Functions

MobileCRM.CultureInfo.initializeAsync
MobileCRM.CultureInfo.loadAsync
MobileCRM.DynamicEntity.deleteAsync
MobileCRM.DynamicEntity.downloadAttachmentAsync
MobileCRM.DynamicEntity.loadDocumentBodyAsync
MobileCRM.DynamicEntity.saveDocumentBodyAsync
MobileCRM.Localization.initializeAsync
MobileCRM.MobileReport.runReportAsync
MobileCRM.Platform.getLocationAsync
MobileCRM.Reference.loadAsync
MobileCRM.FetchXml.Fetch.deserializeFromXmlAsync
MobileCRM.UI.EntityForm.DetailCollection.addAsync
MobileCRM.UI.EntityForm.DetailCollection.getAllAsync
MobileCRM.UI.EntityForm.DetailCollection.getAsync
MobileCRM.UI.MediaTab.getDataAsync
MobileCRM.UI.MessageBox.sayTextAsync

New Methods

MobileCRM.FetchXml.Fetch.serializeToXmlAsync
MobileCRM.UI.LookupForm.showAsync
MobileCRM.UI.MediaTab.getDataAsync
MobileCRM.UI.MessageBox.showAsync
MobileCRM.UI.MultiLookupForm.showAsync