Javascript Bridge Reference

Useful Links

API Changes
Empty Offline HTML page
Empty Offline HTML Visual Studio solution
Mobile CRM Debug Builds

MobileCRM Namespace

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

Namespaces

Namespace Description
FetchXml Contains a set of objects implementing the FetchXML request methods
UI Contains a set of objects implementing the Javascript equivalent of the MobileCRM application UI components.
UI.DetailViewItems Contains a set of objects representing particular detail view items.
Services Contains non-UI classes for accessing documents…
Services.Workflow Contains objects accessing the Dynamics 365 workflow.

Properties

Property Description
bridge Singleton instance of MobileCRM.Bridge providing the management of the Javascript / native code cross-calls.

Objects

Object Description
AboutInfo [v8.2] Represents the branding information.
Application Encapsulates the application-related functionality.
Bridge 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.
Configuration Provides 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.
DynamicEntity Represents a CRM entity, with only a subset of properties loaded.
Localization A static object with functions allowing to access the localized texts.
ManyToManyReference A static object with functions managing many to many relations.
MetaEntity Represents an entity metadata.
MetaProperty Represents a property (CRM field) metadata.
Metadata A static object with functions for accessing the entity metadata store.
MobileReport Provides a functionality of mobile reporting.
NumberFormat [v10.2] Provides culture-specific information for formatting and parsing numeric values.
ObservableObject Represents a generic object which is monitoring the changes of its properties.
Platform Represents object for querying platform specific information and executing platform integrated actions.
Questionnaire Provides a functionality for questionnaires.
Reference Represents an entity reference which provides the minimum information about an entity.
Relationship Represents a relationship between two entities.
_DeviceInfo Represents the device information.
_Settings Internal object representing the application settings.

MobileCRM.AboutInfo Object

[v8.2] Represents the branding information.

Properties

Property Type Description
manufacturer String Gets the manufacturer text.
productTitle String Gets the product title text.
productTitleAndVersion String [v9.0] Gets the string with product title and version.
productSubTitle String Gets the product subtitle text.
poweredBy String Gets the powered by text.
icon String Gets the icon name.
website String Gets the website url.
supportEmail String Gets the support email.

Functions

Function Description
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

Argument Type Description
callback function(Object) The callback function that is called asynchronously with the about info object.
errorCallback function(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

Function Description
checkUserRoles 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.
createDirectory Asynchronously creates the directory in the application local data.
deleteDirectory Asynchronously deletes the empty directory from the application local data.
deleteFile Asynchronously deletes the file from the application local data.
directoryExists Checks whether the directory with given path exists in the application local data.
fileExists Checks whether the file with given path exists in application local data.
getAppColor Gets the customized color by its name.
getAppImage Gets the colorized application image. It is taken either from customization package or from application bundle.
getDirectories Asynchronously gets the list of directories from the application local data.
getFiles Asynchronously gets the list of files from the application local data.
moveFile Asynchronously moves the application local file to another location.
readFile Reads the file from the application local data and asynchronously gets its content.
readFileAsBase64 Reads the file from the application local data and asynchronously gets its base64-encoded content.
setAppColors [v11.2] Sets the application colors.
showAppLogin Causes that the password is forgotten and user is required to type it again to make the app running.
synchronize Starts 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).
writeFile Asynchronously writes the text into the file from the application local data.
writeFileFromBase64 Asynchronously 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

Argument Type Description
roles Array(String) Defines the roles to check.
success function(result) A callback function for successful asynchronous result. The result will carry a number with the count of matching roles.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.createDirectory Function

Asynchronously creates the directory in the application local data.

Arguments

Argument Type Description
path String Defines the relative path of the directory in the application local data.
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
path String Defines the relative path of the directory in the application local data.
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
path String Defines the relative path of the file in the application local data.
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
path String Defines the relative path of the directory located in the application local data.
success function(result) A callback function for successful asynchronous result. The result will carry a Boolean object determining whether the directory exists or not.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
path String Defines the relative path of the file located in the application local data.
success function(result) A callback function for successful asynchronous result. The result will carry a Boolean object determining whether the file exists or not.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
colName String Defines 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.
success function(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).
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
imageName String Defines the image name (e.g. “Buttons.Call.png”).
colorize String If 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.
success function(result) A callback function for successful asynchronous result. The result will carry a String object with “data:” URL containing base64-encoded colorized application image.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.getDirectories Function

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

Arguments

Argument Type Description
path String Defines the relative path of the Directory in the application local data.
success function(result) A callback function which carry the array of directories names.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.getFiles Function

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

Arguments

Argument Type Description
path String Defines the relative path of the Directory in the application local data.
success function(result) A callback function which carry the array of files names in the directory.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.moveFile Function

Asynchronously moves the application local file to another location.

Arguments

Argument Type Description
src String Defines the relative path of the source file in the application local data.
dst String Defines the relative path of the destination file in the application local data.
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.readFile Function

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

Arguments

Argument Type Description
path String Defines the relative path of the file in the application local data.
success function(result) A callback function for successful asynchronous result. The result will carry a String object with the file content.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.readFileAsBase64 Function

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

Arguments

Argument Type Description
path String Defines the relative path of the file in the application local data.
success function(result) A callback function for successful asynchronous result. The result will carry a string with the base64-encoded file content.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
colors object Properties of the object define the colors to set. The values must be int in the AARRGGBB format.
success function(result) A callback function for successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
backgroundOnly Boolean if true, only the background sync is allowed; otherwise it can also run the foreground sync.
ifNotSyncedBefore Date Defines 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

Argument Type Description
forceLogin Boolean if 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

Argument Type Description
path String Defines the relative path of the file in the application local data.
text String Defines the file content to be written.
append Boolean Determines whether to overwrite or append to an existing file..
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Application.writeFileFromBase64 Function

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

Arguments

Argument Type Description
path String Defines the relative path of the file in the application local data.
base64 String A string containing the base64-encoded file content.
success function() A callback function which is called in case of success.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
path String Defines the relative path of the file in the application local data.
text String Defines the file content to be written.
encoding String Defines the text encoding for file content (default is UTF-8). Use “ASCII” for ANSI text or “UTF-16” for multi-byte Unicode.
append Boolean Determines whether to overwrite or append to an existing file.
success function(result) A callback function which is called in case of successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Property Type Description
platform String A string identifying the device platform (e.g. Android, iOS, Windows, WindowsRT, Windows10 or WindowsPhone).
version Number A 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

Method Description
alert Shows a message asynchronously and calls the callback after it is closed by user.
closeForm Closes a form containing this HTML document.
enableDebug Enables platform-specific features for debugging the web page.
enableZoom Enables platform-specific pinch zoom gesture.
getWindowSize [v8.0] Returns the size of the window in logical pixels without any scaling and viewport calculations..
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

Argument Type Description
callback function(obj) The callback function that is called asynchronously.
scope Object The 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

Argument Type Description
callback function(obj) The callback function that is called asynchronously.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
enable Boolean Indicates 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

Argument Type Description
callback function(obj) The callback function that is called asynchronously. Gets an object with the window “width” and “height”.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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.log Method

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

Arguments

Argument Type Description
text String A 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

Argument Type Description
eventName String Global event name.
handler function(args) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
eventName String Global event name.
args Object Any 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

Property Type Description
applicationEdition String Gets the application edition.
applicationPath String Gets the application folder.
applicationVersion String Gets the application version (major.minor.subversion.build).
customizationDirectory String Gets or sets the runtime customization config root.
externalConfiguration String Gets the external configuration directory (either customization or legacy configuration).
isBackgroundSync Boolean Gets or sets whether background synchronization is in progress.
isOnline Boolean Gets or sets whether the online mode is currently active.
legacyVersion String Gets or sets the legacy redirect folder.
licenseAlert String Gets the flag set during sync indicating that the user’s license has expired.
settings MobileCRM._Settings Gets the application settings.
storageDirectory String Gets the root folder of the application storage.

Functions

Function Description
requestObject Requests 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

Argument Type Description
callback function(config) The callback function that is called asynchronously with MobileCRM.Configuration object instance as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Property Type Description
name String Gets 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.
displayName String Gets the full localized culture name.
nativeName String Gets the culture name, consisting of the language, the country/region, and the optional script, that the culture is set to display.
ISOName String Gets the ISO 639-1 two-letter code for the language of the current CultureInfo.
isRightToLeft Boolean Gets a value indicating whether the current CultureInfo object represents a writing system where text flows from right to left.
dateTimeFormat MobileCRM.DateTimeFormat Gets a DateTimeFormat that defines the culturally appropriate format of displaying dates and times.
numberFormat MobileCRM.NumberFormat Gets a NumberFormat that defines the culturally appropriate format of displaying numbers, currency, and percentage.

Functions

Function Description
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.
load [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

Argument Type Description
date Date A date being formatted.
format String Custom 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

Argument Type Description
date Date A 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

Argument Type Description
callback function(currentCulture) The callback function that is called asynchronously with initialized CultureInfo object as argument.
errorCallback function(errorMsg) The errorCallback which is to be called in case of error.
scope Object The 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.load Function

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

Method loads specified 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

Argument Type Description
culture String The 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
callback function(cultureInfo) The callback function that is called asynchronously with initialized CultureInfo object as argument.
errorCallback function(errorMsg) The errorCallback which is to be called in case of error.
scope Object The 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.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

Argument Type Description
date Date A 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

Argument Type Description
date Date A 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

Argument Type Description
date Date A 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

Argument Type Description
date Date A 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

Argument Type Description
date Date A 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

Argument Type Description
date Date A date being formatted.

MobileCRM.DateTimeFormat Object

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

Properties

Property Type Description
abbreviatedDayNames String[] Gets a string array containing the culture-specific abbreviated names of the days of the week.
abbreviatedMonthGenitiveNames String[] Gets a string array of abbreviated month names associated with the current DateTimeFormat object.
abbreviatedMonthNames String[] Gets a string array that contains the culture-specific abbreviated names of the months.
aMDesignator String Gets the string designator for hours that are “ante meridiem” (before noon).
dayNames String[] Gets a string array that contains the culture-specific full names of the days of the week.
firstDayOfWeek Number Gets the first day of the week (0=Sunday, 1=Monday, …)
fullDateTimePattern String Gets the custom format string for a long date and long time value.
longDatePattern String Gets the custom format string for a long date value.
longTimePattern String Gets the custom format string for a long time value.
monthDayPattern String Gets the custom format string for a month and day value.
monthGenitiveNames String[] Gets a string array of month names associated with the current DateTimeFormat object.
monthNames String[] Gets a string array containing the culture-specific full names of the months.
pMDesignator String Gets the string designator for hours that are “post meridiem” (after noon).
shortDatePattern String Gets the custom format string for a short date value.
shortestDayNames String[] Gets a string array of the shortest unique abbreviated day names associated with the current DateTimeFormat object.
shortTimePattern String Gets the custom format string for a short time value.
sortableDateTimePattern String Gets the custom format string for a sortable date and time value.
universalSortableDateTimePattern String Gets the custom format string for a universal, sortable date and time string.
yearMonthPattern String Gets 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

Property Type Description
entityName String The logical name of the entity, e.g. “account”.
id String GUID of the existing entity or null for new one.
isNew Boolean Indicates whether the entity is newly created.
isOnline Boolean Indicates whether the entity was created by online request or from local data.
primaryName String The human readable name of the entity, e.g. “Alexandro”.
properties Object An object with entity properties, e.g. {firstname:”Alexandro”, lastname:”Puccini”}.

Methods

Method Description
constructor Constructs an instance of MobileCRM.DynamicEntity object.
save Performs the asynchronous CRM create/modify entity command.
saveAsync Performs the asynchronous CRM create/modify entity command.

Functions

Function Description
createNew Creates the MobileCRM.DynamicEntity object representing new entity.
deleteById Asynchronously deletes the CRM entity.
downloadAttachment [v9.1] Initiates the attachment download for specified entity.
loadById Asynchronously loads the CRM entity properties.
loadDocumentBody Asynchronously loads the document body for specified entity.
saveDocumentBody [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

Argument Type Description
entityName String The logical name of the entity, e.g. “account”.
id String GUID of the existing entity or null for new one.
primaryName String The human readable name of the entity, e.g “Alexandro”.
properties Object An object with entity properties, e.g. {firstname:”Alexandro”, lastname:”Puccini”}.
isOnline Boolean Indicates 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

Argument Type Description
callback function(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.
forceMode Boolean [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

Argument Type Description
forceMode Boolean 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 to be saved in currently selected application offline/online mode.

Return value

Type: Promise<DynamicEntity>

A Promise object which is asynchronously resolved with saved DynamicEntity 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

Argument Type Description
entityName String The logical name of the entity, e.g. “account”.
id String GUID of the existing entity or null for new one.
primaryName String The human readable name of the entity, e.g “Alexandro”.
properties Object An object with entity properties, e.g. {firstname:”Alexandro”, lastname:”Puccini”}.

MobileCRM.DynamicEntity.deleteById Function

Asynchronously deletes the CRM entity.

Arguments

Argument Type Description
entityName String The logical name of the entity, e.g. “account”.
id String GUID of the existing entity or null for new one.
success function() A callback function for successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
entityName String The logical name of the entity, in most cases “annotation”.
id String GUID of the existing entity or null for new one.
success function(result) A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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.loadById Function

Asynchronously loads the CRM entity properties.

Arguments

Argument Type Description
entityName String The logical name of the entity, e.g. “account”.
id String GUID of the existing entity or null for new one.
success function(result) A callback function for successful asynchronous result. The result argument will carry the MobileCRM.DynamicEntity object.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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. }, null);
  14. }

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

Argument Type Description
entityName String The logical name of the entity, in most cases “annotation”.
id String GUID of the existing entity or null for new one.
success function(result) A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
entityId String GUID of the existing entity or “null” for new one.
entityName String The logical name of the entity; optional, default is “annotation”.
relationship MobileCRM.Relationship The relationship with parent object.
filePath String Absolute or app data-relative path to the file holding the body.
mimeType String MimeType of the content, optional.
success function(MobileCRM.Reference) A callback function for successful asynchronous result. The result argument will carry the Reference to updated/created entity.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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.  
  8. MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
  9. }, MobileCRM.bridge.alert, null);
  10. }

MobileCRM.DynamicEntity.unzipDocumentBody Function

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

Arguments

Argument Type Description
entityName String The logical name of the entity, in most cases the “annotation”.
id String GUID of the existing entity or null for new one.
targetDir String The relative path of the target directory within the application storage.
success function(result) A callback function for successful asynchronous result. The result argument will carry the string with base64-encoded data.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Localization Object

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

Functions

Function Description
get Gets the display string for the passed id.
getComponentLabel Gets the display string for the passed entity and component (view, form) id.
getLoadedLangId Asynchronously gets currently loaded localization language.
getPlural Gets the plural version of the display string for the passed id.
getTextOrDefault Gets the display string for the passed id, or the passed default string if a string with the passed id doesn’t exists.
initialize Initializes the Localization object.
initializeEx [v10.0] Initializes the Localization object.
makeId Creates an absolute id from section and id.

MobileCRM.Localization.get Function

Gets the display string for the passed id.

Arguments

Argument Type Description
id String Display 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

Argument Type Description
entityName String The entity logical name.
componentType String The component type. (View, DetailView).
viewName String The 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

Argument Type Description
callback function(langId) The callback function that is called asynchronously with currently loaded localization language as argument.
errorCallback function(errorMsg) The errorCallback which is to be called in case of error.
scope Object The 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

Argument Type Description
id String Display 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

Argument Type Description
id String Display string id.
defaultString String Default 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

Argument Type Description
callback function(config) The callback function that is called asynchronously with initialized Localization object as argument.
errorCallback function(errorMsg) The errorCallback which is to be called in case of error.
scope Object The scope for callbacks.

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

Argument Type Description
regularExpression string The regular expression defining a subset of localization keys. Refer to Regular Expression Language – Quick Reference. Set to null to obtain whole localization.
callback function(config) The callback function that is called asynchronously with initialized Localization object as argument.
errorCallback function(errorMsg) The errorCallback which is to be called in case of error.
scope Object The scope for callbacks.

MobileCRM.Localization.makeId Function

Creates an absolute id from section and id.

Arguments

Argument Type Description
section String The section id.
id String Display string id.

Return value

Type: String

Absolute id.


MobileCRM.ManyToManyReference Object

A static object with functions managing many to many relations.

Functions

Function Description
addRecord Adds or removes an N-N relationship record between the two passed entities.
create Creates a new N-N relationship between the two passed entities.
remove Removes 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

Argument Type Description
entityName String The relationship entity name.
ref1 MobileCRM.Reference First entity instance.
ref2 MobileCRM.Reference Second entity instance.
create Boolean Whether to create or delete the relationship record.
success function(result) A callback function for successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
entityName String The relationship entity name.
ref1 MobileCRM.Reference First entity instance.
ref2 MobileCRM.Reference Second entity instance.
success function(result) A callback function for successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
entityName String The relationship entity name.
ref1 MobileCRM.Reference First entity instance.
ref2 MobileCRM.Reference Second entity instance.
success function(result) A callback function for successful asynchronous result.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Property Type Description
isEnabled Boolean Indicates whether an entity is enabled. This field is used for limited runtime customization.
isExternal Boolean Indicates whether an entity stores data from external sources Exchange/Google.
name String Gets the entity (logical) name.
objectTypeCode Number Gets the unique entity type code.
primaryFieldName String The name of the entity primary field (name) property.
primaryKeyName String The name of the entity primary key property.
relationshipName String Gets the name of the many-to-many relationship name. Defined only for intersect entities.
statusFieldName String Gets the status property name. In general it is called “statuscode” but there are exceptions.
uploadOnly Boolean Indicates whether this entity can be downloaded during synchronization.
attributes Number Gets additional entity attributes.

Methods

Method Description
canAppendTo Checks whether the user has permission to append a child To a this parent entity.
canCreate Checks whether the current user has create permission on the entity type.
canDelete Checks whether the current user has create permission on the entity type.
canRead Checks whether the current user has read permission on the entity type.
canWrite Checks whether the current user has write permission on the entity type.
getDepth Gets the permission depth.
getProperty Gets the MetaProperty object describing the CRM attribute (field) properties.

Functions

Function Description
loadByName Gets 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

Argument Type Description
child String The 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

Argument Type Description
permission Number Permission 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

Argument Type Description
name String A 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

Argument Type Description
name String A logical name of requested entity.
callback function The callback function that is called asynchronously with MetaEntity object as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

Example 1

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

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

MobileCRM.MetaProperty Object

Represents a property (CRM field) metadata.

Properties

Property Type Description
name String Gets the field (logical) name.
required Number Gets the attribute requirement level (0=None, 1=SystemRequired, 2=Required, 3=Recommended, 4=ReadOnly).
type Number Gets the attribute CRM type (see MS Dynamics SDK).
format Number Gets the attribute display format.
isVirtual Boolean Gets whether the property is virtual (has no underlying storage). State and PartyList properties are virtual.
isReference Boolean Gets whether the property is a reference (lookup) to another entity.
isNullable Boolean Gets whether the property may contain NULL.
defaultValue Gets the property default value.
targets Array Gets the names of target entities, if the property is a lookup, or customer.
minimum Number Gets the attribute minimum value.
maximum Number Gets the attribute minimum value.
precision Number Gets the numeric attribute’s precision (decimal places).
permission Number Gets the attribute’s permission set (0=None, 1=User, 2=BusinessUnit, 4=ParentChild, 8=Organization).
activityPartyType Number Gets the activity party type (from, to, attendee, etc.)
isMultiParty Boolean Gets whether the activity party property can have multiple values (multiple to, cc, resources.)
isSingularParty Boolean Gets 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

Function Description
entityHasChildren Gets whether the passed entity has child entities.
getActivities Gets the list of activities.
getEntity Gets the MetaEntity object describing the entity attributes.
getEntityParent Gets the entity’s parent entity name.
getOptionSetValues Asynchronously gets the list of values for given CRM OptionSet.
getStringListOptions Gets the list of options for the string list property.
requestObject Requests 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

Argument Type Description
entityName String The 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

Argument Type Description
name String A 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

Argument Type Description
childEntityName String The 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

Argument Type Description
entityName String The entity name.
optionSetName String The OptionSet name.
callback function(optionSetValues) The callback function that is called asynchronously with option set values object as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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. }, MobileCRM.bridge.alert, null);

MobileCRM.Metadata.getStringListOptions Function

Gets the list of options for the string list property.

Arguments

Argument Type Description
entityName String The entity name.
propertyName String The 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

Argument Type Description
callback function(metadata) The callback function which is called asynchronously with serialized EntityForm object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Function Description
runReport [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

Argument Type Description
fetch String The fetch XML defining the entity (entities) query used as report input.
reportXML String The mobile report XML definition which can be loaded from the resco_report entity or constructed dynamically. Ignored if IsExportOnly parameter is true.
reportFormat String Report format: Pdf (default), Html, Excel, Text.
isExportOnly Boolean If true then ReportXml is optional. The default is false.
isOnline Boolean Indicates whether the report should be run against the online data or local database. The default is current application mode.
outputFile String The full path to the output file. If omitted a temp file is created. The output path is always passed to the success callback.
success function(obj) A callback function that is called with the file path to successfully created report.
failed function(errorMsg) A callback which is called in case of error.
scope Object The 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.showForm Function

[v10.1] Shows new MobileReport form.

Arguments

Argument Type Description
entity MobileCRM.Reference Report Entity reference what the report is related to.
source MobileCRM.Reference[] The list of entities that should be source of report.”>Array of entity references .
reportXML String The report source query.
failed function(errorMsg) A callback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.NumberFormat Object

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

Properties

Property Type Description
currencyDecimalDigits Number Gets the number of decimal places to use in currency values.
currencyDecimalSeparator String Gets the string to use as the decimal separator in currency values.
currencyGroupSeparator String Gets the string that separates groups of digits to the left of the decimal in currency values.
currencyGroupSizes Number[] Gets the number of digits in each group to the left of the decimal in currency values.
currencyNegativePattern Number Gets the format pattern for negative currency values.
currencyPositivePattern Number Gets the format pattern for positive currency values.
currencySymbol String Gets the string to use as the currency symbol.
naNSymbol String Gets the string that represents the IEEE NaN (not a number) value.
negativeInfinitySymbol String Gets the string that represents negative infinity.
negativeSign String Gets the string that denotes that the associated number is negative.
numberDecimalDigits Number Gets the number of decimal places to use in numeric values.
numberDecimalSeparator String Gets the string to use as the decimal separator in numeric values.
numberGroupSeparator String Gets the string that separates groups of digits to the left of the decimal in numeric values.
numberGroupSizes Number[] Gets the number of digits in each group to the left of the decimal in numeric values.
numberNegativePattern Number Gets the format pattern for negative numeric values.
percentDecimalDigits Number Gets the number of decimal places to use in percent values.
percentDecimalSeparator String Gets the string to use as the decimal separator in percent values.
percentGroupSeparator String Gets the string that separates groups of digits to the left of the decimal in percent values.
percentGroupSizes Number[] Gets the number of digits in each group to the left of the decimal in percent values.
percentNegativePattern Number Gets the format pattern for negative percent values.
percentPositivePattern Number Gets the format pattern for positive percent values.
percentSymbol String Gets the string to use as the percent symbol.
perMilleSymbol String Gets the string to use as the per mille symbol.
positiveInfinitySymbol String Gets the string that represents positive infinity.
positiveSign String Gets 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

Method Description
constructor Constructs an instance of MobileCRM.ObservableObject object.
addProp Creates a new observable property for this object
getChanged Creates 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

Argument Type Description
props Object Optional list of properties.

MobileCRM.ObservableObject.addProp Method

Creates a new observable property for this object

Arguments

Argument Type Description
name String A name of the new property.
writable Boolean Indicates whether the property should have setter.
value An 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

Argument Type Description
propName String The name of the property which is being set.
type String The fully qualified .Net type (e.g. “System.String” or “MobileCrm.Data.IReference,MobileCrm.Data”).
value The value which has to be set.

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

Property Type Description
capabilities Number Gets the mask of capability flags supported by this device (MakePhoneCalls=1; HasMapView=2).
deviceIdentifier String Gets the unique identifier of this device.
screenWidth Number Gets the current screen width in pixels.
screenHeight Number Gets the current screen width in pixels.
screenDensity Number Gets the screen density (DPI).
isMultiPanel Boolean Gets whether the device has tablet or phone UI.
customImagePath String Gets or sets the custom image path that comes from customization.

Functions

Function Description
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.
getDeviceInfo Gets the device information.
getLocation Gets current geo-location from platform-specific location service.
getNetworkInfo [v11.2] Gets network information.
getURL Gets the full URL of currently loaded HTML document.
makeCall [v8.0] Opens the platform-specific call application with specified phone number.
navigateTo Execute the navigateTo function based on the latitude and longitude.
openDocument [v8.1] Opens specified document in associated program.
openUrl Open url in external browser.
preventBackButton Prevents application to close when HW back button is pressed and installs handler which is called instead.
requestObject Requests the managed Platform object.
scanBarCode Activates the bar-code scanning.
scanBarCodeRequiredLength Activates 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

Argument Type Description
address String Recipient’s email address.
subject String An e-mail subject.
body String A string with email body.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
address String Recipient”s email address.
subject String An e-mail subject.
body String A string with email body.
attachments Array Array of files to send. Element must be a full path or a IReference to a note, etc.
entity MobileCRM.Reference The related entity reference.
relationship MobileCRM.Relationship The relationship to the created email entity. (optional).
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
success function(result) A callback function for successful asynchronous result. The result will carry a MobileCRM._DeviceInfo object.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
success function(result) A callback function for successful asynchronous result. The result will carry an object with properties latitude and longitude.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.
age Number Max age in seconds to accept GPS.
precision Number Desired accuracy in meters.
timeout Number Timeout in milliseconds (since v10.1).

MobileCRM.Platform.getNetworkInfo Function

[v11.2] Gets network information.

Arguments

Argument Type Description
success function(result) A callback function for successful asynchronous result. The result will carry an object with properties connected and fastConnection.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Platform.getURL Function

Gets the full URL of currently loaded HTML document.

Arguments

Argument Type Description
success function(result) A callback function for successful asynchronous result. The result will carry a string with URL.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Platform.makeCall Function

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

Arguments

Argument Type Description
telephone String Telephone number
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Platform.openDocument Function

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

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

Arguments

Argument Type Description
path String A path to the document file.
mimeType String Document MIME type (required on Android).
args String Optional arguments for Windows 7 command line.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
url String web 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

Argument Type Description
handler function() 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

Argument Type Description
callback function(platform) The callback function that is called asynchronously with serialized Platform object as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
success function(result) A callback function for successful asynchronous result. The result will carry an array of strings with scanned codes.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
requiredLength Number Set required length of scanned barcode.
success function(result) A callback function for successful asynchronous result. The result will carry an array of strings with scanned codes.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Platform.sendSMS Function

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

Arguments

Argument Type Description
phoneNumber String Phone number
text String SMS text
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The scope for errorCallback.

MobileCRM.Questionnaire Object

Provides a functionality for questionnaires.

Functions

Function Description
getGroupName Generates the real name of repeatable question group.
getQuestionName Generates 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

Argument Type Description
name String Base question group name from questionnaire template.
repeatIndex Number Repeat index of the group.

MobileCRM.Questionnaire.getQuestionName Function

Generates the real name of question from repeatable group.

Arguments

Argument Type Description
name String Base question name from questionnaire template.
repeatIndex Number Repeat index of the group containing the question.

MobileCRM.Questionnaire.showForm Function

[v10.2] Shows the questionnaire form.

Arguments

Argument Type Description
id String Id (guid) of the questionnaire.
failed function(errorMsg) A callback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Reference Object

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

Properties

Property Type Description
entityName String The logical name of the reference, e.g. “account”.
id String GUID of the existing entity or null for new one.
isNew Boolean Indicates whether the entity is newly created.
primaryName String The human readable name of the reference, e.g. “Alexandro”.

Methods

Method Description
constructor Constructs an instance of MobileCRM.Reference object.
toString Prints the reference primary name into string.

Functions

Function Description
loadById Asynchronously loads the CRM reference.

MobileCRM.Reference.constructor Method

Constructs an instance of MobileCRM.Reference object.

Arguments

Argument Type Description
entityName String The logical name of the reference, e.g. “account”.
id String GUID of the existing entity or null for new one.
primaryName String The 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.loadById Function

Asynchronously loads the CRM reference.

Arguments

Argument Type Description
entityName String An entity name
id String The reference ID.
success function(result) A callback function for successful asynchronous result. The result will carry an instance of MobileCRM.Reference object.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.Relationship Object

Represents a relationship between two entities.

Properties

Property Type Description
sourceProperty String Gets the name of the source of the relationship.
target MobileCRM.Reference Gets the target of the relationship.
intersectEntity String Gets the intersect entity if any. Used when displaying entities that are associated through a Many to Many relationship.
intersectProperty String Gets the intersect entity property if any. Used when displaying entities that are associated through a Many to Many relationship.

Methods

Method Description
constructor Constructs an instance of MobileCRM.Relationship object.

MobileCRM.Relationship.constructor Method

Constructs an instance of MobileCRM.Relationship object.

Arguments

Argument Type Description
sourceProperty String Gets the name of the source of the relationship.
target MobileCRM.Reference Gets the target of the relationship.
intersectEntity String Gets the intersect entity if any. Used when displaying entities that are associated through a Many to Many relationship.
intersectProperty String Gets 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

Property Type Description
name String Gets the name identifying the device.
oSVersion String Gets name and version of operating system.
model String Gets device model identifying the real device hardware.
buildInfo String Gets 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

Property Type Description
absoluteUrl String Gets the absolute URL (including the CrmOrganization).
activityListInitialEntity String Gets or sets the last active entity in the ActivityList.
applicationLock Number Gets or sets the application lock state (0=None, 1=Soft, 2=Permanent).
appointmentViewMode Number Gets or sets the last active view mode in Calendar view.
authenticationType Number Gets or sets the CRM server authentication method (0=ActiveDirectory, 1=CRM Online, 2=Internet facing., 3=CRM Online EMEA, 4=CRM Online APAC).
autoSync Number Gets or sets when the application starts to sync on the background (0=Never, 1=OnStart, 2=OnChange, 3=OnStartAndChange).
autoSyncAfterChange Number Gets the number of seconds to wait before syncing after data change. Negative to disable.
autoSyncAfterChangeOnline Number Gets the number of seconds to wait before syncing after data change in online mode. 0 or negative to disable, default is 1.
autoSyncDelay Number Gets or sets the automatic sync delay in seconds.
autoSyncAfterStart Number Gets the number of seconds to wait before syncing after application start. Negative to disable.
canUsePassword Boolean Indicates whether there is a valid password and whether it can be used.
clientCertificateThumbprint String Gets or sets the thumbprint of client certificate which should be used for client authentication.
clientCustomize Boolean Gets or sets whether entities can be disabled on the client.
createCallEntity Boolean Gets or sets whether to create the call entity after a call has been made from MobileCRM.
crm2011AuthUrl String Gets or sets the discovered CRM service authentication server url.
crm2011AuthType String Gets or sets the discovered CRM service authentication type.
crmOnlineDeviceToken String Gets or sets the token (cookie) issued by LiveId services identifying this device.
crmOnlineDeviceTokenExpires Date Gets or sets when the “CrmOnlineDeviceToken” expires (in UTC).
crmOrganization String Gets or sets the CRM organization (Absolute path in org url).
crmWebServiceVersion Number Gets or sets the discovered CRM service version (4 or 5).
crmWebServiceMinorVersion Number Gets or sets the the discovered CRM service minor version (13 – for CRM 2011 Rollup 13 and up).
currencyDecimalPrecision Number Gets or sets the organization Pricing Decimal Precision configuration option (0..4).
currencyDisplayOption Number Gets or sets the currency field display option 0- Symbol ($), 1 – Code (USD).
customizationDirectory String Gets or sets the customization directory.
databaseLocale String Gets or sets the database local language (for case-insensitive and language dependent compare). E.g. “en-US”.
databaseSchemaHash String Gets or sets the database schema hash.
density (Android only) Number Gets or sets the application Density (120=Low, 160=Medium, 240=High, 320=ExtraHigh, 480=ExtraExtraHigh).
deviceFriendlyName String Gets or sets the device friendly name (Steve’s iPhone).
deviceIdentifier String Gets or sets the hardware unique id.
deviceInfo String Gets or sets the device system an hw information (OS, etc.)
deviceName String Gets or sets the device name (Base64 encoded “InternalDeviceId”).
disabledEntities Boolean Gets the names of the disabled entities. Use for limited runtime customization.
domain String Gets or sets the user domain.
emailSignature String Gets or sets the email signature.
enableCallImport (Android, Windows Mobile) Boolean Enables the Call Import form (appears on the Home form)
enableDashboard Boolean Enables the Dashboard form (appears on the Home form).
enableMap Boolean Enables the Map form (appears on the Home form).
enableListButtons Boolean Enables list buttons. Default is true.
forcedFullSyncDate Date Gets 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.
forgetPassword Boolean Prevents remembered password to be used for next login.
fullNameConventionCode Number Gets 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”).
hasSyncErrors Boolean Gets or sets whether there were any synchronization errors encountered.
hasTaskReminder (Android, iOS, Windows Phone) Boolean Gets or sets whether reminders should be scheduled for tasks.
homeRealm String Gets or sets the URL of the authentication server (ADFS) in case of multi domain deployment.
ignoreCertificateErrors Boolean Gets or sets whether to ignore HTTPS certificate errors. (Should be used for evaluation and DEBUG only!)
invalidLoginCount Number Gets or sets the invalid login count.
internalDeviceId String Gets or sets the device id (GUID).
isDarkTheme (WP7 only) Boolean Gets or sets the UI theme (Dark or Light).
isDemoDatabase Boolean Gets or sets whether the current database contains demo data and should not be synced.
isCrmOnline Boolean Gets whether the login is for a CRM Online instance.
isValid Boolean Gets 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.
language String Gets or sets the UI text language.
lastProcessedCallTime (Android, Windows Mobile) Date Gets or sets the time of the last processed call history entry.
lastServerContact Date Gets or sets the time of the last server contact (either sync or security policy).
lastSyncDate Date Gets or sets the last synchronization end date.
lastUserInteraction Date Gets or sets the last user interaction time.
legacyPassword String Gets or sets the synchronization service password.
lockReason String Gets or sets the reason of the application lock.
loginTimeout Number Gets or sets the time in seconds after which the password expires and application login is required.
maxAttachmentSize Number Gets or sets the maximum attachment size to sync (in KB).
maxSyncCount Number Gets or sets the maximum number of records (per entity) to download.
multiThreadSync Boolean Gets or sets whether to use multi-threaded synchronization. Default true.
onlineMode Number Gets or sets when and how the application is switched to online mode (0=Always, 1=WifiOnly, 2=Manual, 3=Never).
organization String Gets or sets the organization name. Obsolete, only for compatibility.
organizationId String Gets or sets the current user’s organization GUID (given by the server).
password String Gets or sets the synchronization service password.
passwordHash String Gets or sets the password hash.
phoneApplication String Gets or sets the URL scheme of application used for making calls.
pushId (Android, iOS) String Gets or sets the push id used for push notification send to this device.
readonlySettings Array Gets the list of read-only settings.
requireSyncLogin Boolean Gets or sets whether the user must login at sync start.
savePassword Boolean Gets or sets whether to store the encrypted password in the config file.
saveSignatureAsImage Boolean Gets or sets whether to store signature attachments as SVG (vector) or PNG (image).
secRulesHash Number Gets or sets the hash code of the last downloaded security policy (zero for no policy).
serverHostName String Gets the CRM server host name.
serverSettingsVersion String Gets or sets the version of the settings file as send with the customization.
serverVersion Number Gets or sets the server version, either 4 for CRM 4.0 or 5 for CRM 2011.
syncCount Number Gets or sets the number of incremental synchronizations performed so far.
incSyncUsesVersionNumberSorting Boolean Gets or sets whether incremental sync fetches use “order by versionnumber” wherever possible. Since 10.2, default true.
syncEmailAsText Boolean Gets or sets whether to convert email to text during sync. Since 6.4, default false.
syncFilterHash String Gets or sets the sync filter file hash code.
systemUserId String Gets or sets the current user GUID (given by the server).
tourplanInitialEntity String Gets or sets the last active entity in the Tourplan (Calendar).
updateObjectTypeCodes Boolean Gets or sets whether to update entity objectypecodes on first sync.
useCrmEmail Boolean Gets or sets whether to create a CRM email entity or use the platform email service.
useDatabaseBlobStore Boolean Gets or sets whether to store attachment blobs in database or in files. If you change this setting you must perform a full sync!
useDatabaseEncryption Boolean Gets or sets whether the database is encrypted. Only used when the database is created (full sync). Default true.
userDefaultCurrencyId String Gets or sets the user’s default currency GUID. If not set use the organization default.
userLogin String Gets or sets the full user name (domain slash name).
userName String Gets or sets the user name.
useRowVersionChangeTracking Boolean Gets or sets whether to use RowVersion or ModifiedOn based sync. Default is true.
url String Gets or sets the web service URL used for synchronization.
verifyServerCertificate Boolean Gets 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

Object Description
Attribute Represents a FetchXml select statement (CRM field).
Condition Represents a FetchXml attribute condition statement.
Entity Represents a FetchXml query root entity.
Fetch Represents a FetchXml query object.
Filter Represents a FetchXml filter statement. A logical combination of Conditions and child-filters.
LinkEntity Represents a FetchXml query linked entity.
Order Represents a FetchXml order statement.

MobileCRM.FetchXml.Attribute Object

Represents a FetchXml select statement (CRM field).

Properties

Property Type Description
aggregate String An aggregation function.
alias String Defines an attribute alias.
dategrouping String A date group by modifier (year, quarter, month, week, day).
groupby Boolean Indicates whether to group by this attribute.
name String A lower-case entity attribute name (CRM logical field name).

Methods

Method Description
constructor Constructs an instance of MobileCRM.FetchXml.Attribute object.

MobileCRM.FetchXml.Attribute.constructor Method

Constructs an instance of MobileCRM.FetchXml.Attribute object.

Arguments

Argument Type Description
name String A lower-case entity attribute name (CRM logical field name).

MobileCRM.FetchXml.Condition Object

Represents a FetchXml attribute condition statement.

Properties

Property Type Description
attribute String The attribute name (CRM logical field name).
operator String The 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”, …
uiname String The lookup target entity display name.
uitype String The lookup target entity logical name.
value The value to compare to.
values Array The list of values to compare to.

MobileCRM.FetchXml.Entity Object

Represents a FetchXml query root entity.

Properties

Property Type Description
attributes Array An array of MobileCRM.FetchXml.Attribute objects.
filter MobileCRM.FetchXml.Filter A query filter.
linkentities Array An array of MobileCRM.FetchXml.LinkEntity objects.
name String An entity logical name.
order Array An array of MobileCRM.FetchXml.Order objects.

Methods

Method Description
constructor Constructs an instance of MobileCRM.FetchXml.Entity object.
addAttribute Adds an entity attribute to the fetch query.
addAttributes Adds all entity attributes to the fetch query.
addFilter Adds a filter for this fetch entity.
addLink Adds an entity link (join) to the fetch query.
orderBy Adds an order by statement to the fetch query.
removeLink Removes an entity link from the fetch query.

MobileCRM.FetchXml.Entity.constructor Method

Constructs an instance of MobileCRM.FetchXml.Entity object.

Arguments

Argument Type Description
name String An entity logical name.

MobileCRM.FetchXml.Entity.addAttribute Method

Adds an entity attribute to the fetch query.

Arguments

Argument Type Description
name String The attribute (CRM logical field name) to order by.
alias String Optional parameter defining an attribute alias.
aggregate String Optional 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

Argument Type Description
attribute String The attribute (CRM logical field name) to order by.
descending Boolean false, 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

Property Type Description
aggregate Boolean Indicates whether the fetch is aggregated.
count int the maximum number of records to retrieve.
entity MobileCRM.FetchXml.Entity An entity object.
page int 1-based index of the data page to retrieve.

Methods

Method Description
constructor Constructs an instance of MobileCRM.FetchXml.Fetch object.
execute Performs the asynchronous CRM Fetch request.
executeAsync Performs 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.

Functions

Function Description
deserializeFromXml Deserializes the Fetch object from XML.
executeFromXML Performs the asynchronous CRM Fetch command.

MobileCRM.FetchXml.Fetch.constructor Method

Constructs an instance of MobileCRM.FetchXml.Fetch object.

Arguments

Argument Type Description
entity MobileCRM.FetchXml.Entity An entity object.
count int the maximum number of records to retrieve.
page int 1-based index of the data page to retrieve.

MobileCRM.FetchXml.Fetch.execute Method

Performs the asynchronous CRM Fetch request.

Arguments

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
success function(result) A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
online Boolean Optional 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 is asynchronously resolved with the objects array of 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

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
success function(result) A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.executeOnline Method

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

Arguments

Argument Type Description
output String A string defining the output format: Array, JSON, XML or DynamicEntities.
success function(result) A callback function for successful asynchronous result. The result argument will carry the objects array of type specified by output argument.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.serializeToXml Method

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

Arguments

Argument Type Description
success function(String) A callback function for successful asynchronous result. The result argument will carry the XML representation of the Fetch object.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

MobileCRM.FetchXml.Fetch.deserializeFromXml Function

Deserializes the Fetch object from XML.

Arguments

Argument Type Description
xml String A string defining the fetch XML request.
success function(result: MobileCRM.FetchXml.Fetch) A callback function for successful asynchronous result. The result argument will carry the Fetch object.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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.executeFromXML Function

Performs the asynchronous CRM Fetch command.

Arguments

Argument Type Description
fetchXmlData String CRM fetch in XML representation.
success function(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).
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

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

Property Type Description
conditions Array An array of Condition objects.
filters Array An array of Filter objects representing child-filters.
type String Defines the filter operator (“or” / “and”).

Methods

Method Description
between Adds a condition that the passed attribute is between the passed bounds.
contains Adds a condition that the passed column starts with the passed string.
isIn Adds a attribute inclusion condition to the filter.
notIn Adds a attribute inclusion condition to the filter.
startsWith Adds a condition that the passed column value contains the passed string.
where Adds a attribute condition to the filter.

MobileCRM.FetchXml.Filter.between Method

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

Arguments

Argument Type Description
attribute String The attribute name (CRM logical field name).
low Depends on attribute type The lower bound.
high Depends on attribute type The 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

Argument Type Description
attribute String The attribute name (CRM logical field name).
value String The 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

Argument Type Description
attribute String The attribute name (CRM logical field name).
values Array An 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

Argument Type Description
attribute String The attribute name (CRM logical field name).
values Array An 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

Argument Type Description
attribute String The attribute name (CRM logical field name).
value String The 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

Argument Type Description
attribute String The attribute name (CRM logical field name).
op String The condition operator. “eq”, “ne”, “lt”, “le”, “gt”, “ge”, “like”
value Depends on attribute type The 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

Property Type Description
alias String A link alias.
from String The “from” field (if parent then target entity primary key).
linkType String The link (join) type (“inner” or “outer”).
to String The “to” field.

Methods

Method Description
constructor Constructs an instance of MobileCRM.FetchXml.LinkEntity object.

MobileCRM.FetchXml.LinkEntity.constructor Method

Constructs an instance of MobileCRM.FetchXml.LinkEntity object.

Arguments

Argument Type Description
name String An entity name

MobileCRM.FetchXml.Order Object

Represents a FetchXml order statement.

Properties

Property Type Description
alias String Defines an order alias.
attribute String An attribute name (CRM logical field name).
descending Boolean true, for descending order; false, for ascending order.

Methods

Method Description
constructor Constructs an instance of MobileCRM.FetchXml.Order object.

MobileCRM.FetchXml.Order.constructor Method

Constructs an instance of MobileCRM.FetchXml.Order object.

Arguments

Argument Type Description
attribute String An attribute name (CRM logical field name).
descending Boolean true, 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

Object Description
EntityForm Represents the Javascript equivalent of native entity form object.
EntityList [v9.2] Represents the Javascript equivalent of native entity list object.
EntityListCellAction Enumeration class holding constants for MobileCRM.UI.EntityListClickEvent.
EntityListClickContext Represents a context for the MobileCRM.UI.EntityList.onClick handler.
EntityListClickEvent Represents an event object for MobileCRM.UI.EntityListClickContext.
Form [v8.0] Represents the Javascript equivalent of the form object.
FormManager A 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.
ListDataSource The data source loading routine implementation.
LookupForm This object allows user to select an entity from a configurable list of entity types.
MediaTab Represents the MediaTab controller.
MessageBox This 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.
TourplanForm Represents the Javascript equivalent tourplan form object.
TourplanViewMode Enumeration class holding constants for MobileCRM.UI.TourplanForm.
ViewController Represents the Javascript equivalent of view controller (map/web content).
ViewDefinition Represents the entity view definition.
_AppointmentView Represents the Javascript equivalent view of tourplan form object.
_Controller Represents the Javascript equivalent of the view controller object.
_DetailItem Represents the Javascript equivalent of detail item which is controlling the field editing.
_DetailView Represents the Javascript equivalent of detail view with set of items responsible for fields editing.
_EntityList Represents the Javascript equivalent of the entity list controller object.
_ListView Represents the Javascript equivalent of the list view (control) object.
_View Represents 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

Property Type Description
associatedViews Array Gets the associated views as an array of MobileCRM.UI._EntityList objects.
canEdit Boolean Gets whether the form can be edited.
canClose Boolean Determines if form can be closed, i.e. there are no unsaved data being edited.
context Object Gets 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.
controllers Array Gets the form controllers (map, web) as an array of MobileCRM.UI._Controller objects.
detailViews Array Gets the detailView controls as an array of MobileCRM.UI._DetailView objects.
entity MobileCRM.DynamicEntity Gets or sets the entity instance the form is showing.
form MobileCRM.UI.Form Gets the top level form.
iFrameOptions Object Carries the custom parameters that can be specified when opening the form using MobileCRM.UI.FormManager.
isDirty Boolean Indicates whether the form has unsaved data.
relationship MobileCRM.Relationship Defines relationship with parent entity.
visible Boolean Gets whether the underlying form is visible.

Methods

Method Description
cancelValidation Stops the onSave validation and optionally causes an error message to be displayed.
getController Returns the tab controller by its view name.
getDetailView Returns the DetailView by its name.
getMediaTab Gets the MediaTab object representing the media tab with given name.
reactivateEntity Reactivates inactive entity and reloads the form.
selectTab [v8.0] Selects the form tab by its name.
selectView Selects the associated entity list view by its name.
setTabVisibility Sets 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.
suspendSave Suspends current “onSave” validation and allows performing another asynchronous tasks to determine the validation result
updateAddressFields Sets the address fields according to the current geo-location from platform-specific location service.

Functions

Function Description
closeWithoutSaving Closes the form ignoring all changes that have been made on it.
enableCommand Enables 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.
onCanExecuteCommand Binds or unbinds the handler called when the EntityForm needs to find out whether the command can be executed (is enabled).
onChange Binds or unbinds the handler for onChange event on EntityForm.
onCommand Binds 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.
onSave Binds 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.
refreshForm Reloads the form’s edit state.
requestObject Requests the managed EntityForm object.
save [v9.0]Saves the form entity and its children and refreshes the form.
saveAndClose Saves edited entity and closes the form.
selectTabEx [v8.0] Selects the form tab by its name.
showPleaseWait Shows a please wait message, disabling the form except for the close command.

Objects

Object Description
DetailCollection Provides 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

Argument Type Description
errorMsg String An 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

Argument Type Description
name String A 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

Argument Type Description
name String A 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

Argument Type Description
statuscode Number Activation 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

Argument Type Description
tabName String The name of the tab.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
tabName String The name of the associated entity list tab.
viewName String The 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

Argument Type Description
tabName String The name of the tab
visible Boolean Defines 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

Argument Type Description
latitude Number The latitude from geo-location from platform-specific location service
longitude Number longitude 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

Argument Type Description
command String The name of the command.
enable Boolean Determines whether to enable or disable the command.
iParam Number [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

Argument Type Description
command String The name of the EntityForm command.
callback function(entityForm) The callback function that is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
viewName String The name of the view which has to be maximized/restored.
callback function(Boolean) Asynchronous callback which is called with Boolean result: true, if the view is maximized; false, if it is restored.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.EntityForm.loadTab Function

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

Arguments

Argument Type Description
tabName String The name of the tab.
load Boolean Whether to (re)load or unload a view.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The scope for callback.

MobileCRM.UI.EntityForm.maximizeView Function

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

Arguments

Argument Type Description
viewName String The name of the view which has to be maximized/restored.
maximize Boolean true, 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

Argument Type Description
command String The name of the EntityForm command. Optionally can contain the param value separated by slash (e.g. ChangeStatus/5).
handler function(entityForm) The handler function that has to be bound or unbound. Handler’s return value indicates whether the command is enabled (true/false).
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
command String The name of the EntityForm command.
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
itemName String The name of desired detail item (mostly logical name of the field).
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.EntityForm.onPostSave Function

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

Arguments

Argument Type Description
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
detail MobileCRM.DynamicEntity detail entity.
errorCallback function(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

Argument Type Description
callback function(entityForm) The callback function that is called asynchronously with serialized EntityForm object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
tabName String The name of the tab.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
caption String Wait 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

Function Description
add Appends the product into sales order collection.
addProductWithQuantity [v10.0] Appends the product into sales order collection.
deleteById Deletes the sales entity detail (e.g. Order detail) by id.
deleteByIndex Deletes the sales entity detail (e.g. Order detail) by index.
get Asynchronously returns requested sales entity detail (e.g. Order detail)
getAll Asynchronously returns the collection of the sales entity details (e.g. Order details)
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

Argument Type Description
product MobileCRM.Reference A reference of the product to be appended.
callback function(MobileCRM.DynamicEntity) The callback function which is called asynchronously with MobileCRM.DynamicEntity object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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.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

Argument Type Description
product MobileCRM.Reference A reference of the product to be appended.
quantity Number Product quantity.
callback function(MobileCRM.DynamicEntity) The callback function which is called asynchronously with MobileCRM.DynamicEntity object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
id String An id of the item to be deleted.
callback Function The callback function which is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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. }

MobileCRM.UI.EntityForm.DetailCollection.deleteByIndex Function

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

Arguments

Argument Type Description
index Number An index of the item to be deleted.
callback Function The callback function which is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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. }

MobileCRM.UI.EntityForm.DetailCollection.get Function

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

Arguments

Argument Type Description
index Number An index of requested item.
callback function(MobileCRM.DynamicEntity) The callback function that is called asynchronously with the MobileCRM.DynamicEntity object as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

Example 1

This example demonstrates how to update the order detail quantity by desired index. In case if index is less than size of collection, exception will be thrown.

  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

Argument Type Description
callback function(Array) The callback function that is called asynchronously with an array of MobileCRM.DynamicEntity objects as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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.onChange Function

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

Arguments

Argument Type Description
handler function(entityForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Property Type Description
allowAddExisting Boolean Gets or sets whether adding an existing entity is allowed.
allowCreateNew Boolean Gets or sets whether create a new entity (or managing the N:N entities in the case of N:N list) is allowed.
allowedDocActions Number Gets or sets a mask of document actions (for Note and Sharepoint document lists).
allowSearch Boolean Gets or sets whether to show the search bar.
autoWideWidth String Gets the view auto width pixel size.
context Object [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.

entityName String Gets the name of the entities in this list.
flipMode Number Gets or sets the flip configuration (which views to show and which one is the initial).
hasMapViews Boolean Gets whether the list has a view that can be displayed on map.
hasCalendarViews Boolean Gets or sets whether there is a view with “CalendarFields”.
hasMoreButton Boolean Gets whether the list needs a more button.
internalName String Gets the internal list name. Used for localization and image lookup.
isDirty Boolean Gets or sets whether the list is dirty.
isLoaded Boolean Gets or sets whether the list is loaded.
isMultiSelect Boolean Gets whether multi selection is active.
listButtons Array Gets the read-only array of strings defining the list buttons.
listMode Number Gets the current list mode.
listView MobileCRM.UI._ListView Gets the controlled listView control.
lookupSource MobileCRM.Relationship Gets the lookup source. If the list is used for lookup this is the entity whose property is being “looked-up”.
options Number Gets the kinds of views available on the list.
relationship MobileCRM.Relationship Gets the relation source and related entity. “null”, if there is no relationship (if it is not an associated list).
selectedEntity MobileCRM.DynamicEntity Gets currently selected entity. “null”, if there’s no selection.
uniqueName Number Gets or sets the unique name of the list. Used to save/load list specific settings.

Methods

Method Description
suspendSave [v10.0] Suspends current “onSave” validation and allows performing another asynchronous tasks to determine the validation result

Functions

Function Description
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.
onCommand Binds or unbinds the handler for EntityList command.
onSave [v10.0] Binds or unbinds the handler for onSave event on EntityList.
reload Initiates asynchronous entity list reload.
requestEditedEntities [v10.0] Asynchronously gets the list of entities that were changed on the list.
requestObject Requests the EntityList object.
runCommand Executes the list/button command attached to this entity list.
selectView Selects specified EntityList view.
setDataSource Sets 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.
setPrimaryCommand Overrides 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

Argument Type Description
rowIndex Number The index of the row to click on.
cellIndex Number The index of the cell.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
handler function(entityList) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
handler function(entityList) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
command String The name of the EntityList command.
handler function(entityList) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
handler function(entityList) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
callback function(DynamicEntity[]) Callback obtaining an array of dynamic entities that were changed on the list.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Argument Type Description
callback function(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.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
commandName String A name of the command. It can be either custom command or one of following predefined commands:
parameter Number A command parameter (e.g. the status code value for ChangeStatus command).
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The scope for callback.

MobileCRM.UI.EntityList.selectView Function

Selects specified EntityList view.

Arguments

Argument Type Description
viewName String The 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. }, MobileCRM.bridge.alert, null);
  20. }, 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

Argument Type Description
dataSource MobileCRM.UI.ListDataSource A 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

Argument Type Description
dataSourceFactory Function A 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

Argument Type Description
rowIndex Number The index of the entity in the list.
propertyName String The name of the property.
editValue any the new property value.
saveImmediately Boolean Indicates whether to save entity immediately or whether to just make it dirty.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The scope for callback.

MobileCRM.UI.EntityList.setPrimaryCommand Function

Overrides the entity list’s primary command button.

Arguments

Argument Type Description
labels Array/String An array of labels or single label (e.g. “New”).
callback Function A callback which is called when command is launched.
scope Object A scope, in which the callback has to be called.

MobileCRM.UI.EntityList.startEditCell Function

Arguments

Argument Type Description
rowIndex Number The index of the row to edit.
cellIndex Number The index of the cell.
saveImmediately Boolean Indicates whether to save entity immediately after change or whether to just make it dirty.
binding Number Optional, if null the binding from the cell index will be used.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The scope for callback.

MobileCRM.UI.EntityListCellAction Object

Enumeration class holding constants for MobileCRM.UI.EntityListClickEvent.

Properties

Property Type Description
Text Number Cell displaying data bound or constant text.
Image Number Cell displaying data bound or constant image.
Button Number Clickable button cell.
InlineButton Number The inline button. iOS only.
Editable Number The cell is editable. Or together with Text kind.
Clickable Number The cell is clickable. Or together with Text kind.
DirectEdit Number The cell is editable and will be saved right after change. Or together with Text kind.
ActionMask Number The cell is editable or clickable.

MobileCRM.UI.EntityListClickContext Object

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

Properties

Property Type Description
entities Array Single item array containing the DynamicEntity object representing clicked entity.
propertyName String The field name that was clicked within the list item.
event MobileCRM.UI.EntityListClickEvent Event details.

MobileCRM.UI.EntityListClickEvent Object

Represents an event object for MobileCRM.UI.EntityListClickContext.

Properties

Property Type Description
cell Number An index of the cell in row template.
row Number The row index.
binding Number A binding value.
action Number Click action flags. Use constant from MobileCRM.UI.EntityListCellAction enumeration.

MobileCRM.UI.Form Object

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

Properties

Property Type Description
canMaximize Boolean Gets or sets whether form can be maximized to fullscreen (full application frame).
isMaximized Boolean Gets or sets whether form is currently maximized to fullscreen (full application frame).
caption String Gets or sets the form caption.
selectedViewIndex Number Gets or sets the selected view (tab) index.
showTitle Boolean [v8.1] Determines whether the form caption bar should be visible.
viewCount Number Gets the count of views in the form.
visible Boolean Gets whether the form is visible.

Functions

Function Description
requestObject [v8.0] Requests the currently opened Form object.
showPleaseWait Shows a please wait message, disabling the form except for the close command.
showToast Shows 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

Argument Type Description
callback function(form) The callback function that is called asynchronously with serialized Form object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
caption String Wait 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

Argument Type Description
message String A toast content message.
icon String Valid app image name (e.g. Home.Now.png).

MobileCRM.UI.FormManager Object

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

Functions

Function Description
showDetailDialog Shows an entity detail dialog.
showEditDialog Shows an entity edit dialog.
showNewDialog Shows a new entity dialog.

MobileCRM.UI.FormManager.showDetailDialog Function

Shows an entity detail dialog.

Arguments

Argument Type Description
entityName String The entity name.
id String GUID of the existing entity.
relationship MobileCRM.RelationShip The 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

Argument Type Description
entityName String The entity name.
id String GUID of the existing entity or null for new one.
relationship MobileCRM.RelationShip The optional relationship with a parent entity.
options Object A 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

Argument Type Description
entityName String The entity name.
relationship MobileCRM.RelationShip The optional relationship with a parent entity.
options Object A 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

Property Type Description
form MobileCRM.UI.Form Gets the top level form.
items Array Gets the list of the home items.
listView MobileCRM.UI._ListController Gets the list view with home items.
lastSyncResult MobileCRM.Services.SynchronizationResult [v8.1] An object with last sync results. Contains following boolean properties: newCustomizationReady, customizationDownloaded, dataErrorsEncountered, appWasLocked, syncAborted, adminFullSync, wasBackgroundSync
syncResultText String [v8.1] The last synchronization error text.
syncProgress Object [v8.1] An object with current sync progress. Contains following properties: labels, percent. It is undefined if no sync is running.

Functions

Function Description
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

Argument Type Description
callback function() The callback function that is called asynchronously after forms were closed successfully.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.HomeForm.closeHomeItemAsync Function

[v8.0] Close the specified HomeItem.

Arguments

Argument Type Description
name String The 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”.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
handler function(homeForm) A function which will be called when the synchronization finished event occurs with current instance of the MobileCRM.UI.HomeForm as parameter.
scope Object A 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

Argument Type Description
items Array A list of group and subgroups representing the path to the home item.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
name String The 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”.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(homeForm) The callback function that is called asynchronously with serialized HomeForm object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
items Array A list of group and subgroups representing the path to the home item.
title String The title for the home item.
subTitle String The title for the home item.
badge String The title for the home item.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
items Array A 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

Property Type Description
form MobileCRM.UI.Form Gets the form hosting the iFrame.
isDirty Boolean [v10.0] Controls whether the form is dirty and requires save, or whether it can be closed.
options Object Carries the custom parameters that can be specified when opening the form using MobileCRM.UI.IFrameForm.show function.
preventCloseMessage String [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.
saveBehavior Number [v10.0] Controls the behavior of the Save command on this form (0=Default, 1=SaveOnly, 2=SaveAndClose).

Methods

Method Description
suspendSave [v10.0] Suspends current “onSave” process and allows performing asynchronous tasks to save the data.

Functions

Function Description
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.
show Shows a new iFrame form.
showModal Shows 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

Argument Type Description
handler function(IFrameForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The 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

Argument Type Description
callback function(iFrameForm) The callback function that is called asynchronously with serialized MobileCRM.UI.IFrameForm object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
caption String Defines the form caption.
url String Defines the URL of the HTML document.
maximized Boolean Indicates whether the new form should be maximized.
options Object Generic 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

Argument Type Description
caption String Defines the form caption.
url String Defines the URL of the HTML document.
options Object Generic 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

Property Type Description
chunkSize Number Controls the number of entities loaded in once.
fetch MobileCRM.FetchXml.Fetch Gets the original fetch request for this list view.
loadNextChunk function(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

Method Description
chunkReady This 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

Argument Type Description
entities Array[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

Property Type Description
entities Array An array of allowed entity kinds (schema names).
allowedViews String OBSOLETE: Allowed views, or null if all are allowed.
source MobileCRM.Relationship The entity whose property will be set to the chosen value.
prevSelection MobileCRM.Reference The entity whose property will be set to the chosen value.
allowNull Boolean Whether to allow selecting no entity.
preventClose Boolean Whether to prevent closing form without choosing a value.

Methods

Method Description
addEntityFilter Defines a fetch XML filter for entity records.
addView Appends an entity view to the list of allowed views.
show Shows 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

Argument Type Description
entityName string Entity logical name.
filterXml string A 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

Argument Type Description
entityName string Entity logical name.
viewName string A name of the view.
isDefault Boolean true, 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

Argument Type Description
success function(obj) The callback function that is called with chosen MobileCRM.Reference object.
failed function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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.MediaTab Object

Represents the MediaTab controller.

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

Methods

Method Description
capturePhoto Captures photo on this media tab.
clear Clears the content of this media tab.
export Saves to file to disk.
getData [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.
open Opens the loaded document in a external application. Which application is platform specific.
print Prints the document.
recordAudio Executes the record audio command on this media tab.
recordVideo Executes the record video command on this media tab.
selectFile Executes the select file command on this media tab.
selectPhoto Executes 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

Function Description
getData [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

Argument Type Description
callback function(String) The callback function that is called asynchronously with the base64-encoded document data.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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.getDocumentInfo Method

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

Arguments

Argument Type Description
callback function(Object) The callback function that is called asynchronously with the document info object.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(String) The callback function that is called asynchronously with the media tab note subject.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(Boolean) The callback function that is called asynchronously with the boolean value indicating whether the content is empty or not.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
commandMask Number Specifies the mask of allowed commands.
errorCallback function(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

Argument Type Description
editable Boolean Indicates whether to mark MediaTab as editable.
errorCallback function(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

Argument Type Description
subject String The name of the note to load (and save).
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.MediaTab.getData Function

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

Arguments

Argument Type Description
viewName String The name of the media tab.
callback function(String) The callback function that is called asynchronously with the base64-encoded document data.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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.MessageBox Object

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

Properties

Property Type Description
items Array An array of button names.
title string The message box title.
defaultText string The cancel button title text.
multiLine Boolean Indicates whether the message is multi line.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.MessageBox object.
show Shows a popup window which allows the user to choose one of the actions.

Functions

Function Description
sayText Shows a simple popup window with a multi-line text.

MobileCRM.UI.MessageBox.constructor Method

Constructs an instance of MobileCRM.UI.MessageBox object.

Arguments

Argument Type Description
title string The message box title.
defaultText string The cancel button title text.

MobileCRM.UI.MessageBox.show Method

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

Arguments

Argument Type Description
success function(obj) The callback function that is called with chosen item string.
failed function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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.sayText Function

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

Arguments

Argument Type Description
text String A text to be shown.
success function The callback function that is called after user closes the message box.
failed function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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.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

Property Type Description
entities Array An array of allowed entity kinds (schema names).
source MobileCRM.Relationship The entity whose property will be set to the chosen value.
dataSource MobileCRM.Reference[] The list of entities that should be displayed as selected.
prevSelection MobileCRM.Reference The entity whose property will be set to the chosen value.
allowNull Boolean Whether to allow selecting no entity.
preventClose Boolean Whether to prevent closing form without choosing a value.

Methods

Method Description
addEntityFilter Defines a fetch XML filter for entity records.
addView Appends an entity view to the list of allowed views.
show Shows 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

Argument Type Description
entityName string Entity logical name.
filterXml string A 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

Argument Type Description
entityName string Entity logical name.
viewName string A name of the view.
isDefault Boolean true, 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

Argument Type Description
success function(obj) The callback function that is called with chosen array of MobileCRM.Reference objects.
failed function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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.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

Property Type Description
currentStateInfo Object Gets the information about the current process flow state (active stage, visible stage and process).

Methods

Method Description
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

Argument Type Description
processRef MobileCRM.Reference A reference to the workflow entity defining the process to use, or null to disable BusinessProcessFlow.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Property Type Description
form MobileCRM.UI.Form Gets the form which hosts the questionnaire.
groups MobileCRM.UI.QuestionnaireForm.Group[] A list of QuestionnaireForm.Group objects.
questions MobileCRM.UI.QuestionnaireForm.Question[] A list of QuestionnaireForm.Question objects.
relationship MobileCRM.Relationship Gets the relation source and related entity. “null”, if there is no relationship.

Methods

Method Description
cancelValidation Stops the onSave validation and optionally causes an error message to be displayed.
findGroupById Returns the question group with given id.
findGroupByName Returns the question group with given name.
findQuestionById Returns the question item with given id.
findQuestionByName Returns the question item with given name.
suspendPostSave Suspends current “onPostSave” operations and allows performing another asynchronous tasks before the form is closed.
suspendSave Suspends current “onSave” validation and allows performing another asynchronous tasks to determine the validation result

Functions

Function Description
changeLookupQuestionSetup Sets the views and filters for specified lookup question.
deleteGroup 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.
focusQuestion Asynchronously sets the focus on given question.
getQuestionnaireEntity Requests the Questionnaire entity.
onAnswerChanged [v11.2] Binds or unbinds the handler for specific question change event on QuestionnaireForm.
onChange Binds or unbinds the handler for onChange event on QuestionnaireForm.
onDeleteGroup Binds or unbinds the handler for onDeleteGroup event on QuestionnaireForm.
onPostSave Binds or unbinds the handler for onPostSave event on QuestionnaireForm.
onRepeatGroup Binds or unbinds the handler for onRepeatGroup event on QuestionnaireForm.
onSave Binds or unbinds the handler for onSave event on QuestionnaireForm.
overridePicklistOptions Overrides the list of options for given picklist question.
repeatGroup Duplicates repeatable group with all its questions. The name of the group will contain the lowest available repeatIndex and suffix in form #00X.
requestObject Requests the managed QuestionnaireForm object.
trySetAnswer Asynchronously sets the answer value for given question.

Objects

Object Description
Group
Question

MobileCRM.UI.QuestionnaireForm.cancelValidation Method

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

Arguments

Argument Type Description
errorMsg String An 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

Argument Type Description
name String An 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

Argument Type Description
name String A 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

Argument Type Description
id String An 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

Argument Type Description
name String A 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

Argument Type Description
questionName String A name of the question.
dialogSetup MobileCRM.UI.DetailViewItems.LookupSetup Lookup setup for modal lookup dialog.
inlinePickSetup MobileCRM.UI.DetailViewItems.LookupSetup Optional setup for inline lookup picker. Leave empty to use the same setup as modal dialog.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
id String Id of the source group.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.focusQuestion Function

Asynchronously sets the focus on given question.

Arguments

Argument Type Description
questionName String A name of the question.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.getQuestionnaireEntity Function

Requests the Questionnaire entity.

Arguments

Argument Type Description
callback function(entity) The callback function that is called asynchronously with a DynamicEntity object representing currently opened questionnaire. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.onAnswerChanged Function

[v11.2] Binds or unbinds the handler for specific question change event on QuestionnaireForm.

Arguments

Argument Type Description
questionName String The name of desired question.
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onChange Function

Binds or unbinds the handler for onChange event on QuestionnaireForm.

Arguments

Argument Type Description
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onDeleteGroup Function

Binds or unbinds the handler for onDeleteGroup event on QuestionnaireForm.

Arguments

Argument Type Description
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onPostSave Function

Binds or unbinds the handler for onPostSave event on QuestionnaireForm.

Arguments

Argument Type Description
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onRepeatGroup Function

Binds or unbinds the handler for onRepeatGroup event on QuestionnaireForm.

Arguments

Argument Type Description
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.onSave Function

Binds or unbinds the handler for onSave event on QuestionnaireForm.

Arguments

Argument Type Description
handler function(questionnaireForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

MobileCRM.UI.QuestionnaireForm.overridePicklistOptions Function

Overrides the list of options for given picklist question.

Arguments

Argument Type Description
questionName String A name of the picklist question.
allowNull Boolean Indicates whether the empty answer is allowed.
options Object An object with label-to-value mappings, e.g. {“Option 1″:1,”Option 2”:2}.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
id String Id of the source group.
copyValues Boolean Optional paramater determining whether the group values should be copied to the new instance of this group.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(questionnaireForm) The callback function that is called asynchronously with serialized QuestionnaireForm object as argument. Callback should return true to apply changed properties.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.trySetAnswer Function

Asynchronously sets the answer value for given question.

Arguments

Argument Type Description
questionName String A name of the question.
answer any A value that has to be set as answer. It must correspond to the type of question.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Group Object

Properties

Property Type Description
id String Gets the id of this question group.
name String Gets the name of the question group.
index Number Gets the index of the question group.
label String Gets the question group label.
description String Get the question group description.
templateGroup String Gets the id of parent group from questionnaire template.
repeatIndex Number Index of this instance of repeatable group. Zero for non-repeatable groups.
repeatEnabled Boolean Indicates whether the group is repeatable.
isVisible Boolean Gets or sets whether the group is visible.
isEnabled Boolean Gets or sets whether the group is enabled.
isExpanded Boolean Gets or sets whether the group is expanded (true) or collapsed (false).

Methods

Method Description
deleteGroup 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.
repeatGroup Duplicates 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

Argument Type Description
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
copyValues Boolean Optional parameter determining whether the group values should be copied to the new instance of this group.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Question Object

Properties

Property Type Description
id String Gets the id of this question record.
name String Gets the name of the question item.
label String Gets or sets the question item label.
index Number Gets the index of the question item.
groupId String Gets the id of parent question group (may be empty).
description String Get or sets the question item description.
type Number Gets the value type of the question item.
value Any Gets current answer value. To change it, use trySetAnswer method.
style String Gets or sets the question item style name.
isVisible Boolean Indicates whether the item is visible.
isEnabled Boolean Indicates whether the item is enabled.
focus Boolean Set to true to focus the question item.
validate Boolean Indicates whether the item should be validated.
errorMessage String Holds the error message text related to current value of the question item.

Methods

Method Description
focus Asynchronously sets the focus on this question.
trySetAnswer Asynchronously sets the answer value for this question.

MobileCRM.UI.QuestionnaireForm.Question.focus Method

Asynchronously sets the focus on this question.

Arguments

Argument Type Description
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.QuestionnaireForm.Question.trySetAnswer Method

Asynchronously sets the answer value for this question.

Arguments

Argument Type Description
answer any A value that has to be set as answer. It must correspond to the type of question (String/Number/Reference/Guid).
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.ReportForm Object

[v8.1] Represents the Dynamics CRM report form object.

Properties

Property Type Description
allowedReportIds Array The list of report entity ids that has to be included in the report form selector.
allowedLanguages Array The list of LCID codes of the languages that has to be included into the report form selector. The number -1 stands for “Any language”.
defaultReport String The primary name of the report entity that should be pre-selected on the report form.

Methods

Method Description
show Shows the Dynamics CRM report form.

MobileCRM.UI.ReportForm.show Method

Shows the Dynamics CRM report form.

Arguments

Argument Type Description
success function(obj) The callback function that is called if the report form was successfully opened.
failed function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Property Type Description
isDirty Boolean Indicates whether the form has been modified.
isLoaded Boolean Gets or sets whether the form is loaded.
view MobileCRM.UI._AppointmentView Gets tourplan form view MobileCRM.UI.AppointmentView.

Functions

Function Description
onCreateNew [v11.3] Binds or unbinds the handler for creating new appointment after long-pressing on calendar.
requestObject Requests the managed TourplanForm object.
setDate Sets the current date in calendar view (Tourplan).
setMode Sets 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

Argument Type Description
handler function(tourplanForm) The handler function that has to be bound or unbound.
bind Boolean Determines whether to bind or unbind the handler.
scope Object The scope for handler calls.

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

Argument Type Description
callback function(platform) The callback function that is called asynchronously with serialized TourplanForm object as argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.UI.TourplanForm.setDate Function

Sets the current date in calendar view (Tourplan).

Arguments

Argument Type Description
date Date A date to set.
errorCallback function(errorMsg) The errorCallback which is called in case of error.

MobileCRM.UI.TourplanForm.setMode Function

Sets the calendar view (Tourplan) mode.

Arguments

Argument Type Description
mode MobileCRM.UI.TourplanViewMode A mode to set.
errorCallback function(errorMsg) The errorCallback which is called in case of error.

MobileCRM.UI.TourplanViewMode Object

Enumeration class holding constants for MobileCRM.UI.TourplanForm.

Properties

Property Type Description
Agenda Number Agenda view.
Day Number Day view.
Week Number Week view.
Month Number Month view.

MobileCRM.UI.ViewController Object

Represents the Javascript equivalent of view controller (map/web content).

Functions

Function Description
createCommand Overrides the form’s primary/secondary command button.

MobileCRM.UI.ViewController.createCommand Function

Overrides the form’s primary/secondary command button.

Arguments

Argument Type Description
primary Boolean true, for primary button; false, for secondary button.
labels Array/String An array of labels or single label.
callback Function A callback which is called when command is launched.
scope Object A 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

Property Type Description
entityName String Gets the entity this view is for.
name String Gets the name of the view.
fetch String Gets the fetchXml query.
kind Number Gets the kind of the view (public, associated, etc.).
version Number Gets the version.
buttons String Gets the view buttons.
selector String Gets the view template selector workflow.

Functions

Function Description
loadEntityViews Asynchronously loads all view definitions for given entity.

MobileCRM.UI.ViewDefinition.loadEntityViews Function

Asynchronously loads all view definitions for given entity.

Arguments

Argument Type Description
entityName String The entity name.
callback function(viewDefArray) The callback function which is called asynchronously. Callback will obtain an array of ViewDefinition objects.
errorCallback function(errorMsg) The errorCallback which is called asynchronously in case of error.
scope Object The 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

Property Type Description
name String Gets the name of view.
isVisible Boolean Gets or sets whether the view is visible.
mode MobileCRM.UI.TourplanViewMode Gets a view mode MobileCRM.UI.TourplanViewMode.
currentDate Date Gets the current date of displayed view.

MobileCRM.UI._Controller Object

Represents the Javascript equivalent of the view controller object.

Properties

Property Type Description
isDirty Boolean Gets or sets whether the controller contains dirty data that should be saved.
isLoaded Boolean Gets or sets whether the controller is loaded.
view MobileCRM.UI._View Gets or sets the view (control) instance.

MobileCRM.UI._DetailItem Object

Represents the Javascript equivalent of detail item which is controlling the field editing.

Properties

Property Type Description
dataMember String Gets or sets the item data binding.
errorMessage String Gets or sets the item error message displayed during validation.
isEnabled Boolean Gets or sets whether the item is editable.
isNullable Boolean Gets or sets whether the item value can be “null”.
isVisible Boolean Gets or sets whether the item is visible.
label String Gets or sets the item label.
name String Gets or sets the item name.
validate Boolean Gets or sets whether the item needs validation.
 
isPassword (text items only) Boolean Gets or sets whether the text value should be masked. Used for password entry.
kind (text items only) Number Gets or sets the value kind (0 for Text, 1 for Email, 2 for Url, 3 for Phone).
maxLength (text items only) Number Gets to sets the maximum text length.
numberOfLines (text items only) Number Number of lines to display. Default is one.
value (text items only) String Gets or sets the bound item value.
 
decimalPlaces (numeric items only) Number Gets or sets the number of decimal places.
displayFormat (numeric items only) String
increment (numeric items only) Number Gets or sets the increment (if the Up/Down control is visible).
maximum (numeric items only) Number Gets or sets the maximum allowed value.
minimum (numeric items only) Number Gets or sets the minimum allowed value.
upDownVisible (numeric items only) Boolean Gets or sets whether the up/down control is visible.
value (numeric items only) Number Gets or sets the bound item value.
 
textChecked (boolean items only) String Gets or sets the text for checked state.
textUnchecked (boolean items only) String Gets or sets the text for unchecked state.
value (boolean items only) Boolean Gets or sets the bound item value.
 
parts (DateTime items only) Number Gets or sets whether to display and edit the date, time or both (0=both, 1=date only, 2=time only).
value (DateTime items only) Date Gets or sets the bound item value.
 
value (Duration items only) Number Gets or sets the bound item value (duration in minutes).
 
displayMember (OptionSet items only) String Gets or sets the name of the property whose value is used as the label of an option.
value (OptionSet items only) Number Gets or sets the bound item value (selected value).
valueMember (OptionSet items only) String Gets 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) Boolean Gets or sets whether the item is multiline. Default is false.
value (Link items only) MobileCRM.Reference Gets 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

Property Type Description
isDirty Boolean Indicates whether the value of an item has been modified.
isEnabled Boolean Gets or sets whether the all items are enabled or disabled.
isVisible Boolean Gets or sets whether the view is visible.
items Array An array of MobileCRM.UI._DetailItem objects
name String Gets the name of the view

Methods

Method Description
getItemByName Returns the MobileCRM.UI._DetailItem with specified name or “null”.
getItemIndex Returns 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

Argument Type Description
name String A 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

Argument Type Description
name String A 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

Argument Type Description
item MobileCRM.UI.DetailViewItems.Item An item to be added.
index Number An 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

Argument Type Description
items Array(MobileCRM.UI.DetailViewItems.Item) An array of items to be added.
index Number An 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

Argument Type Description
item MobileCRM.UI.DetailViewItems.LinkItem An item
callback function(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.
scope Object A 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

Argument Type Description
index Number An 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

Argument Type Description
indexes Array An 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

Argument Type Description
index Number Selected 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

Argument Type Description
index Number Item index on the view.
listDataSource Object The data source object (e.g. {“label1”:1, “label2”:2}).
valueType String Type of list data source element value. Default is string, allowed int, string.
defaultValue String New 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

Argument Type Description
index Number Item index on the view.
dialogSetup MobileCRM.UI.DetailViewItems.LookupSetup Lookup setup for modal lookup dialog.
inlinePickSetup MobileCRM.UI.DetailViewItems.LookupSetup Optional 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

Property Type Description
allowAddExisting Boolean Gets 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.
allowedViews Object Gets or sets the allowed views (e.g. {“view1″:”Label 1”, “view2″:”Label 2”};).
entityName String Gets the name of the entities in this list.
hasMapViews Boolean Gets whether the list has a view that can be displayed on map.
internalName String Gets the internal list name. Used for localization and image lookup.
isDirty Boolean Gets or sets whether the list is dirty.
isLoaded Boolean Gets or sets whether the list is loaded.
listButtons Array Gets or sets the list buttons.
listView MobileCRM.UI._ListView Gets the list view control.

MobileCRM.UI._ListView Object

Represents the Javascript equivalent of the list view (control) object.

Properties

Property Type Description
isVisible Boolean Gets or sets whether the view is visible.
name String Gets the name of the view.
selectedIndex Number Gets or sets the index of the selected row.
templateIndex Number Gets or sets the index of the template used to paint rows in the normal state.
selectedTemplateIndex Number Gets or sets the index of the template used to paint rows in the selected state.
isScrollEnabled Boolean Gets or sets whether list can scroll. Default true.

MobileCRM.UI._View Object

Represents the Javascript equivalent of the view (control) object.

Properties

Property Type Description
isVisible Boolean Gets or sets whether the view is visible.
name String Gets the name of the view.

MobileCRM.UI.DetailViewItems Namespace

Contains a set of objects representing particular detail view items.

Objects

Object Description
CheckBoxItem [8.0] Represents the checkbox item.
ComboBoxItem [8.0] Represents the combobox item.
DateTimeItem [8.0] Represents the date/time item.
DropDownFormat An 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.
LookupSetup Represents 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

Property Type Description
textChecked String Gets or sets the text for checked state.
textUnchecked String Gets or sets the text for unchecked state.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.CheckBoxItem object.

MobileCRM.UI.DetailViewItems.CheckBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.CheckBoxItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Property Type Description
listDataSource Object Gets or sets the object with props and values to be displayed in the combo list (e.g. {“label1”:1, “label2”:2}).

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.ComboBoxItem object.

MobileCRM.UI.DetailViewItems.ComboBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.ComboBoxItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Property Type Description
minimum Date Gets or sets the minimum allowed value.
maximum Date Gets or sets the maximum allowed value.
parts Number Gets or sets whether to display and edit the date, time or both.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.DateTimeItem object.

MobileCRM.UI.DetailViewItems.DateTimeItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.DateTimeItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Property Type Description
StringList Number StringList dropdown format.
StringListInput Number StringListInput dropdown format.
MultiStringList Number MultiStringList dropdown format.
MultiStringListInput Number MultiStringListInput dropdown format.

MobileCRM.UI.DetailViewItems.DurationItem Object

[8.0] Represents the duration item.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.DurationItem object.

MobileCRM.UI.DetailViewItems.DurationItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.DurationItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Property Type Description
name String Gets or sets the item name.
label String Gets or sets the item label.
dataMember String Gets or sets the name of the property containing the item value in data source objects.
errorMessage String Gets or sets the item error message.
isEnabled Boolean Gets or sets whether the item is editable.
isVisible Boolean Gets or sets whether the item is visible.
value Object Gets or sets the bound item value.
isNullable Boolean Gets or sets whether the item value can be “null”.
validate Boolean Gets or sets whether the item needs validation.
style String The name of the Woodford item style.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.Item object.

MobileCRM.UI.DetailViewItems.Item.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.Item object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines the item label.

MobileCRM.UI.DetailViewItems.LinkItem Object

[8.0] Represents the link item.

Properties

Property Type Description
isMultiLine Boolean Gets or sets whether the item is multiline. Default is false.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.LinkItem object.

MobileCRM.UI.DetailViewItems.LinkItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.LinkItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines the item label.
listDropDownFormat MobileCRM.UI.DetailViewItems.DropDownFormat Defines 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

Method Description
addFilter Defines a fetch XML filter for entity records.
addView Appends an entity view to the list of allowed views.

MobileCRM.UI.DetailViewItems.LookupSetup.addFilter Method

Defines a fetch XML filter for entity records.

Arguments

Argument Type Description
entityName string Entity logical name.
filterXml string A 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

Argument Type Description
entityName string Entity logical name.
viewName string A name of the view.
isDefault Boolean true, if the view should be set as default.

MobileCRM.UI.DetailViewItems.NumericItem Object

[8.0] Represents the numeric item.

Properties

Property Type Description
minimum Number Gets or sets the minimum allowed value.
maximum Number Gets or sets the maximum allowed value.
increment Number Gets or sets the increment (if the upDownVisible is true).
upDownVisible Boolean Gets or sets whether the up/down control is visible.
decimalPlaces Number Gets or sets the number of decimal places.
displayFormat String Gets or sets the value format string.

Methods

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.NumericItem object.

MobileCRM.UI.DetailViewItems.NumericItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.NumericItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.SeparatorItem object.

MobileCRM.UI.DetailViewItems.SeparatorItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.SeparatorItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Property Type Description
numberOfLines Number Gets or sets the number of lines to display. Default is one.
isPassword Boolean Gets or sets whether the text value should be masked. Used for password entry.
maxLength Number Gets to sets the maximum text length.
kind Number Gets or sets the value kind (Text=0, Email=1, Url=2, Phone=3, Barcode=4).
placeholderText Number Gets 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

Method Description
constructor Constructs an instance of MobileCRM.UI.DetailViewItems.TextBoxItem object.

MobileCRM.UI.DetailViewItems.TextBoxItem.constructor Method

Constructs an instance of MobileCRM.UI.DetailViewItems.TextBoxItem object.

Arguments

Argument Type Description
name String Defines the item name.
label String Defines 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

Object Description
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.
FileInfo Carries 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

Method Description
getContact [v9.1] Gets an address book contact by its ID.

Functions

Function Description
getService [v9.1] Gets an instance of AddressBookService object.

Objects

Object Description
AddressBookRecord

MobileCRM.Services.AddressBookService.getContact Method

[v9.1] Gets an address book contact by its ID.

Arguments

Argument Type Description
id String Requested contact id.
callback function(MobileCRM.Services.AddressBookService.AddressBookRecord) The callback function which is called asynchronously with MobileCRM.Services.AddressBookService.AddressBookRecord object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Services.AddressBookService.getService Function

[v9.1] Gets an instance of AddressBookService object.

Arguments

Argument Type Description
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Property Type Description
recordId String Record id.
firstName String Record first name.
lastName String Record last name.
middleName String Record middle name.
nickName String Record nick name.
jobTitle String Job title.
organization String Organization name.
prefix String Name prefix (Title) name.
suffix String Name suffix (Title) name.
geo Array Address GPS coordinates.
url String Web page URL of record.

MobileCRM.Services.AudioRecorder Object

[v10.0] Represents a service for recording an audio.

Methods

Method Description
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

Function Description
startRecording [v10.0] Starts recording audio from microphone

MobileCRM.Services.AudioRecorder.getRecordBase64 Method

[v10.0] Returns recorded audio from microphone as base64 string

Arguments

Argument Type Description
callback function(String) The callback function that is called asynchronously with the base64-encoded recording data.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Services.AudioRecorder.getRecordFilePath Method

[v10.0] Returns absolute path to the file containing the record

Arguments

Argument Type Description
callback function(String) The callback function that is called asynchronously with the file path.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Services.AudioRecorder.stopRecording Method

[v10.0] Stops recording audio from microphone

Arguments

Argument Type Description
callback function The callback function which is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Services.AudioRecorder.startRecording Function

[v10.0] Starts recording audio from microphone

Arguments

Argument Type Description
callback function The callback function which is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Property Type Description
chatUser MobileCRM.DynamicEntity An instance of the resco_chatuser entity for current user (either system or external).
userEntity String The user entity name (either systemuser or external user entity name).
userId String Primary key (id) of the current user (either system or external).

Methods

Method Description
attachNoteToPost Creates a note (annotation) entity with the file attachment related to specified post.
postMessage Submits a new post into the channel defines by related entity reference.
subscribeToEntityChannel Subscribes current user to a channel specified by related entity.

Functions

Function Description
getService Asynchronously 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

Argument Type Description
postId String An id of the resco_chatpost entity which should have the note attached.
filePath String A path to a file that has to be attached.
mimeType String A MIME type of the file.
subject String A text which will be used as note’s subject.
callback function(MobileCRM.DynamicEntity) The callback function which is called asynchronously with MobileCRM.DynamicEntity representing newly created annotation record.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
regardingEntity MobileCRM.Reference A reference to an entity that the post should relate to.
text String The post content.
callback function(MobileCRM.DynamicEntity) The callback function which is called asynchronously with MobileCRM.DynamicEntity representing newly created resco_chatpost record.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
regardingEntity MobileCRM.Reference Reference to an entity that has to be subscribed/unsubscribed.
subscribe Boolean Determines whether to subscribe or unsubscribe entity channel.
callback Function The callback function which is called asynchronously in case of success.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.ChatService) The callback function which is called asynchronously with MobileCRM.Services.ChatService instance as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The scope for callbacks.

MobileCRM.Services.DocumentService Object

[v8.1] Represents a service for acquiring the documents.

Properties

Property Type Description
maxImageSize Number Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size.
recordQuality Number Gets or sets the record quality for audio/video recordings.
allowChooseVideo Boolean Indicates whether the video files should be included into the image picker when selecting the photos. The default is true.
allowMultipleFiles Boolean Indicates whether to allow multiple files for DocumentActions SelectPhoto and SelectFile.[Not implemented on iOS.]

Methods

Method Description
capturePhoto Asks the user to capture a photo and calls the async callback with file info.
pasteFile Takes the file from clipboard and calls the async callback with file info.
print [v9.1] Prints the document defined by file path.
recordAudio Asks the user to record an audio note and calls the async callback with file info.
recordVideo Asks 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.
selectFile Asks 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).
selectPhoto Asks 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
filePath String A file path.
landscape Boolean True, to print the document in landscape. False, to print it in portrait
errorCallback function(errorMsg) The error callback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
filePath String A file path.
maxWidth Number Max width.
maxHeight Number Max height.
callback function(result) A callback function for asynchronous result. In case of success result argument will be true otherwise false.
scope Object The 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

Argument Type Description
fileName String A file name.
fileData String Base64 encoded file data.
callback function(result) A callback function for asynchronous result. In case of success result argument will be true otherwise false.
scope Object The scope for callbacks.

MobileCRM.Services.DocumentService.selectFile Method

Asks the user to choose a file and calls the async callback with file info.

Arguments

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Argument Type Description
callback function(MobileCRM.Services.FileInfo) The callback function which is called asynchronously with MobileCRM.Services.FileInfo object as an argument.
errorCallback function(errorMsg) The errorCallback which is called in case of error.
scope Object The 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

Method Description
constructor Constructs an instance of MobileCRM.Services.DynamicsReport object.
download Downloads 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

Argument Type Description
fileName String A file name for resulting file. Leave “null” to let app to safely generate the file name and extension.
format String One of following formats (must be supported in Dynamics): XML, CSV, PDF, MHTML, EXCELOPENXML, WORDOPENXML, IMAGE.
success function(location) A callback function that is called with the full path to downloaded file.
failed function(errorMsg) A callback which is called in case of error.
scope Object The 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

Property Type Description
filePath String Gets the full path of the local file.
url String Gets the local URL of the file which can be used from within this HTML document.
mimeType String Gets the file MIME type.
nextInfo MobileCRM.Services.FileInfo Gets 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

Property Type Description
streetNumber String Gets or sets the street number.
street String Gets or sets the street.
city String Gets or sets the city.
zip String Gets or sets the zip code.
stateOrProvince String Gets or sets the state or province.
country String Gets or sets the country.
isValid String Indicates whether the address is valid.

Methods

Method Description
toLocation Translates the civic address represented by GeoAddress object into GPS position.

Functions

Function Description
fromLocation Translates 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

Argument Type Description
success function(location) A callback function that is called with the location object having latitude and longitude properties.
failed function(errorMsg) A callback which is called in case of error.
scope Object The 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

Argument Type Description
latitude Number Latitude value of the GPS position.
longitude Number Longitude value of the GPS position.
success function(address) A callback function that is called with the GeoAddress object as argument.
failed function(errorMsg) A callback which is called in case of error.
scope Object The 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

Property Type Description
userName String The authentication user name.
password String The authentication password.
method String The http method to use for the request (e.g. “POST”, “GET”, “PUT”).
headers Object An object of additional header key/value pairs to send along with requests using the HttpWebRequest.
contentType String The htt request data content type.
allowRedirect Boolean The http allows servers to redirect a client request to a different location.
responseEncoding String The http web response encoding type. (default: UTF-8), e.g. Base64, ASCII, UTF-8, Binary in case of blob.
responseType String The HttpWebResponse content type.

Methods

Method Description
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

Argument Type Description
url String The Url of server where HTTP request will be sent.
callback function(response) A callback function that is called with the web response having “responseCode” and “responseText” properties.
scope Object The scope for callbacks.

MobileCRM.Services.HttpWebRequest.setBody Method

[v11.0] Set content body of http web request.

Arguments

Argument Type Description
body String The body content.
encoding String The encoding (e.g. UTF-8, ASCII, Base64, Binary)

MobileCRM.Services.HttpWebRequest.setCredentials Method

[v10.4] Set Network credentials information.

Arguments

Argument Type Description
userName String The authentication user name.
password String The authentication password.

MobileCRM.Services.HttpWebRequest.setResponseEncoding Method

[v11.0] Set encoding for content type of http web response.

Arguments

Argument Type Description
encoding String The encoding (e.g. UTF-8, ASCII, Base64)

MobileCRM.Services.SynchronizationResult Object

[v8.1] Represents the synchronization result.

Properties

Property Type Description
newCustomizationReady Boolean Indicates whether the new customization is ready.
customizationDownloaded Boolean Indicates whether the new customization was applied.
dataErrorsEncountered Boolean Indicates whether some data errors were encountered during sync (cannot upload, delete, change status, owner, etc.).
appWasLocked Boolean Application was locked.
syncAborted Boolean Sync was aborted.
adminFullSync Boolean Full sync was requested so background sync was aborted.
webError Boolean Indicates whether sync failed due to a communication error (HttpException, for example).
connectFailed Boolean Indicates whether sync could not start because of a connection failure.
wasBackgroundSync Boolean Indicates whether the last sync was background sync or foreground sync.

MobileCRM.Services.Workflow Namespace

Contains objects accessing the Dynamics 365 workflow.

Objects

Object Description
Action [v11.2] Represents custom workfow action.

MobileCRM.Services.Workflow.Action Object

[v11.2] Represents custom workfow action.

Functions

Function Description
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

Argument Type Description
actionName String The unique name of the custom action to execute.
parameters Object The object containing the parameters for the custom action.
success function(string) A callback function for successful asynchronous result. The result argument will carry the serialized response from the server.
failed function(error) A callback function for command failure. The error argument will carry the error message.
scope A scope for calling the callbacks; set “null” to call the callbacks in global scope.

API Changes

Version 11.3

New Functions

MobileCRM.Platform.sendSMS
MobileCRM.UI.Form.showToast
MobileCRM.Questionnaire.getGroupName
MobileCRM.Questionnaire.getQuestionName

New Methods

MobileCRM.DynamicEntity.saveAsync
MobileCRM.FetchXml.Fetch.executeAsync

New Events

MobileCRM.UI.TourplanForm.onCreateNew

Version 11.2

New Classes

MobileCRM.UI.TourplanForm
MobileCRM.Services.Workflow.Action

New Functions

MobileCRM.Application.setAppColors
MobileCRM.UI.EntityForm.onItemChange
MobileCRM.Platform.getNetworkInfo
MobileCRM.Services.DocumentService.saveFileDialog
MobileCRM.Services.DocumentService.selectMultiplePhotos

MobileCRM.UI.QuestionnaireForm.getQuestionnaireEntity
MobileCRM.UI.QuestionnaireForm.onAnswerChanged

New Enums

MobileCRM.UI.DetailViewItems.DropDownFormat
MobileCRM.UI.TourplanViewMode

Version 11.1

New Functions

MobileCRM.UI.EntityList.setDataSourceFactory

New Methods

MobileCRM.UI.MediaTab.export
MobileCRM.UI.MediaTab.open
MobileCRM.UI.MediaTab.print
MobileCRM.UI.MediaTab.setCommandsMask
MobileCRM.UI.MediaTab.setEditable
MobileCRM.Services.DocumentService.resizeImage

New Properties

MobileCRM.Services.DocumentService.allowMultipleFiles

Version 11.0

New Classes

MobileCRM.Services.HttpWebRequest

New Functions

MobileCRM.Platform.scanBarCodeRequiredLength
MobileCRM.UI.HomeForm.restoreUIReplacement

New Properties

MobileCRM.UI.LookupForm.preventClose
MobileCRM.Service.SynchronizationResult.connectFailed
MobileCRM.Service.SynchronizationResult.webError

Version 10.3

New Classes

MobileCRM.UI.QuestionnaireForm

New Functions

MobileCRM.Application.showAppLogin
MobileCRM.Platform.openDocument
MobileCRM.UI.HomeForm.updateHomeItems

New Properties

MobileCRM.Platform.isMultiPanel
MobileCRM._Settingd.canUsePassword
MobileCRM._Settingd.clientCertificateThumbprint
MobileCRM._Settingd.incSyncUsesVersionNumberSorting
MobileCRM._Settingd.syncEmailAsText

Version 10.2

New Classes

MobileCRM.CultureInfo
MobileCRM.DateTimeFormat
MobileCRM.NumberFormat
MobileCRM.Questionnaire

New Functions

MobileCRM.Platform.makeCall
MobileCRM.UI.EntityForm.selectTabEx
MobileCRM.UI.HomeForm.updateHomeItemAsync
MobileCRM.UI.MessageBox.sayText

Version 10.1

New Classes

MobileCRM.UI.EntityListClickContext
MobileCRM.UI.EntityListClickEvent
MobileCRM.UI.DetailViewItems.LookupSetup

New Functions

MobileCRM.Application.checkUserRoles
MobileCRM.Metadata.getStringListOptions
MobileCRM.MobileReport.showForm
MobileCRM.Platform.preventBackButton
MobileCRM.UI.EntityForm.loadTab
MobileCRM.UI.EntityList.clickCell
MobileCRM.UI.EntityList.onClick
MobileCRM.UI.EntityList.setEntityProperty
MobileCRM.UI.EntityList.startEditCell

New function parameters

MobileCRM.Platform.getLocation

New Prototype Methods

MobileCRM.FetchXml.Entity.removeLink
MobileCRM.UI.MediaTab.getNoteSubject
MobileCRM.UI.MediaTab.setNoteSubject
MobileCRM.UI._DetailView.updateLinkItemViews

Version 10.0

New Classes

MobileCRM.Services.AudioRecorder

New Functions

MobileCRM.DynamicEntity.saveDocumentBody
MobileCRM.FetchXml.Fetch.deserializeFromXml
MobileCRM.Localization.initializeEx
MobileCRM.UI.EntityForm.DetailCollection.addProductWithQuantity
MobileCRM.UI.EntityList.onChange
MobileCRM.UI.EntityList.onSave
MobileCRM.UI.EntityList.requestEditedEntities
MobileCRM.UI.IFrameForm.onSave
MobileCRM.UI.IFrameForm.preventClose
MobileCRM.UI.IFrameForm.setDirty

New Prototype Methods

MobileCRM.FetchXml.Fetch.serializeToXml
MobileCRM.UI.EntityList.suspendSave
MobileCRM.UI.IFrameForm.suspendSave

New Properties

MobileCRM.UI.EntityList.context
MobileCRM.UI.IFrameForm.isDirty
MobileCRM.UI.IFrameForm.saveBehavior

Version 9.3

New Classes

MobileCRM.UI.MultiLookupForm
MobileCRM.Services.ChatService
MobileCRM.Services.GeoAddress

New Functions

MobileCRM.UI.EntityForm.onSelectedViewChanged

New Properties

MobileCRM.UI.IFrameForm.preventCloseMessage

Version 9.2

New Classes

MobileCRM.UI.EntityList
MobileCRM.UI.ListDataSource

New Prototype Methods

MobileCRM.UI._DetailView.startEditItem
MobileCRM.UI._DetailView.updateComboItemDataSource
MobileCRM.Services.DocumentService.print

New Functions

New function parameters

MobileCRM.Platform.getLocation

Version 9.1

New Classes

MobileCRM.Services.AddressBookService

New Prototype Methods

MobileCRM.ExposedObject.asInvokeArgument

New Functions

MobileCRM.DynamicEntity.downloadAttachment
MobileCRM.DynamicEntity.unzipDocumentBody
MobileCRM.Platform.emailWithAttachments
MobileCRM.MobileReport.runReport

New function parameters

MobileCRM.UI.EntityForm.enableCommand

Version 9.0

New Classes

MobileCRM.UI.IFrameForm

New Prototype Methods

MobileCRM.Bridge.onGlobalEvent
MobileCRM.Bridge.raiseGlobalEvent
MobileCRM.UI.LookupForm.addEntityFilter
MobileCRM.UI.EntityForm.reactivateEntity

New Functions

MobileCRM.Application.readFileAsBase64
MobileCRM.Application.writeFileFromBase64
MobileCRM.UI.Form.showPleaseWait
MobileCRM.UI.HomeForm.closeForms
MobileCRM.UI.EntityForm.save
MobileCRM.UI.EntityForm.closeWithoutSaving

New Properties

MobileCRM.AboutInfo.productTitleAndVersion

Version 8.3

New Properties

MobileCRM.Configuration.licenseAlert
MobileCRM._Settings.autoSyncAfterChangeOnline
MobileCRM._Settings.autoSyncDelay
MobileCRM._Settings.createCallEntity
MobileCRM._Settings.emailSignature
MobileCRM._Settings.enableMap

New Functions

MobileCRM.Application.getDirectories
MobileCRM.Application.getFiles

Version 8.2

New Classes

MobileCRM.AboutInfo
MobileCRM.UI.ProcessController

New Properties

MobileCRM.UI.LookupForm.allowedViews

New Functions

MobileCRM.MetaEntity.loadByName
MobileCRM.Platform.openUrl
MobileCRM.Platform.navigateTo
MobileCRM.UI.EntityForm.onPostSave
MobileCRM.UI.EntityForm.refreshForm
MobileCRM.UI.EntityForm.DetailCollection.onChange
MobileCRM.UI.HomeForm.closeHomeItemAsync

New Prototype Methods

MobileCRM.FetchXml.Filter.notIn
MobileCRM.UI.EntityForm.getController
MobileCRM.UI.EntityForm.openSalesEntityDetail
MobileCRM.UI.EntityForm.suspendPostSave

New Platforms Supported

Windows 10
Windows 10 Mobile