Resco Mobile CRM - Javascript Bridge Reference
Official JSBridge GitHub PageMobileCRM 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. |
ActivityParty | Person or group associated with an activity. An activity can have multiple activity parties. |
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. |
OAuthSettings | [v12.4] Represents the settings what are used to authenticate using OAuth server account. |
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.
- // Request About info object
- MobileCRM.AboutInfo.requestObject(
- function (aboutInfo) {
- /// <param name="aboutInfo" type="MobileCRM.AboutInfo"/>
- var appReport = "About Info : \n";
- for (var prop in aboutInfo)
- appReport += prop + ": " + aboutInfo[prop] + "\n";
- MobileCRM.bridge.alert(appReport);
- },
- MobileCRM.bridge.alert // alerts an error
- );
MobileCRM.ActivityParty Object
Person or group associated with an activity. An activity can have multiple activity parties.
Properties
Property | Type | Description |
---|---|---|
entityName | String | The entity name of the party (account, contact, lead, systemuser, etc.) |
id | String | GUID of the existing entity or null for new one or direct party. |
primaryName | String | The human readable name of the reference, e.g. "Alexandro". |
isDirectParty | Boolean | Gets or sets whether the party is direct (email) or a pointer to an CRM record. |
addressUsed | String | Gets or sets the actual address used. |
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.ActivityParty object. |
MobileCRM.ActivityParty.constructor Method
Constructs an instance of MobileCRM.ActivityParty object.
Arguments
Argument | Type | Description |
---|---|---|
entityName | String | The logical entity name of the party (account, contact, lead, systemuser, etc.) |
id | String | GUID of the existing entity or null for new one or direct party. |
primaryName | String | The human readable name of the reference, e.g "Alexandro". |
isDirectParty | Boolean | Gets or sets whether the party is direct (email) or a pointer to an CRM record. |
addressUsed | String | Gets or sets the actual address used. |
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. |
createDirectoryAsync | Asynchronously creates the directory in the application local data. |
deleteDirectory | Asynchronously deletes the empty directory from the application local data. |
deleteDirectoryAsync | Asynchronously deletes the empty directory from the application local data. |
deleteFile | Asynchronously deletes the file from the application local data. |
deleteFileAsync | Asynchronously deletes the file from the application local data. |
directoryExists | Checks whether the directory with given path exists in the application local data. |
directoryExistsAsync | 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. |
fileExistsAsync | Checks whether the file with given path exists in application local data. |
getAccessToken | |
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. |
getDirectoriesAsync | Asynchronously gets the list of directories from the application local data. |
getFiles | Asynchronously gets the list of files from the application local data. |
getFilesAsync | Asynchronously gets the list of files from the application local data. |
getLastSignificantTimeChange | [v13.3.1] Gets the last detected time change. |
moveFile | Asynchronously moves the application local file to another location. |
moveFileAsync | 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. |
readFileAsync | [v15.3] Reads the file from the application local data and asynchronously gets its 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. |
writeFileAsync | [v15.3] Asynchronously writes data 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.
- MobileCRM.Application.createDirectory("TestData/MyFolder", function () {
- MobileCRM.bridge.alert("Folder was created");
- }, function () {
- MobileCRM.bridge.alert("Folder wasn't created");
- });
MobileCRM.Application.createDirectoryAsync 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. |
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.
- MobileCRM.Application.deleteDirectory("TestData/MyFolder", function (res) {
- MobileCRM.bridge.alert("Folder was deleted");
- }, function () {
- MobileCRM.bridge.alert("Folder wasn't deleted");
- });
MobileCRM.Application.deleteDirectoryAsync 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. |
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.
- MobileCRM.Application.deleteFile("TestData/MyFile.txt", function (res) {
- MobileCRM.bridge.alert("File was deleted");
- }, function () {
- MobileCRM.bridge.alert("File wasn't deleted");
- });
MobileCRM.Application.deleteFileAsync 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. |
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
- MobileCRM.Application.directoryExists("TestData/MyFolder", function (exists) {
- MobileCRM.bridge.alert(exists ? "Exists" : "Doesn't exist");
- }, MobileCRM.bridge.alert)
MobileCRM.Application.directoryExistsAsync 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. |
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
- MobileCRM.Application.fileExists("TestData/MyFile.txt", function (exists) {
- MobileCRM.bridge.alert(exists ? "Exists" : "Doesn't exist");
- }, MobileCRM.bridge.alert)
MobileCRM.Application.fileExistsAsync 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. |
MobileCRM.Application.getAccessToken Function
Arguments
Argument | Type | Description |
---|---|---|
resourceUrl | String | The resource. |
successCallback | function(textAccessToken) | A callback function what is called asynchronously with serialized access token as argument. |
failureCallback | 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.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.
- MobileCRM.Application.getAppColor("ListForeground", function (color) {
- /// <param name="color" type="String">String containing the color definition (e.g. "#FF0000" for red color).</param>
- if (color) {
- MobileCRM.bridge.alert("ListForeground color = " + color);
- var element = document.getElementById("mainTable");
- if (element)
- element.style.color = color;
- }
- });
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.getDirectoriesAsync 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. |
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.getFilesAsync 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. |
MobileCRM.Application.getLastSignificantTimeChange Function
[v13.3.1] Gets the last detected time change.
Arguments
Argument | Type | Description |
---|---|---|
success | function() | A callback function which is called in case of success. Callback will receive an object with "lastChange" date and "delta" time in sceonds. |
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.moveFileAsync 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. |
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.
- var imagePath = "Images/MobileCrm/Images.MonoTouch/Logo/Logo@2x.png";
- MobileCRM.Application.fileExists(imagePath, function (exists) {
- if (exists) {
- MobileCRM.Application.readFileAsBase64(imagePath, function (data) {
- var imgElement = document.getElementById("test-image");
- if (imgElement)
- imgElement.src = "data:image/jpeg;base64," + data;
- }, MobileCRM.bridge.alert);
- }
- else
- MobileCRM.bridge.alert("File '"+ imagePath +"' doesnt'exist");
- });
MobileCRM.Application.readFileAsync Function
[v15.3] 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. |
encoding | String | Defines the text encoding for file content (default is UTF8). Use base64 for binary files. Supported values: UTF8, UTF16 ASCII, BASE64. |
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.
- // Following line initiates immediate foreground synchronization.
- // If required "Sync login" is active, it causes all forms being closed and "Sync Login" form is being shown.
- MobileCRM.Application.synchronize(false);
- // Following line initiates the background synchronization, if the last synchronization was performed before given Date.
- // It requires "Save password" being active and "Sync login" inactive
- 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.writeFileAsync Function
[v15.3] Asynchronously writes data 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 (in corresponding text encoding) to be written. |
encoding | String | Defines the text encoding for file content data. Use base64 for binary files. Supported values: UTF8, ASCII, BASE64. |
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.
- function saveAndShowImage(base64ImageData) {
- /// <param name="base64ImageData" type="String">String containing base64-encoded image data.</param>
- MobileCRM.Application.writeFileFromBase64("ExternalImage.jpg", base64ImageData, function () {
- var imgElement = document.getElementById("test-image");
- imgElement.src = "../ExternalImage.jpg"; // Offline HTML is opened from the WWW folder and image was stored into the root folder
- }, MobileCRM.bridge.alert);
- }
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.. |
invokeMethodPromise | Invokes a method on exposed managed object asynchronously as a Promise. |
invokeStaticMethodPromise | Invokes a static method on specified type asynchronously as a Promise. |
log | [v8.0] Appends a message into the JSBridge log. |
onGlobalEvent | [v9.0] Binds or unbinds the handler for global event. |
raiseGlobalEvent | [v9.0] Raises the global event which can have listeners bound by other iFrames. |
MobileCRM.Bridge.alert Method
Shows a message asynchronously and calls the callback after it is closed by user.
Arguments
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.
- 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.
- 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.
- 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".
- MobileCRM.bridge.getWindowSize(
- function (obj) {
- MobileCRM.bridge.alert("window size : " + obj.width + " x " + obj.height);
- },
- MobileCRM.bridge.alert
- );
MobileCRM.Bridge.invokeCommandPromise Method
MobileCRM.Bridge.invokeMethodPromise Method
Invokes a method on exposed managed object asynchronously as a Promise.
Arguments
Argument | Type | Description |
---|---|---|
objectName | String | The name of exposed managed object as it was registered on C# side (IJavascriptBridge.ExposeObject). |
method | String | The name of the method implemented by object class. |
paramsList | Array | An array with parameters that should be passed to a method. |
Return value
Type: Promise<any>
A Promise object which will be resolved with JSON-serialized return value. It is either generic type or MobileCRM.ObservableObject with JSON-serialized return value..
MobileCRM.Bridge.invokeStaticMethodPromise Method
Invokes a static method on specified type asynchronously as a Promise.
Arguments
Argument | Type | Description |
---|---|---|
assembly | String | The name of the assembly which defines the type. |
typeName | String | The full name of the C# type which implements the method. |
method | String | The name of static method to be invoked. |
paramsList | Array | An array with parameters that should be passed to a method. |
Return value
Type: Promise<any>
A Promise object which will be resolved with JSON-serialized return value. It is either generic type or MobileCRM.ObservableObject with JSON-serialized return value..
MobileCRM.Bridge.log Method
[v8.0] Appends a message into the JSBridge log.
Arguments
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.
- /// This method can be used to add specific information into the JSBridge log.
- 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.
- MobileCRM.bridge.onGlobalEvent("MyCustomEvent", function (args) {
- MobileCRM.bridge.alert("Retreived arguments from raised event 'MyCustomEvent' " + JSON.stringify(args));
- }, 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.
- MobileCRM.bridge.onGlobalEvent("EntityFormClosed", function (closedEntityForm) {
- /// <param name='closedEntityForm' type='MobileCRM.UI.EntityForm'>An EntityForm object representing the form that was closed.</param>
- if (closedEntityForm.entity.entityName == "salesorderdetail")
- onProductChanged(closedEntityForm.entity.id);
- }, 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.
- MobileCRM.bridge.raiseGlobalEvent("MyCustomEvent", {
- testTitle: "My Title",
- testData: { aaa: 1, bbb: 2 },
- testDirectVal: 666
- });
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.
- MobileCRM.Configuration.requestObject(
- function (config) {
- /// <param name="config" type="MobileCRM.Configuration">/<param>
- if (config.isOnline) {
- var settings = config.settings;
- queryXYStatistics(settings.userName, settings.password, settings.domain);
- }
- // we have done no changes, thus return false to disallow sending the changes back to C#.
- return false;
- },
- function (err) {
- /// <param name="err" type="String">/<param>
- MobileCRM.bridge.alert("An error occurred: " + err);
- },
- null
- );
- function queryXYStatistics(userName, password, domain) {
- // Use CRM credentials let's say for an AJAX call to a WebService...
- }
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. |
localization | String | Gets selected localization language. |
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. |
initializeAsync | [v10.2] Initializes the CultureInfo object. |
load | [v10.2] Asynchronously gets the CultureInfo object for specified language/country. |
loadAsync | [v10.2] Asynchronously gets the CultureInfo object for specified language/country. |
longDateString | [v10.2] Returns the long date string that matches current device culture. |
longTimeString | [v10.2] Returns the long time string that matches current device culture. |
monthDayString | [v10.2] Returns the month and day string that matches current device culture. |
shortDateString | [v10.2] Returns the short date string that matches current device culture. |
shortTimeString | [v10.2] Returns the short time string that matches current device culture. |
yearMonthString | [v10.2] Returns the year and month string that matches current device culture. |
MobileCRM.CultureInfo.formatDate Function
[v10.2] Returns the formatted date/time string that matches current device culture.
This method fails if CultureInfo.initialize method hasn't completed yet.
Arguments
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.
- MobileCRM.CultureInfo.initialize(function (currentCulture) {
- ///<param name='currentCulture' type='MobileCRM.CultureInfo' />
- var formatDate = new Date();
- var monthDayPattern = "MM-MMMM, ddd-dddd";
- var customDate = MobileCRM.CultureInfo.formatDate(formatDate, monthDayPattern);
- var fullDateTime = MobileCRM.CultureInfo.fullDateTimeString(formatDate);
- var longDate = MobileCRM.CultureInfo.longDateString(formatDate);
- var longTime = MobileCRM.CultureInfo.longTimeString(formatDate);
- var shortDate = MobileCRM.CultureInfo.shortDateString(formatDate);
- var shortTime = MobileCRM.CultureInfo.shortTimeString(formatDate);
- var mothDay = MobileCRM.CultureInfo.monthDayString(formatDate);
- var yearMonth = MobileCRM.CultureInfo.yearMonthString(formatDate);
- var result =
- monthDayPattern + ": " + customDate + "\n" +
- "full date time : " + fullDateTime + "\n" +
- "long date : " + longDate + "\n" +
- "short date : " + shortDate + "\n" +
- "long time : " + longTime + "\n" +
- "short time : " + shortTime + "\n" +
- "day of month : " + mothDay + "\n" +
- "year of month : " + yearMonth + "\n";
- MobileCRM.bridge.alert(result);
- }, 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.
- MobileCRM.CultureInfo.initialize(function (currentCulture) {
- ///<param name='currentCulture' type='MobileCRM.CultureInfo' />
- var cultureInfo =
- "Display name: " + currentCulture.displayName + "\n" +
- "ISO name: " + currentCulture.ISOName + "\n" +
- "Native name: " + currentCulture.nativeName + "\n\n" +
- "Number format: " + JSON.stringify(currentCulture.numberFormat) + "\n\n" +
- "DateTime format: " + JSON.stringify(currentCulture.dateTimeFormat) + "\n" +
- "Right to left: " + currentCulture.isRightToLeft + "\n";
- // for further details about date, time and number format,
- // see MobileCRM.DateTimeFormat and MobileCRM.NumberFormat
- MobileCRM.bridge.alert(cultureInfo);
- }, MobileCRM.bridge.alert, null);
MobileCRM.CultureInfo.initializeAsync Function
[v10.2] Initializes the CultureInfo object.
Method loads the current culture information asynchronously.
All other functions will return the default or empty string before the initialization promise is resolved.
Return value
Type: Promise<MobileCRM.CultureInfo>
A Promise object which will be resolved with the loaded CultureInfo object.
MobileCRM.CultureInfo.load Function
[v10.2] Asynchronously gets the CultureInfo object for specified language/country.
Arguments
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.
- MobileCRM.CultureInfo.load("en-GB", function (info) {
- ///<param name='info' type='MobileCRM.CultureInfo' />
- var cultureInfo =
- "Display name: " + info.displayName + "\n" +
- "ISO name: " + info.ISOName + "\n" +
- "Native name: " + info.nativeName + "\n\n" +
- "Number format: " + JSON.stringify(info.numberFormat) + "\n\n" +
- "DateTime format: " + JSON.stringify(info.dateTimeFormat) + "\n" +
- "Right to left: " + info.isRightToLeft + "\n";
- // for further details about date, time and number format,
- // see MobileCRM.DateTimeFormat and MobileCRM.NumberFormat
- MobileCRM.bridge.alert(cultureInfo);
- }, MobileCRM.bridge.alert, null);
MobileCRM.CultureInfo.loadAsync Function
[v10.2] Asynchronously gets the CultureInfo object for specified language/country.
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 |
Return value
Type: Promise<MobileCRM.CultureInfo>
A Promise object which will be resolved with the loaded CultureInfo object.
MobileCRM.CultureInfo.longDateString Function
[v10.2] Returns the long date string that matches current device culture.
This method fails if CultureInfo.initialize method hasn't completed yet.
Arguments
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. |
forceDirty | Boolean | Indicates whether to force save the provided properties even if not modified. Default behavior is to save only properties that were modified. |
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. |
deleteAsync | Asynchronously deletes the CRM entity. |
deleteById | Asynchronously deletes the CRM entity. |
deleteMultiple | Saves an entity instance to storage.Where the entity is stored is determined by how it was loaded: online / offline. |
downloadAttachment | [v9.1] Initiates the attachment download for specified entity. |
downloadAttachmentAsync | [v9.1] Initiates the attachment download for specified entity. |
loadAsync | Asynchronously loads the CRM entity properties. |
loadById | Asynchronously loads the CRM entity properties. |
loadDocumentBody | Asynchronously loads the document body for specified entity. |
loadDocumentBodyAsync | Asynchronously loads the document body for specified entity. |
saveDocumentBody | [v10.0]Asynchronously saves the document body for specified entity. |
saveDocumentBodyAsync | [v10.0]Asynchronously saves the document body for specified entity. |
saveMultiple | Saves an entities instances to storage.Where the entity is stored is determined by how it was loaded: online / offline. |
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.
- var account = MobileCRM.DynamicEntity.createNew("account");
- var props = account.properties;
- props.name = "A Bike Store";
- props.address1_line1 = "Unknown";
- // ...
- account.save(
- function (error) {
- if (error)
- MobileCRM.bridge.alert("An error occurred: " + error);
- else {
- // callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
- var newId = this.id;
- var allProps = this.properties;
- rememberNewAccount(newId, allProps.name);
- }
- }
- );
Example 2
This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.
- function updateGPS(accountid, latitude, longitude) {
- var account = new MobileCRM.DynamicEntity("account", accountid);
- var props = account.properties;
- props.address1_latitude = latitude;
- props.address1_longitude = longitude;
- account.save(
- function (error) {
- if (error)
- MobileCRM.bridge.alert("An error occurred: " + error);
- else {
- // callback is called in scope of newly created MobileCRM.DynamicEntity object; thus we can access the data using "this" keyword
- logModification(this.id, this.primaryName);
- }
- }
- );
- }
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 will be resolved with saved DynamicEntity object as result.
Example 1
This example demonstrates how to modify an existing account. It updates the GPS coordinates for given account.
- function updateGPS(accountid, latitude, longitude) {
- // Instead of loading whole entity object, we'll create the DynamicEntity object
- // for Account entity with existing ID and provide just changed fields.
- var account = new MobileCRM.DynamicEntity("account", accountid);
- var props = account.properties;
- props.address1_latitude = latitude;
- props.address1_longitude = longitude;
- account.saveAsync()
- .then(function (savedEntity) {
- // Promise was fulfilled and we obtained full MobileCRM.DynamicEntity object with all its fields (including primary name)
- logModification(savedEntity.id, savedEntity.primaryName);
- })
- .catch(function (error) {
- // Promise was rejected with error
- MobileCRM.bridge.alert("An error occurred: " + error);
- });
- }
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.deleteAsync 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. |
Return value
Type: Promise<void>
A Promise object which will be resolved after the entity record is deleted.
Example 1
This example demonstrates how to delete an account with given id.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function deleteAccount(accountId) {
- try {
- await MobileCRM.DynamicEntity.deleteAsync("account", accountid);
- onAccountDeleted(accountid);
- }
- catch (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- }
- }
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.
- MobileCRM.DynamicEntity.deleteById(
- "account",
- accountid,
- function () {
- onAccountDeleted(accountid);
- },
- function (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- }
- );
MobileCRM.DynamicEntity.deleteMultiple Function
Saves an entity instance to storage.Where the entity is stored is determined by how it was loaded: online / offline.
Arguments
Argument | Type | Description |
---|---|---|
deletedEntities | MobileCRM.DynamicEntity[] | Array of MobileCRM.DynamicEntity or MobileCRM.Reference what will be deleted. |
sucessCallbacak | function(result) | A callback function for successful asynchronous result. |
failureCallback | function(error) | A callback function for command failure. The error argument will carry the error message. |
online | Boolean | Whether to load and save online or offline. Null for default mode defined by current configuration. |
scope | A scope for calling the callbacks; set "null" to call the callbacks in global scope. |
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.
- function downloadNoteAttachment(noteId) {
- MobileCRM.DynamicEntity.downloadAttachment("annotation", noteId, function (base64str) {
- /// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
- var imgElement = document.getElementById("img-result");
- if (imgElement)
- imgElement.setAttribute("src", "data:;base64," + base64str); // set the "src" attribute for out <img> element
- }, MobileCRM.bridge.alert, null);
- }
MobileCRM.DynamicEntity.downloadAttachmentAsync Function
[v9.1] Initiates the attachment download for specified entity.
Function sends an asynchronous request to application, which downloads the document body (e.g. the annotation) from server and resolves pending Javascript promise.
Arguments
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. |
Return value
Type: Promise<string>
A Promise object which will be resolved with base64-encoded data string.
Example 1
This example demonstrate how to download the note attachment image and set it into <img> element.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function downloadNoteAttachment(noteId) {
- try {
- var base64str = await MobileCRM.DynamicEntity.downloadAttachmentAsync("annotation", noteId);
- var imgElement = document.getElementById("img-result");
- if (imgElement)
- imgElement.setAttribute("src", "data:;base64," + base64str); // set the "src" attribute for out <img> element
- }
- catch (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- }
- }
MobileCRM.DynamicEntity.loadAsync 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. |
Return value
Type: Promise<MobileCRM.DynamicEntity>
A Promise object which will be resolved with an instance of DynamicEntity object representing entity record.
Example 1
This example demonstrates how to load the account entity with given id.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function getAccountData(accountId) {
- try {
- var entity = await MobileCRM.DynamicEntity.loadAsync("account", accountId);
- MobileCRM.bridge.alert(JSON.stringify(entity));
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
- }
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.
- function getAccountData(accountId) {
- /// <param name="account" type="MobileCRM.Reference"/>;
- MobileCRM.DynamicEntity.loadById(
- "account",
- accountId,
- function (entity) {
- /// <param name="entity" type="MobileCRM.DynamicEntity"/>;
- // "entity" argument contains the MobileCRM.DynamicEntity object
- MobileCRM.bridge.alert(JSON.stringify(entity.properties));
- },
- function (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- },
- null
- );
- }
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.
- function loadAccountDocumentBody(accountid){
- MobileCRM.DynamicEntity.loadDocumentBody("annotation", accountidid, function (base64str) {
- /// <param name='base64str' type='String'>parameter contains a string with base64-encoded attachment data.</param>
- MobileCRM.bridge.alert("Base64String: \n\n" + base64str);
- var imgElement = document.getElementById("img-result");
- if (imgElement)
- imgElement.setAttribute("src", "data:image/jpeg;base64," + base64str); // set the "src" attribute for out <img> element
- }, MobileCRM.bridge.alert, null);
- }
MobileCRM.DynamicEntity.loadDocumentBodyAsync Function
Asynchronously loads the document body for specified entity.
Function sends an asynchronous request to application, where the locally stored document body (e.g. the annotation.documentbody) is encoded to base64 and pending Javascript promise is resolved. This function supports both online data and the data stored in local database/BLOB store.
Arguments
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. |
Return value
Type: Promise<string>
A Promise object which will be resolved with base64-encoded data string.
Example 1
This example demonstrates how to load the document body (e.g. attached image) for given annotation (Note). Following function loads locally stored attachment for note defined by its id and sets the base-64 data as image source.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function loadAccountDocumentBody(accountid){
- try{
- var base64str = await MobileCRM.DynamicEntity.loadDocumentBody("annotation", accountidid);
- MobileCRM.bridge.alert("Base64String: \n\n" + base64str);
- var imgElement = document.getElementById("img-result");
- if (imgElement)
- imgElement.setAttribute("src", "data:image/jpeg;base64," + base64str); // set the "src" attribute for out <img> element
- }
- catch (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- }
- }
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.
- function saveAnnotation(filePath, accountReference) {
- ///<param name='filePath' type='String'>path to file for annotation attachment.</param>
- ///<param name='accountReference' type='MobileCRM.Reference'>Reference to account.</param>
- var relationship = new MobileCRM.Relationship("objectid", accountReference);
- MobileCRM.DynamicEntity.saveDocumentBody(null, null, relationship, filePath, null, function (annotation) {
- ///<param name='annotation' type='MobileCRM.Reference'>Reference to nelwy created annotation.</param>
- MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
- }, MobileCRM.bridge.alert, null);
- }
MobileCRM.DynamicEntity.saveDocumentBodyAsync Function
[v10.0]Asynchronously saves the document body for specified entity.
Function sends an asynchronous request to application, where the locally stored document body (e.g. the annotation.documentbody) is saved.
Arguments
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. |
Return value
Type: Promise<MobileCRM.Reference>
A Promise object which will be resolved with the Reference object representing updated/created entity.
Example 1
This example demonstrates how to save the document body (e.g. attached image) for newly created annotation (Note). Following function locally stores the attachment (defined by file path) for newly created note.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function saveAnnotation(filePath, accountReference) {
- ///<param name='filePath' type='String'>path to file for annotation attachment.</param>
- ///<param name='accountReference' type='MobileCRM.Reference'>Reference to account.</param>
- try{
- var relationship = new MobileCRM.Relationship("objectid", accountReference);
- var annotation = await MobileCRM.DynamicEntity.saveDocumentBody(null, null, relationship, filePath, null);
- MobileCRM.bridge.alert(annotation.entityName + " '" + annotation.primaryName + "' successfully saved.");
- }
- catch (error) {
- MobileCRM.bridge.alert("An error occurred: " + error);
- }
- }
MobileCRM.DynamicEntity.saveMultiple Function
Saves an entities instances to storage.Where the entity is stored is determined by how it was loaded: online / offline.
Arguments
Argument | Type | Description |
---|---|---|
updatedEntities | MobileCRM.DynamicEntity[] | Array of MobileCRM.DynamicEntity. |
online | Boolean | Whether to load and save online or offline. Null for default mode defined by current configuration. |
sucessCallbacak | function(result) | A callback function for successful asynchronous result. |
failureCallback | 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.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. |
initializeAsync | [v10.0] 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.
- MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
- function startPointFn(localization) {
- // returns the localized text for localization ID "Cmd.Action".
- var actionText = MobileCRM.Localization.get("Cmd.Action");
- MobileCRM.bridge.alert(actionText);
- }
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.
- MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
- function startPointFn(localization) {
- var viewLabel = MobileCRM.Localization.getComponentLabel("account", "View", "Custom View");
- MobileCRM.bridge.alert(viewLabel);
- }
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.
- MobileCRM.Localization.getLoadedLangId(startPointFn, MobileCRM.bridge.alert, null);
- function startPointFn(loadedLangId) {
- // returns the localized loaded language id ("EN" for English);
- var langId = loadedLangId;
- MobileCRM.bridge.alert(loadedLangId);
- }
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.
- MobileCRM.Localization.initialize(startPointFn, MobileCRM.bridge.alert);
- function startPointFn(localization) {
- // returns the localized plural for entity "account" ("Accounts" for English).
- var accountsLabel = MobileCRM.Localization.getPlural("account");
- MobileCRM.bridge.alert(accountsLabel);
- }
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.initializeAsync Function
[v10.0] Initializes the Localization object.
Method loads the string table asynchronously and resolves pending promise with initialized Localization object.
All other functions will return the default or empty string before the initialization finishes.
Arguments
Argument | Type | Description |
---|---|---|
regularExpression | string | Optional regular expression defining a subset of localization keys. Refer to Regular Expression Language - Quick Reference. Set to null to obtain whole localization. |
Return value
Type: Promise<MobileCRM.Localization>
A Promise object which will be resolved with initialized Localization object as argument.
MobileCRM.Localization.initializeEx Function
[v10.0] Initializes the Localization object.
Method loads the string table asynchronously and calls either the errorCallback with error message or the callback with initialized Localization object.
All other functions will return the default or empty string before the initialization finishes.
Arguments
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.
- var competitor = new MobileCRM.Reference("competitor", competitorid);
- var product = new MobileCRM.Reference("product", productid);
- MobileCRM.ManyToManyReference.addRecord("competitorproduct", competitor, product,
- function () { onCreated(); },
- function (err) { showError(err); }
- );
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.
- var competitor = new MobileCRM.Reference("competitor", competitorid);
- var product = new MobileCRM.Reference("product", productid);
- MobileCRM.ManyToManyReference.create("competitorproduct", competitor, product,
- function () { onCreated(); },
- function (err) { showError(err); }
- );
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.
- var competitor = new MobileCRM.Reference("competitor", competitorid);
- var product = new MobileCRM.Reference("product", productid);
- MobileCRM.ManyToManyReference.remove("competitorproduct", competitor, product,
- function () { onRemoved(); },
- function (err) { showError(err); }
- );
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.
- MobileCRM.Metadata.requestObject(
- function (metaData) {
- // Request MetaEntity object by its name.
- MobileCRM.MetaEntity.loadByName(
- "account",
- function (metaEntity) {
- /// <param name="metaEntity" type="MobileCRM.MetaEntity"/>;
- var metaProperties = "MetaEntity properties \n";
- metaProperties += "can account append to contact : " + metaEntity.canAppendTo("contact") + "\n";
- metaProperties += "account C-R-W-D : " + metaEntity.canCreate(); + "-" + metaEntity.canRead(); +
- "-" + metaEntity.canWrite(); + "-" + metaEntity.canDelete();
- MobileCRM.bridge.alert(metaProperties);
- }, MobileCRM.bridge.alert,
- null
- );
- },
- MobileCRM.bridge.alert
- );
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").
- MobileCRM.Metadata.getOptionSetValues(
- "opportunity",
- "statuscode",
- function (optionSetValues) {
- /// <param name="optionSetValues" type="Object"></param>
- var values = "";
- for (var name in optionSetValues) {
- var val = optionSetValues[name];
- values += name + " = " + val + "\n";
- }
- MobileCRM.bridge.alert("Opportunity option set values: \n\n" + values);
- },
- 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.
- MobileCRM.Metadata.requestObject(function (metadata) {
- var metaEntity = MobileCRM.Metadata.getEntity("account");
- var latitudeProp = metaEntity.getProperty("address1_latitude");
- var longitudeProp = metaEntity.getProperty("address1_longitude");
- // contains entity what has child ("invoicedetail","salesorder",...);
- var childrenMap = metadata._childParentMap;
- for (var i in childrenMap) {
- // Parent for children (invoice has invoicedetail;)
- var entityParent = entity.getEntityParent(i);
- }
- }, 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. |
runReportAsync | [v9.1] Executes the mobile reporting request which produces the mobile report document of given format. |
showForm | [v10.1] Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query. |
showFormWithConfiguration | [v16.0] Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query. |
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.
- function fetchReportXML() {
- var report = new MobileCRM.FetchXml.Entity("resco_mobilereport");
- report.addAttribute("resco_data");
- var fetch = new MobileCRM.FetchXml.Fetch(report);
- fetch.execute("Array", function (res) {
- /// <param name='res' type='Array'>Array of results carrying resco_data field value.</param>
- if (res.length > 0) {
- var reportXML = res[0][0];
- runMobileReport(reportXML);
- }
- }, MobileCRM.bridge.alert, null);
- }
- // Alternatively, you can run your own custom mobile report definition.
- // Assumes that 'salesorder' entity have 'totalamount' and 'name' attributes enabled.
- function runMobileReport(reportXML) {
- 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>";
- MobileCRM.Configuration.requestObject(function (config) {
- /// <param name='config' type='MobileCRM.Configuration'/>
- var filePath = config.storageDirectory + "/MyCustomReport.pdf"; // Create file in storage directory.
- MobileCRM.MobileReport.runReport(fetchXML, reportXML, "Pdf", null, false, filePath, function (res) {
- /// in success callback, report form with data and fetch should be displayed.
- }, MobileCRM.bridge.alert);
- }, MobileCRM.bridge.alert, null);
- }
MobileCRM.MobileReport.runReportAsync 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_mobilereport 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. |
Return value
Type: Promise<string>
A Promise object which will be resolved with the file path to successfully created report.
MobileCRM.MobileReport.showForm Function
[v10.1] Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query.
If both types of source are passed, user can select which one to use.
Arguments
Argument | Type | Description |
---|---|---|
report | MobileCRM.Reference | Optional reference to the resco_mobilereport entity that will be pre-selected. |
source | MobileCRM.Reference[] | The list of entity references used as report input. |
fetchXML | String | The fetch XML defining the entity (entities) query used as report input. |
failed | function(errorMsg) | A callback which is called in case of error. |
scope | Object | The scope for callbacks. |
MobileCRM.MobileReport.showFormWithConfiguration Function
[v16.0] Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query.
If both types of source are passed, user can select which one to use.
Arguments
Argument | Type | Description |
---|---|---|
report | MobileCRM.Reference | Optional reference to the resco_mobilereport entity that will be pre-selected. |
source | MobileCRM.Reference[] | The list of entity references used as report input. |
fetchXML | String | The fetch XML defining the entity (entities) query used as report input. |
paramString | String | Run report form Configuration string in JSON format. |
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.OAuthSettings Object
[v12.4] Represents the settings what are used to authenticate using OAuth server account.
Properties
Property | Type | Description |
---|---|---|
authorityEndPoint | String | Gets or sets the OAuth token url. |
authorizationUrl | String | Gets or sets the authorization url to get authorization code. |
clientId | String | Gets or sets the authentication Client Id. |
clientSecret | String | Gets or sets the Authentication Client Secret. |
redirectUrl | String | Gets or sets the authorization redirect url for service. |
resourceUrl | String | Gets or sets the App ID URI of the target web API (secured resource). |
scopes | String | Gets or sets the scope to limit an application's access to a user's account. |
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. |
runCallback | Invokes callback passing this instance of ObservableObject as argument. |
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.runCallback Method
Invokes callback passing this instance of ObservableObject as argument.
Arguments
Argument | Type | Description |
---|---|---|
callback | function | The callback function. |
scope | Object | The scope for callback. |
Return value
Type: Object
An object clone containing all properties changed during the callback call.
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. |
Example 1
This example demonstrate how to set list of values for multi select pick list item on entity form.
- MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- if (detailView) {
- var dv = entityForm.getDetailView("General");
- if (dv) {
- var multiOpt = dv.getItemByName("multi_pick_list_item");
- if (multiOpt) {
- // val must contain a string with a list of numeric values delimited with semi-colon (;)
- multiOpt.setTypedValue("value", "System.String", "100000001;100000000;100000002");
- }
- }
- }
- return true;
- }, MobileCRM.bridge.alert, null);
MobileCRM.Platform Object
Represents object for querying platform specific information and executing platform integrated actions.
This object cannot be created directly. To obtain/modify this object, use MobileCRM.Platform.requestObject function.
Properties
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 |
---|---|
[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. |
getLocationAsync | 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. |
sendEmail | [v15.0] Opens the platform-specific e-mail message form with pre-filled data. |
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.
- MobileCRM.Platform.email(
- "someone@example.com", /// email address
- "Test Subject", /// email subject
- "Hi, This is Resco email.", /// email body
- MobileCRM.bridge.alert
- );
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.
- function sendEmail(filePath) {
- var attachments = []; /// Array attachments to send. Element must be a full path or a reference to a note.
- attachments.push(filePath);
- MobileCRM.Platform.emailWithAttachments(
- "someone@example.com", /// email address
- "Test Subject", /// email subject
- "Hi, This is Resco email.", /// email body
- attachments,
- null, null,
- endTest, null
- );
- }
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.
- // Request device info object
- MobileCRM.Platform.getDeviceInfo(
- function (info) {
- /// <param name="info" type="MobileCRM._DeviceInfo"></param>
- var result = "Device Info : \n";
- for (var prop in info) {
- result += prop + " : " + info[prop].toString(); + "\n";
- }
- MobileCRM.bridge.alert(result);
- },
- MobileCRM.bridge.alert
- );
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, longitude and timestamp . |
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.getLocationAsync Function
Gets current geo-location from platform-specific location service.
If the current platform does not support the location service, returned Promise is rejected with error "Unsupported".
Arguments
Argument | Type | Description |
---|---|---|
age | Number | Max age in seconds to accept GPS. |
precision | Number | Desired accuracy in meters. |
timeout | Number | Timeout in milliseconds (since v10.1). |
Return value
Type: Promise<object>
A Promise object which will be resolved with an object having latitude and longitude properties.
MobileCRM.Platform.getNetworkInfo Function
[v11.2] Gets network information.
Arguments
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.
- var tel = "555-0131";
- MobileCRM.Platform.makeCall(tel, MobileCRM.bridge.alert);
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.
- var documentPath = "c:\\Desktop\\test.txt";
- 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!).
- var documentPath = "c:\\Desktop\\test.txt";
- var notePad = "c:\\windows\\system32\\notepad.exe"
- 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.
- 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.
- // Request MobileCRM.Platform object
- MobileCRM.Platform.requestObject(
- function (platform) {
- /// <param name="platform" type="MobileCRM.Platform"></param>
- var result = "Platform Info : \n";
- for (var prop in platform) {
- result += prop + " : " + platform[prop] + "\n";
- }
- MobileCRM.bridge.alert(result);
- },
- MobileCRM.bridge.alert
- );
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.
- MobileCRM.Platform.scanBarCode(
- function (barcodes) {
- /// <param name="barcode" type="Array">Array of scanned barcode</param>
- barcode = "";
- for (var i in barcodes)
- barcode += "\n barcode " + i + " : " + barcodes[i];
- MobileCRM.bridge.alert(barcode);
- },
- MobileCRM.bridge.alert
- );
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.sendEmail Function
[v15.0] 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. |
mimeType | String | Body content MIME type. |
errorCallback | function(errorMsg) | The errorCallback which is called asynchronously in case of error. |
scope | Object | The scope for errorCallback. |
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. |
Example 1
This example demonstrates how to open sms application with predefined telephone number and message text.
- MobileCRM.Platform.sendSMS("123-456-789", "This sms was sent using RESCO MobileCRM JSBridge api.",
- function (err) {
- MobileCRM.bridge.alert("Send SMS failed.\nErr: " + err);
- }
- );
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. |
relationship | MobileCRM.Relationship | Optional relationship with the parent record. |
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 |
---|---|
loadAsync | Asynchronously loads the CRM reference. |
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.loadAsync Function
Asynchronously loads the CRM reference.
Arguments
Argument | Type | Description |
---|---|---|
entityName | String | An entity name |
id | String | The reference ID. |
Return value
Type: Promise<MobileCRM.Reference>
A Promise object which will be resolved with an instance of Reference object representing entity record reference.
MobileCRM.Reference.loadById Function
Asynchronously loads the CRM reference.
Arguments
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. |
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 | [BLOCKED] 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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttribute("accountid");
- entity.addAttribute("name");
- 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.addLink Method
Adds an entity link (join) to the fetch query.
Arguments
Argument | Type | Description |
---|---|---|
target | String | The target entity. |
from | String | The "from" field (if parent then target entity primary key). |
to | String | The "to" field. |
linkType | String | The link (join) type ("inner" or "outer"). |
Return value
Type: MobileCRM.FetchXml.LinkEntity
The newly created MobileCRM.FetchXml.LinkEntity object.
Example 1
Following example creates the fetch entity for account with linked primary contact.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var linkEntity = entity.addLink("contact", "parentcustomerid", "accountid", "outer");
- linkEntity.addAttribute("fullname");
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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- entity.orderBy("name", false);
MobileCRM.FetchXml.Entity.removeLink Method
Removes an entity link from the fetch query.
Arguments
Argument | Type | Description |
---|---|---|
link | MobileCRM.FetchXml.LinkEntity | The MobileCRM.FetchXml.LinkEntity object to remove. |
Return value
Type: Array
The list of remaining LinkEntity objects or null if the link does not exists.
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. |
distinct | Boolean | Whether to return only distinct (different) values. |
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. |
serializeToXmlAsync | [v10.0] Serializes the Fetch object to XML. |
Functions
Function | Description |
---|---|
deserializeFromXml | Deserializes the Fetch object from XML. |
deserializeFromXmlAsync | 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. |
distinct | bool | Whether to return only distinct (different) values. |
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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttribute("accountid");
- entity.addAttribute("name");
- var fetch = new MobileCRM.FetchXml.Fetch(entity);
- fetch.execute(
- "Array", // Take the results as an array of arrays with field values
- function (result) {
- // "result" is
- // [["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"],
- // ["All Cycles","0FDBF212-4F72-4019-A9B6-59F0695EB646"],...];
- for (var i in result) {
- // "account" is ["A Bike Store","52A239BD-E8F9-425C-B3A4-FD685D659215"]
- var account = result[i];
- // Pass accountid and name for processing
- processAccount(account[0], account[1]);
- }
- },
- function (err) {
- MobileCRM.bridge.alert("Error fetching accounts: " + err);
- },
- null
- );
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 will be resolved with array of objects having type specified by output argument.
Example 1
This example demonstrates how to fetch a list of accounts and process their names.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttribute("accountid");
- entity.addAttribute("name");
- var fetch = new MobileCRM.FetchXml.Fetch(entity);
- fetch.executeAsync(null) // "null" stands for default "DynamicEntities" result format
- .then(function (result) {
- // Promise was fulfilled and we obtained an array of DynamicEntities
- for (var i in result) {
- var account = result[i];
- // Pass account id and name for further processing
- processAccount(account.id, account.primaryName);
- }
- })
- .catch(function (err) {
- // Promise was rejected with error
- MobileCRM.bridge.alert("Error fetching accounts: " + err);
- });
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.serializeToXmlAsync Method
[v10.0] Serializes the Fetch object to XML.
Return value
Type: Promise<string>
A Promise object which will be resolved with the XML representation of this Fetch object.
MobileCRM.FetchXml.Fetch.deserializeFromXml Function
Deserializes the Fetch object from XML.
Arguments
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.
- var xml =
- '<fetch>\
- <entity name="account">\
- <attribute name="accountid" />\
- <attribute name="name" />\
- <order attribute="name" descending="false" />\
- <filter type="and">\
- <condition attribute="statecode" operator="eq" value="0" />\
- </filter>\
- </entity>\
- </fetch>';
- MobileCRM.FetchXml.Fetch.deserializeFromXml(xml, function (fetch) {
- /// <param name="fetch" type="MobileCRM.FetchXml.Fetch" />
- fetch.entity.filter.startsWith("name", "B"); // Modify deserialized fetch...
- fetch.execute("DynamicEntities", function (res) { // ... and execute it
- var report = res.join("\r\n");
- MobileCRM.bridge.alert(report);
- }, MobileCRM.bridge.alert);
- }, MobileCRM.bridge.alert);
MobileCRM.FetchXml.Fetch.deserializeFromXmlAsync Function
Deserializes the Fetch object from XML.
Arguments
Argument | Type | Description |
---|---|---|
xml | String | A string defining the fetch XML request. |
Return value
Type: Promise<MobileCRM.FetchXml.Fetch>
A Promise object which will be resolved with the Fetch object.
MobileCRM.FetchXml.Fetch.executeFromXML Function
Performs the asynchronous CRM Fetch command.
Arguments
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.
- var xmlData = '<fetch resultformat="Array"><entity name="account"><attribute name="accountid"/>' +
- '<attribute name="name"/></entity></fetch>';
- MobileCRM.FetchXml.Fetch.executeFromXML(
- xmlData,
- function (result) {
- for (var i in result) {
- var props = result[i];
- processAccount(props[0], props[1]);
- }
- },
- function (err) {
- MobileCRM.bridge.alert("Error fetching accounts: " + err);
- },
- null
- );
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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var filter = new MobileCRM.FetchXml.Filter();
- filter.between("modifiedon", new Date(2013, 5, 1), new Date(2013, 6, 1));
- 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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var filter = new MobileCRM.FetchXml.Filter();
- filter.contains("telephone1", "555");
- 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.
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var filter = new MobileCRM.FetchXml.Filter();
- filter.isIn("address1_city", ["Boston", "Redmond"]);
- 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".
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var filter = new MobileCRM.FetchXml.Filter();
- filter.startsWith("name", "a");
- 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".
- var entity = new MobileCRM.FetchXml.Entity("account");
- entity.addAttributes();
- var filter = new MobileCRM.FetchXml.Filter();
- filter.where("name", "like", "a%");
- 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 |
---|---|
ChartDataSource | The data source loading routine implementation. |
EntityChart | [13.0] Represents the Javascript equivalent of native entity chart object. |
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. |
RoutePlan | [v14.2] Represents the Javascript equivalent view of RoutePlan 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. |
_DocumentController | Represents Media tab controller containing specific kind of document. |
_DocumentInfo | Represents information about attached document. |
_DocumentView | Represents the document view object containing the attachment document (binary field content). |
_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.ChartDataSource Object
The data source loading routine implementation.
An instance of this object can be used to supply the data source for MobileCRM.UI.EntityChart.setDataSource function.
Properties
Property | Type | Description |
---|---|---|
type | string | Chart type in string |
data | object | Object of chart dataset |
MobileCRM.UI.EntityChart Object
[13.0] Represents the Javascript equivalent of native entity chart object.
Functions
Function | Description |
---|---|
setDataSource | Sets the chart data source replacement. |
MobileCRM.UI.EntityChart.setDataSource Function
Sets the chart 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.ChartDataSource | A data source object implementing the EntityChart loading routine. |
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. |
bulkUpdateItems | Array | A list of entity records editted on this bulk update form. |
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. |
isBulkUpdateForm | Boolean | Indicates whether the form is bulk update form. |
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. |
documentView | MobileCRM.UI._DocumentView | NoteForm only. Gets the view containing the note attachment. |
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. |
getEntityList | Returns the entity list by its view 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. |
onProcessLoaded | Binds or unbinds the handler for onProcessLoaded 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.
- MobileCRM.UI.EntityForm.onSave(
- function (entityForm) {
- var addressDetail = entityForm.getDetailView("Address");
- var addrItem = addressDetail.getItemByName("address1_line1");
- if (!addrItem.value) {
- // use cancelValidation method and set the error message to be displayed
- // or pass "null" to cancel the validation without any message.
- entityForm.cancelValidation("Street 1 line is empty.");
- // Return false to ignore all changes
- return false;
- }
- },
- true,
- null
- );
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.
- function getController() {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var iframeController = entityForm.getController("iFrame");
- },
- MobileCRM.bridge.alert
- );
- }
Example 2
This example demonstrates how to force crop ratio and maximum image width after new image is set (captured/selected/pasted/...) into media tab.
- ImageViewMode = {
- /// <summary>Size/crop values are taken just like suggestion (e.g. for CaptureImage action).</summary>
- NoEnforcement: 0,
- /// <summary>Image is automatically cropped to DesiredRatio as it arrives.</summary>
- AutoCrop: 1,
- /// <summary>Image is automatically resized as it arrives.</summary>
- AutoResize: 2,
- /// <summary>Image editor is opened to resolve crop/resize actions.</summary>
- OpenEditor: 0x8000,
- }
- MobileCRM.UI.EntityForm.requestObject(function (f) {
- /// <param name="f" type="MobileCRM.UI.EntityForm"/>
- var documentView;
- if (f.entity.entityName == "annotation")
- documentView = f.documentView; // NoteForm has "documentView" property
- else {
- // Other forms have media tab included in controllers array:
- var documentController = f.getController("ContactImage");
- documentView = documentController.view; // _DocumentController has view of type _DocumentView
- }
- // Further filtering can be done using relationship
- // E.g. Note form opened from contact can be detected this way:
- //if (f.relationship.target.entityName == "contact") {...}
- // Finally, set desired image props:
- documentView.maxImageWidth = 640; // limit image width to 640px
- documentView.maxImageHeight = 0; // Allow any height
- documentView.desiredRatio = 4 / 3; // Force image ratio 4:3
- // Force automatic crop and resize after new image is captured/selected:
- documentView.enforcementMode = ImageViewMode.AutoCrop | ImageViewMode.AutoResize;
- // AutoCrop takes the center part of image and AutoResize will force image width at most 640px.
- // Choose "ImageViewMode.OpenEditor" to let user to choose crop rectangle in image editor:
- // documentView.enforcementMode = ImageViewMode.OpenEditor;
- });
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.
- function getController() {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var generalView = entityForm.getDetailView("General");
- },
- MobileCRM.bridge.alert
- );
- }
MobileCRM.UI.EntityForm.getEntityList Method
Returns the entity list by its view name.
Arguments
Argument | Type | Description |
---|---|---|
name | String | A name of entity list view. |
Return value
Type: MobileCRM.UI._EntityList
A MobileCRM.UI._EntityList object with requested view name.
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- // bind media tab operations handlers to button onclick event.
- document.getElementById("capturePhoto").onclick = function () {
- media.capturePhoto();
- }
- document.getElementById("selectPhoto").onclick = function () {
- media.selectPhoto();
- }
- document.getElementById("selectFile").onclick = function () {
- media.selectFile();
- }
- document.getElementById("recordAudio").onclick = function () {
- media.recordAudio();
- }
- document.getElementById("recordVideo").onclick = function () {
- media.recordVideo();
- }
- },
- MobileCRM.bridge.alert
- );
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.
- MobileCRM.UI.EntityForm.requestObject(function(entityForm){
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- if (entityForm.entity.properties.statecode == 1) // check whether entity is inactive
- entityForm.reactivateEntity(new Number(1)); // contact status code.
- }, 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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- entityForm.selectTab(
- // The name of the associated contacts tab consists of the entity logical name,
- // the lookup field name and the source entity name.
- "contact.parentcustomerid.account",
- MobileCRM.bridge.alert
- );
- },
- MobileCRM.bridge.alert,
- null
- );
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
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- entityForm.selectView("contact.parentcustomerid.account", "View name");
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // The name of the tab, and true to show or false to hide
- entityForm.setTabVisibility("General", true);
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.onSave(onSaveValidation, true, null);
- function onSaveValidation(entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- var editedAccount = entityForm.entity;
- var saveHandler = entityForm.suspendSave();
- var fetchEntity = new MobileCRM.FetchXml.Entity("contact");
- fetchEntity.addAttribute("contactid");
- var filter = new MobileCRM.FetchXml.Filter();
- filter.where("parentcustomerid", "eq", editedAccount.id);
- fetchEntity.filter = filter;
- var fetch = new MobileCRM.FetchXml.Fetch(fetchEntity);
- fetch.execute(
- null, // Take the results as an array of arrays with field values
- function (result) {
- /// <param name="result" type="Array"/>
- if (result && result.length)
- saveHandler.resumeSave();
- else
- saveHandler.resumeSave("At least one contact is required");
- },
- function (error) {
- saveHandler.resumeSave("Contact fetch error: " + error);
- }
- );
- }
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.
- MobileCRM.Platform.getLocation(
- function (res) {
- if (res.latitude && res.longitude) {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- entityForm.updateAddressFields(res.latitude, res.longitude);
- },
- MobileCRM.bridge.alert
- );
- }
- },
- MobileCRM.bridge.alert
- );
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.
- 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.
- 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.
- function onQualifyLead() {
- MobileCRM.UI.EntityForm.executeCommandByName(
- "Qualify",
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- },
- MobileCRM.bridge.alert
- );
- }
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.
- var viewName = "MyView";
- MobileCRM.UI.EntityForm.isViewMaximized(
- viewName,
- function (isMaximized) {
- if (!isMaximized)
- MobileCRM.UI.EntityForm.maximizeView(viewName, true);
- },
- MobileCRM.bridge.alert
- );
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.
- MobileCRM.UI.EntityForm.onCanExecuteCommand("custom_Scanner", function (entityForm) {
- var entity = entityForm.entity;
- return !entity.properties["productnumber"];
- }, 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".
- MobileCRM.UI.EntityForm.onCanExecuteCommand(
- "ChangeStatus/5", // The value "5" is the status code for "Disqualified - Cannot Contact" status on Lead entity
- function (entityForm) {
- return false;
- },
- true
- );
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
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- // First check whether the change handler is called due to desired item change
- var changedItem = entityForm.context.changedItem;
- if (changedItem == "firstname" || changedItem == "lastname") {
- // Get desired DetailView and its items
- var detailView = entityForm.getDetailView("General");
- var firstNameItem = detailView.getItemByName("firstname");
- var lastNameItem = detailView.getItemByName("lastname");
- // Now get edited entity and set its property to the combination of detail items values
- var editedEntity = entityForm.entity;
- editedEntity.properties.fullname = firstNameItem.value + " " + lastNameItem.value;
- }
- },
- true,
- null
- );
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.
- MobileCRM.UI.EntityForm.onCommand(
- "custom_Scanner",
- function (entityForm) {
- var entity = entityForm.entity;
- MobileCRM.Platform.scanBarCode(
- function (res) {
- if (!res || res.length <= 0) {
- sayError("No barcode");
- }
- else {
- storeBarCode(res[0]);
- }
- },
- function (err) { sayError(err); }
- );
- },
- true
- );
- function storeBarCode(code) {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- entityForm.entity.properties["productnumber"] = code;
- },
- function (err) { sayError(err); }
- );
- }
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.
- MobileCRM.UI.EntityForm.onPostSave(
- function (entityForm) {
- /// register event.
- var entity = entityForm.entity;
- var account = new MobileCRM.Reference(entity.entityName, entity.id, entity.primaryName);
- var postSuspend = entityForm.suspendPostSave();
- /// create associated contact.
- var contact = new MobileCRM.DynamicEntity.createNew("contact");
- contact.properties.lastname = "_child of " + account.primaryName;
- contact.properties.parentcustomerid = account;
- contact.save(
- function (err) {
- if (err)
- MobileCRM.bridge.alert(err);
- else {
- postSuspend.resumePostSave();
- }
- }
- );
- },
- true,
- MobileCRM.bridge.alert
- );
MobileCRM.UI.EntityForm.onProcessLoaded Function
Binds or unbinds the handler for onProcessLoaded 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. |
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.
- MobileCRM.UI.EntityForm.onSave(
- function (entityForm) {
- var addressDetail = entityForm.getDetailView("Address");
- var addrItem = addressDetail.getItemByName("address1_line1");
- if (!addrItem.value || addrItem.value.length == 0) {
- // Set the error message on detail item
- addrItem.errorMessage = "Street 1 line is empty.";
- // select second tab (zero-based)
- entityForm.form.selectedViewIndex = 1;
- entityForm.context.errorMessage = addrItem.errorMessage;
- // Return true to apply changed values
- return true;
- }
- // Return false to ignore all changes
- return false;
- },
- true,
- null
- );
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.
- MobileCRM.UI.EntityForm.onSelectedViewChanged(function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- if (entityForm.context.selectedView == "Address") {
- var entity = entityForm.entity;
- var dv = entityForm.getDetailView("Address");
- var bEnable = !entity.properties.parentcustomerid;
- dv.getItemByName("address1_line1").isEnabled = bEnable;
- dv.getItemByName("address1_city").isEnabled = bEnable;
- }
- }, 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).
- function getDetails() {
- MobileCRM.UI.EntityForm.DetailCollection.getAll(function (details) {
- /// <param name='details' type='Array'/>
- var len = details.length;
- if (len <= 0)
- return;
- // Open the form for the first sales entity detail (e.g. the first OrderDetail)
- openDetail(details[0]);
- }, MobileCRM.bridge.alert, null);
- }
- function openDetail(detail) {
- /// <param name='detail' type='MobileCRM.DynamicEntity'/>
- /// open sales order detail
- var order = detail.properties.salesorderid;
- var relationShip = new MobileCRM.Relationship("salesorderid", order, null, null);
- MobileCRM.UI.EntityForm.openSalesEntityDetail(detail, relationShip);
- }
MobileCRM.UI.EntityForm.refreshForm Function
Reloads the form's edit state.
Example 1
This example demonstrates how to reload form's edit state.
- 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
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- // Get the MobileCRM.DynamicEntity which is being edited on this form
- var entity = entityForm.entity;
- // Get the form control object
- var form = entityForm.form;
- // Set the form caption to the primary name of currently edited entity
- form.caption = entity.primaryName;
- // Return true to apply changed value.
- return true;
- },
- function (err) {
- MobileCRM.bridge.alert("An error occurred: " + err);
- },
- null
- );
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
- function saveAndCloseForm() {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- if (entityForm)
- MobileCRM.UI.EntityForm.saveAndClose();
- },
- function (err) {
- MobileCRM.bridge.alert("An error occurred: " + err);
- },
- null
- );
- }
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.
- 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.
- /// Try to get the device's geo coordinates and show please wait window while the operation is in progress.
- function getGPSCoords() {
- var wait = MobileCRM.UI.EntityForm.showPleaseWait("Getting the GPS coordinates...");
- MobileCRM.Platform.getLocation(
- function (coords) {
- wait.close();
- if (coords.latitude && coords.longitude)
- MobileCRM.bridge.alert("latitude : " + coords.latitude + " longitude : " + coords.longitude);
- },
- function (err) {
- wait.close();
- MobileCRM.bridge.alert(err);
- }
- );
- }
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. |
addAsync | [v10.0] 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) |
getAllAsync | Asynchronously returns the collection of the sales entity details (e.g. Order details) |
getAsync | Asynchronously returns requested sales entity detail (e.g. Order detail) |
onChange | [v8.2] Binds or unbinds the handler which is called when the list of sales details changes. |
MobileCRM.UI.EntityForm.DetailCollection.add Function
Appends the product into sales order collection.
Resulting MobileCRM.DynamicEntity object implements method "update" which can be used to update the entity properties in the sales detail collection.
Arguments
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.
- function addNewProduct(productId, quantity) {
- var productRef = new MobileCRM.Reference("product", productId);
- MobileCRM.UI.EntityForm.DetailCollection.add(
- productRef,
- function (orderDetail) {
- /// <param name="orderDetail" type="MobileCRM.DynamicEntity"/>
- orderDetail.properties["quantity"] = quantity;
- orderDetail.update(
- function (err) {
- if (err)
- MobileCRM.bridge.alert(err);
- else
- MobileCRM.bridge.alert("Product added");
- });
- },
- MobileCRM.bridge.alert
- );
- }
MobileCRM.UI.EntityForm.DetailCollection.addAsync Function
[v10.0] Appends the product into sales order collection.
Resulting MobileCRM.DynamicEntity object implements method "update" which can be used to update the entity properties in the sales detail collection.
Arguments
Argument | Type | Description |
---|---|---|
product | MobileCRM.Reference | A reference of the product to be appended. |
quantity | Number | Product quantity. |
Return value
Type: Promise<MobileCRM.DynamicEntity>
A Promise object which will be resolved with the DynamicEntity object representing new sales entity detail record.
Example 1
This example demonstrates how to add a new product with given quantity into order details.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function addNewProduct(productId, quantity) {
- try {
- var productRef = new MobileCRM.Reference("product", productId);
- var orderDetail = await MobileCRM.UI.EntityForm.DetailCollection.addAsync(productRef, quantity);
- MobileCRM.bridge.alert("Product added");
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
- }
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.
- function addNewProduct() {
- var product = new MobileCRM.FetchXml.Entity("product");
- product.addAttributes();
- var fetch = new MobileCRM.FetchXml.Fetch(product, 1); // only one product will be fetched.
- fetch.execute("DynamicEntities", function (res) {
- var productReference = new MobileCRM.Reference(res[0].entityName, res[0].id, res[0].primaryName);
- // add product to detail collection.
- MobileCRM.UI.EntityForm.DetailCollection.addProductWithQuantity(
- productReference,
- 2,
- function (orderDetail) {
- /// <param name="orderDetail" type="MobileCRM.DynamicEntity"/>
- // in success callback of function.
- // order detail will be updated automatically.
- // display info about current order detail
- MobileCRM.bridge.alert(JSON.stringify(orderDetail));
- },
- MobileCRM.bridge.alert // Alert an error (if any)
- );
- }, MobileCRM.bridge.alert, null);
- }
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.
- function deleteProduct() {
- // retrieve first product if exist from order detail
- MobileCRM.UI.EntityForm.DetailCollection.getAll(
- function (details) {
- /// <param name="details" type="Array<MobileCRM.DynamicEntity>"/>
- if (details.length) {
- var product = details[0];
- MobileCRM.UI.EntityForm.DetailCollection.deleteById(
- product.id,
- function () {
- MobileCRM.bridge.alert("Product " + product.properties.productdescription + " successfully deleted.");
- },
- MobileCRM.bridge.alert
- );
- }
- else
- MobileCRM.bridge.alert("Order doesn't contain any product.");
- },
- MobileCRM.bridge.alert
- );
- }
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.
- function deleteByIndex(index) {
- MobileCRM.UI.EntityForm.DetailCollection.getAll(
- function (details) {
- /// <param name="details" type="Array<MobileCRM.DynamicEntity>"/>
- if (details[index]) {
- var product = details[index];
- MobileCRM.UI.EntityForm.DetailCollection.deleteByIndex(
- index,
- function () {
- MobileCRM.bridge.alert("Product " + product.properties.productdescription + " successfully deleted.");
- },
- MobileCRM.bridge.alert
- );
- }
- else
- MobileCRM.bridge.alert("Order doesn't contain any product.");
- },
- MobileCRM.bridge.alert
- );
- }
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.
- function increaseQuantity(orderDetailIndex, increment) {
- MobileCRM.UI.EntityForm.DetailCollection.get(
- orderDetailIndex,
- function (detail) {
- /// <param name="detail" type="MobileCRM.DynamicEntity"/>
- // work with numbers, not strings!
- detail.properties["quantity"] = new Number(detail.properties["quantity"]) + new Number(increment);
- // Update the SalesOrderDetail entity in order details collection
- detail.update();
- },
- MobileCRM.bridge.alert
- );
- }
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.
- MobileCRM.UI.EntityForm.DetailCollection.getAll(function (orderDetails) {
- /// <param name="orderDetails" type="Array"/>
- var nDetails = orderDetails.length;
- var text = "";
- for (var i = 0; i < nDetails; i++) {
- var detail = orderDetails[i];
- var productName = detail.properties["productid"].primaryName;
- var quantity = detail.properties["quantity"];
- text += "Product: " + productName + " Quantity: " + quantity + " \n";
- }
- if (text.length > 0)
- MobileCRM.bridge.alert(text);
- }, MobileCRM.bridge.alert, null);
MobileCRM.UI.EntityForm.DetailCollection.getAllAsync Function
Asynchronously returns the collection of the sales entity details (e.g. Order details)
Return value
Type: Promise<MobileCRM.DynamicEntity[]>
A Promise object which will be resolved with an array of DynamicEntity objects representing the sales entity detail records.
Example 1
This example demonstrates how to get the list of order details.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- try {
- var orderDetails = await MobileCRM.UI.EntityForm.DetailCollection.getAllAsync();
- var text = orderDetails.map(function(detail){
- return "Product: " + detail.properties["productid"].primaryName +
- ", Quantity: " + detail.properties["quantity"];
- }).join("\n");
- if (text.length > 0)
- MobileCRM.bridge.alert(text);
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
MobileCRM.UI.EntityForm.DetailCollection.getAsync Function
Asynchronously returns requested sales entity detail (e.g. Order detail)
Arguments
Argument | Type | Description |
---|---|---|
index | Number | An index of requested item. |
Return value
Type: Promise<MobileCRM.DynamicEntity>
A Promise object which will be resolved with the DynamicEntity object representing the sales entity detail record.
Example 1
This example demonstrates how to update the order detail quantity.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function increaseQuantity(orderDetailIndex, increment) {
- try {
- var detail = await MobileCRM.UI.EntityForm.DetailCollection.getAsync(orderDetailIndex);
- detail.properties["quantity"] =(+detail.properties["quantity"]) + increment; // work with numbers, not strings!
- // Update the SalesOrderDetail entity in order details collection
- detail.update();
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
- }
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.
- MobileCRM.UI.EntityForm.DetailCollection.onChange(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- /// retrieve last added product new index from context
- var changedProductIndex = entityForm.context.newIndex;
- if (changedProductIndex >= 0) {
- MobileCRM.UI.EntityForm.DetailCollection.get(
- changedProductIndex,
- function (detail) {
- /// open actually changed product.
- MobileCRM.UI.EntityForm.openSalesEntityDetail(detail, MobileCRM.bridge.alert, null);
- },
- MobileCRM.bridge.alert
- );
- }
- }, 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.
- MobileCRM.UI.EntityList.onChange(function (entityList) {
- /// <param name='entityList' type='MobileCRM.UI.EntityList'/>
- var context = entityList.context;
- if (context.propertyName == "address1_line1") {
- var editedEntities = entityList.context.entities;
- var props = editedEntities[0].properties;
- if (!props.address1_city)
- props.address1_city = "Boston";
- }
- }, 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.
- MobileCRM.UI.EntityList.onClick(function (entityList) {
- /// <param name="entityList" type="MobileCRM.UI.EntityList" />
- var context = entityList.context;
- var eventInfo = JSON.stringify(context.event);
- var entity = context.entities.toString();
- var property = context.propertyName;
- MobileCRM.bridge.alert("Entity: " + entity + " property: " + property + " was clicked.\nEvent info: " + eventInfo);
- }, 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.
- MobileCRM.UI.EntityList.onCommand("custom_OpenAccount", function (entityList) {
- /// <param name='entityList' type='MobileCRM.UI.EntityList'>
- var selectedEntities = entityList.context.entities;
- if (selectedEntities.length === 1) {
- var customer = selectedEntities[0];
- MobileCRM.UI.FormManager.showDetailDialog(customer.entityName, customer.id);
- }
- }, 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.
- MobileCRM.UI.EntityList.onSave(function (entityList) {
- /// <param name='entityList' type='MobileCRM.UI.EntityList'/>
- var editedEntities = entityList.context.entities;
- var saveHandler = entityList.suspendSave();
- for (var i in editedEntities) {
- var entity = editedEntities[i];
- if (entity.properties.fax.length < 3) {
- saveHandler.resumeSave("record : " + entity.primaryName + " has short fax");
- return;
- }
- }
- saveHandler.resumeSave();
- }, 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.
- 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.
- MobileCRM.UI.EntityList.requestEditedEntities(function (editedEntities) {
- /// <param name='editedEntities' type='Array'>Array of edited DynamicEntities.<param/>
- var editedEntitiesRecord = [];
- for (var i in editedEntities) {
- editedEntitiesRecord.push(editedEntities[i]);
- }
- MobileCRM.bridge.alert("Edited entities : " + editedEntitiesRecord.toString());
- }, 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.
- MobileCRM.UI.EntityList.requestObject(function (entityList) {
- /// <param name='entityList' type='MobileCRM.UI.EntityList'>
- var listView = entityList.listView;
- // Select the first record.
- listView.selectedIndex = 0;
- // Take the first button (if any).
- var button = entityList.listButtons[0];
- if (button){
- MobileCRM.bridge.alert("button '" + button + "' was clicked.")
- MobileCRM.UI.EntityList.runCommand(button); // Run its command.
- }
- }, 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.
- MobileCRM.UI.EntityList.requestObject(function (entityList) {
- /// <param name='entityList' type='MobileCRM.UI.EntityList'>
- var entityName = entityList.entityName;
- var currentView = entityList.currentView;
- // load another views for entity
- MobileCRM.UI.ViewDefinition.loadEntityViews(
- entityName,
- function (views) {
- /// <param name="views" type="Array"/>
- if (views != undefined && views.length > 0) {
- for (var i in views) {
- var viewName = views[i].name;
- if (viewName !== currentView) {
- MobileCRM.UI.EntityList.selectView(viewName);
- return;
- }
- }
- }
- },
- MobileCRM.bridge.alert,
- null
- );
- }, 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.
- var dataSource = new MobileCRM.UI.ListDataSource();
- // loadNextChunk method must be implemented explicitly
- dataSource.loadNextChunk = function (page, count) {
- var fetch = this.fetch; // Take a fetch provided for current entity view
- // Specify explicit page and count requested by application (optional - it's pre-set before this method is called).
- fetch.count = count;
- fetch.page = page;
- if (page == 1) {
- // Specify custom filter or link entities.
- // Do it just for the first page!
- // WARNING: Do not add new attributes to the fetch - they will be ignored.
- var filter = new MobileCRM.FetchXml.Filter();
- filter.where("parentcustomerid", "not-null");
- var originalFilter = fetch.entity.filter;
- if (originalFilter && originalFilter.conditions.length > 0) {
- // Combine new filter with original filter which came from the view definition.
- var combinedFilter = new MobileCRM.FetchXml.Filter();
- combinedFilter.type = "and";
- combinedFilter.filters = [filter, originalFilter];
- fetch.entity.filter = combinedFilter;
- }
- else
- fetch.entity.filter = filter; // Set the new filter to fetch entity
- }
- // Execute fetch asynchronously and force the output type DynamicEntities.
- // When the array of DynamicEntity objects is ready, call chunkReady (don't forget to call it in scope of this ListDataSource).
- fetch.execute("DynamicEntities", function (entities) {
- // This is the final place to manipulate with the array of loaded entities before it is passed to the EntityList.
- this.chunkReady(entities); // Callback is called in scope of our dataSource, so we can call it's method chunkReady to pass the data.
- }, MobileCRM.bridge.alert, this);
- };
- 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.
- MobileCRM.UI.Form.requestObject(
- function (form) {
- /// <param name='form' type='MobileCRM.UI.Form'/>
- form.caption = "Custom caption";
- if (form.canMaximize)
- form.isMaximized = true;
- },
- MobileCRM.bridge.alert
- );
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). |
Example 1
This example demonstrate how to display toast window with text and home icon, which is dismissed after few seconds.
- MobileCRM.UI.Form.showToast("MCRM say hello", "Home.Now.png");
MobileCRM.UI.FormManager Object
A static object with functions allowing to open the entity forms.
Functions
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.
- function openAccountDetail() {
- var account = new MobileCRM.FetchXml.Entity("account");
- account.addAttribute("accountid");
- // only one record will be fetched
- var fetch = new MobileCRM.FetchXml.Fetch(account, 1);
- fetch.execute(
- "Array", // Take the results as an array of arrays with field values
- function (res) {
- MobileCRM.UI.FormManager.showDetailDialog("account", res[0][0], null);
- },
- MobileCRM.bridge.alert
- );
- }
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.
- function openAccountEditDetail() {
- var account = new MobileCRM.FetchXml.Entity("account");
- account.addAttribute("accountid");
- // only active record can have edit form
- account.filter = new MobileCRM.FetchXml.Filter();
- account.filter.where("statecode", "eq", "0");
- // only one record will be fetched
- var fetch = new MobileCRM.FetchXml.Fetch(account, 1);
- fetch.execute(
- "Array", // Take the results as an array of arrays with field values
- function (res) {
- MobileCRM.UI.FormManager.showEditDialog("account", res[0][0], null);
- },
- MobileCRM.bridge.alert
- );
- }
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.
- function addAssociatedContact() {
- // Request entity form (currently edited Account form).
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- var editedAcount = entityForm.entity;
- var target = new MobileCRM.Reference(editedAcount.entityName, editedAcount.id);
- var relationShip = new MobileCRM.Relationship("parentcustomerid", target, null, null);
- MobileCRM.UI.FormManager.showNewDialog(
- "contact",
- relationShip, {
- "@initialize": { // force the form to pre-fill certain fields
- telephone1: editedAcount.properties.telephone1, // new contact will have the same phone as account
- address1_line1: editedAcount.properties.address1_line1, // ... and address too
- address1_city: editedAcount.properties.address1_city
- },
- // These props will be passed to all iFrames on the contact form which is being opened
- iFrameOptions: {
- doNotRequirePhone: true
- }
- }
- );
- },
- MobileCRM.bridge.alert
- );
- }
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"), custom name as defined in Woodford or one of following special 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.
- 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.
- 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.
- MobileCRM.UI.HomeForm.onSyncFinished(
- function (homeForm) {
- /// <param name="homeForm" type="MobileCRM.UI.HomeForm"/>
- if (homeForm.lastSyncResult.newCustomizationReady && !homeForm.lastSyncResult.customizationDownloaded) {
- MobileCRM.bridge.alert("Application update is available");
- }
- },
- null
- );
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.
- var items = ['#Main Group', '#Subgroup', '@@My html;file://myIFrame.html'];
- 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.
- 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.
- function changeTitle(newTitle) {
- MobileCRM.UI.HomeForm.requestObject(
- function (homeForm) {
- /// <param name="homeForm" type="MobileCRM.UI.HomeForm"/>
- homeForm.form.caption = "My Changed Caption";
- return true;
- },
- MobileCRM.bridge.alert
- );
- }
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.
- var items = ['#Main Group', '#Subgroup', '@@My html;file://myIFrame.html'];
- 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
- MobileCRM.UI.HomeForm.updateHomeItems([{
- path: "@Dashboard",
- title: "Sales Summary",
- subTitle: "Monthly statistics"
- }, {
- path: "contact",
- isVisible: false
- }, {
- path: "opportunity",
- isVisible: true
- }
- ]);
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.
- function requestiFrame() {
- MobileCRM.UI.IFrameForm.requestObject(function (iFrame) {
- /// <param name='iFrame' type='MobileCRM.UI.IFrameForm'/>
- var p = document.createElement("p");
- p.innerText = "IFrameForm form properties = "
- for (var prop in iFrame.form) {
- p.innerText += prop + " : " + iFrame.form[prop];
- }
- document.appendChild(p);
- }, MobileCRM.bridge.alert, null);
- }
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.
- function show() {
- MobileCRM.UI.IFrameForm.requestObject(function (iFrame) {
- /// <param name='iFrame' type='MobileCRM.UI.IFrameForm'/>
- MobileCRM.UI.IFrameForm.show("TestIframe", "http://www.google.com/", false, options = { text: "Some Text as option." });
- }, MobileCRM.bridge.alert, null);
- }
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.
- function showModal() {
- MobileCRM.UI.IFrameForm.showModal("TestIframe", "http://www.google.com/", options = { text: "Some Text as option." });
- }
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. |
showAsync | 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.
- 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.
- function chooseParentCustomer() {
- var lookupForm = new MobileCRM.UI.LookupForm();
- // HOW TO ADD ADDITIONAL FILTERING TO LOOKUP FORM.
- var customXMLView = '<fetch version="1.0"><entity name="account">' +
- '<filter type="and"><condition attribute="address1_city" operator="like" value="Bratislava"/></filter></entity></fetch>';
- lookupForm.addEntityFilter("account", customXMLView)
- lookupForm.addView("account", "Default");
- lookupForm.allowNull = true; // Allow choosing empty value
- lookupForm.show(onLookupFinished, MobileCRM.bridge.alert, null);
- }
- function onLookupFinished(accountRef) {
- /// <param name="accountRef" type="MobileCRM.Reference"/>
- // Change the parent customer on currently edited contact entity
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- var editedContact = entityForm.entity;
- var newCustomer = accountRef ? new MobileCRM.Reference(accountRef.entityName, accountRef.id, accountRef.primaryName) : null;
- editedContact.properties["parentcustomerid"] = newCustomer;
- },
- MobileCRM.bridge.alert
- );
- }
MobileCRM.UI.LookupForm.showAsync Method
Shows a dialog which allows the user to select an entity from a configurable list of entity types.
Return value
Type: Promise<MobileCRM.Reference>
A Promise object which will be resolved with a Reference object representing chosen entity record.
Example 1
This example demonstrates how to choose the parent customer from Contact form. This code opens up the Account list and sets chosen Account into the parent customer field.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function chooseParentCustomer() {
- try {
- var lookupForm = new MobileCRM.UI.LookupForm();
- // HOW TO ADD ADDITIONAL FILTERING TO LOOKUP FORM.
- var customXMLView = '<fetch version="1.0"><entity name="account">' +
- '<filter type="and"><condition attribute="address1_city" operator="like" value="Bratislava"/></filter></entity></fetch>';
- lookupForm.addEntityFilter("account", customXMLView)
- lookupForm.addView("account", "Default");
- lookupForm.allowNull = true; // Allow choosing empty value
- var accountRef = await lookupForm.showAsync();
- // Change the parent customer on currently edited contact entity
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- var editedContact = entityForm.entity;
- var newCustomer = accountRef ? new MobileCRM.Reference(accountRef.entityName, accountRef.id, accountRef.primaryName) : null;
- editedContact.properties["parentcustomerid"] = newCustomer;
- },
- MobileCRM.bridge.alert
- );
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
- }
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. |
getDataAsync | [v8.0] Gets the media tab document in form of base64 string. |
getDocumentInfo | [v8.0.1] Asynchronously gets the media tab view object. |
getNoteSubject | [v10.1] Asynchronously gets the subject text of the note loaded on the media tab. |
isEmpty | [v9.0.2] Asynchronously gets the boolean value indicating whether the media tab content is empty or not. |
open | Opens the loaded document in a external application. Which application is platform specific. |
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. |
getDataAsync | [v8.0] Gets the media tab document in form of base64 string. |
MobileCRM.UI.MediaTab.capturePhoto Method
Captures photo on this media tab.
Example 1
This example demonstrates how to initiate photo capture on the media tab.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.capturePhoto();
- },
- MobileCRM.bridge.alert,
- null
- );
MobileCRM.UI.MediaTab.clear Method
Clears the content of this media tab.
Example 1
This example demonstrates how to clear the media tab content.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.clear();
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.getData(
- function (base64String) {
- MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
- var img = document.getElementById("imgTarget");
- if (img)
- // Construct data URL from base64 data and set it as a source to <img> element.
- img.src = "data:;base64," + base64String;
- },
- MobileCRM.bridge.alert
- );
- }, MobileCRM.bridge.alert, null );
MobileCRM.UI.MediaTab.getDataAsync Method
[v8.0] Gets the media tab document in form of base64 string.
Return value
Type: Promise<string>
A Promise object which will be resolved with the base64-encoded document data.
Example 1
This example demonstrates how to retrieve data from existing media tab (in our case with name "DocumentAction"). In case of image data, resulting base64 can be set as source of the <img> element.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- MobileCRM.UI.EntityForm.requestObject(
- async function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- var base64String = await media.getData();
- MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
- var img = document.getElementById("imgTarget");
- if (img)
- // Construct data URL from base64 data and set it as a source to <img> element.
- img.src = "data:;base64," + base64String;
- }
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.getDocumentInfo(
- function (info) {
- // 0=None, 1=Signature, 2=WebPage, 3=Image, 4=File
- var documentInfo = JSON.stringify(info);
- MobileCRM.bridge.alert("Document info : \n\n" + documentInfo);
- },
- MobileCRM.bridge.alert
- );
- },
- 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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.recordAudio();
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.recordVideo();
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.selectFile();
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.selectPhoto();
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- var DocumentAction = {
- /** No action.*/
- None: 0x0000,
- /** Configures the view for ink input.*/
- CaptureInk: 0x0001,
- /** Asks the user to capture a photo and loads the choosen media into the view.*/
- CapturePhoto: 0x0002,
- /** Asks the user to choose a media (image, video, depending on what the platform supports) and loads the choosen media into the view.*/
- SelectPhoto: 0x0004,
- /** Asks the user to choose a file and loads it into the view.*/
- SelectFile: 0x0008,
- /** Asks the user to record an audio note and loads it into the view.*/
- RecordAudio: 0x0010,
- /** Asks the user to record a video and loads it into the view.*/
- RecordVideo: 0x0020,
- /** Gets last photo taken and loads it into the view.*/
- UseLastPhotoTaken: 0x0040,
- /** Asks the user to choose file from either online or offline location and loads it into the view.*/
- LoadFrom: 0x0080,
- /** Clears the view and marks it as empty.*/
- Clear: 0x1000,
- /** Shows a preview of the loaded document (fullscreen, etc.).*/
- View: 0x2000,
- /** Opens the loaded document in a external application. Which application is platform specific.*/
- OpenExternal: 0x4000,
- /** Sends the document to another application. This command is implemented only on Android.*/
- SendTo: 0x8000,
- /** Virtual action handled in common code.*/
- Download: 0x10000,
- /** Copy image to clipboard.*/
- Copy: 0x20000,
- /** Paste image from clipboard.*/
- Paste: 0x40000,
- /** Prints the document.*/
- Print: 0x80000,
- /** Let user to choose smaller image resolution.*/
- ResizeImage: 0x100000,
- /** Let user import VCard attachment (handled in common code).*/
- Import: 0x200000,
- /** Pass document to edit in external app (Microsoft office so far[15.6.2015]).*/
- Edit: 0x400000,
- /** Send document as attachment.*/
- Email: 0x800000,
- /** Ask the user to choose multiple images.*/
- SelectMultiplePhotos: 0x1000000,
- /** Asks the user to choose multiple files from either online or offline location and loads it into the view.*/
- LoadFromMultiple: 0x2000000,
- /** Opens image in the image editor.*/
- EditImage: 0x4000000,
- /** Saves to file to disk.*/
- Export: 0x8000000,
- /** Actions that are non-destructive.*/
- ReadOnlyMask: 0x88AE000 // SendTo | View | OpenExternal | Print | Email | Copy | Export
- };
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.setCommandsMask(DocumentAction.CapturePhoto | DocumentAction.SelectPhoto, MobileCRM.bridge.alert);
- },
- MobileCRM.bridge.alert, null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.setEditable(true, MobileCRM.bridge.alert); // set false to make it read-only
- },
- MobileCRM.bridge.alert, null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- media.getData(
- function (base64String) {
- MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
- var img = document.getElementById("imgTarget");
- if (img)
- // Construct data URL from base64 data and set it as a source to <img> element.
- img.src = "data:;base64," + base64String;
- },
- MobileCRM.bridge.alert
- );
- }, MobileCRM.bridge.alert, null );
MobileCRM.UI.MediaTab.getDataAsync 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. |
Return value
Type: Promise<string>
A Promise object which will be resolved with the base64-encoded document data.
Example 1
This example demonstrates how to retrieve data from existing media tab (in our case with name "DocumentAction"). In case of image data, resulting base64 can be set as source of the <img> element.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- MobileCRM.UI.EntityForm.requestObject(
- async function (entityForm) {
- // get media tab by its name
- var media = entityForm.getMediaTab("DocumentAction");
- var base64String = await media.getData();
- MobileCRM.bridge.alert("base64String from media tab:\n" + base64String);
- var img = document.getElementById("imgTarget");
- if (img)
- // Construct data URL from base64 data and set it as a source to <img> element.
- img.src = "data:;base64," + base64String;
- }
- );
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. |
showAsync | Shows a popup window allowing user to choose one of actions. |
Functions
Function | Description |
---|---|
sayText | Shows a simple popup window with a multi-line text. |
sayTextAsync | 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.
- var popup = new MobileCRM.UI.MessageBox("title");
- /// Add the buttons for message box
- popup.items = ["Yes", "No"];
- /// If title is too long set the 'multi-line' to true
- popup.multiLine = true;
- popup.show(
- function (button) {
- if (button == "Yes")
- MobileCRM.bridge.alert("You taped on 'Yes' button");
- else
- MobileCRM.bridge.alert("You taped on 'NO' button");
- return;
- }
- );
MobileCRM.UI.MessageBox.showAsync Method
Shows a popup window allowing user to choose one of actions.
Return value
Type: Promise<string>
A Promise object which will be resolved with chosen item string.
Example 1
This example demonstrates how to create and display the message box with buttons "YES" and "No".
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function confirmMsg(title) {
- var popup = new MobileCRM.UI.MessageBox(title);
- /// Add the buttons for message box
- popup.items = ["Yes", "No"];
- /// If title is too long set the 'multi-line' to true
- popup.multiLine = true;
- var button = await popup.showAsync();
- if (button == "Yes")
- MobileCRM.bridge.alert("You taped on 'Yes' button");
- else
- MobileCRM.bridge.alert("You taped on 'NO' button");
- }
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.
- var text = "Thank you for using this method\nPress OK to continue."
- MobileCRM.UI.MessageBox.sayText(text, function () {
- // ... continue execution
- });
MobileCRM.UI.MessageBox.sayTextAsync Function
Shows a simple popup window with a multi-line text.
Arguments
Argument | Type | Description |
---|---|---|
text | String | A text to be shown. |
Return value
Type: Promise<void>
A Promise object which will be resolved when user closes the message box.
Example 1
This example demonstrates how to display simple popup with multi-line text.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- var text = "Thank you for using this method\nPress OK to continue."
- await MobileCRM.UI.MessageBox.sayText(text);
- // ... execution continues after user closes the message box
MobileCRM.UI.MultiLookupForm Object
[v9.3] This object allows user to select a list of entities from a configurable list of entity types. Derived from LookupForm so you can use the addView() and addEntityFilter() methods.
Properties
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. |
allowNull | Boolean | Whether to allow selecting no entity. |
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. |
showAsync | 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.
- function openMultiLookUp(orderRef) {
- /// <param name='orderRef' type='MobileCRM.Reference'>A reference to a sales order entity.</param>
- var filteredLeadXML =
- '<fetch version="1.0">' +
- '<entity name="product">' +
- '<filter type="and">' +
- '<condition attribute="name" operator="like" value="H%" />' +
- '</filter>' +
- '</entity>' +
- '</fetch>';
- var ml = new MobileCRM.UI.MultiLookupForm("product");
- ml.source = new MobileCRM.Relationship("salesorderid", orderRef);
- ml.addEntityFilter("product", filteredLeadXML);
- ml.allowNull = true;
- ml.addView("product", "Active Products", true); // requires "Active Products" view for "product" entity in your mobile project
- ml.show(function (selected) {
- /// <param name='selected' type='Array<MobileCRM.Reference>'/>
- }, MobileCRM.bridge.alert, null);
- }
MobileCRM.UI.MultiLookupForm.showAsync Method
Shows a dialog which allows the user to select a list of entities from a configurable list of entity types.
Return value
Type: Promise<MobileCRM.Reference[]>
A Promise object which will be resolved with an array of Reference objects representing chosen entity records.
Example 1
This example demonstrates how to select products from multi-lookup form. It opens the multi-lookup form with products matching specified filter fetch.
- // WARNING: async/await pattern requires ECMAScript 6 and it's not supported on Internet Explorer.
- // It's supported by all modern browsers including mobile version of Chrome and Safari (requires Android 5+ and iOS 10+).
- async function openMultiLookUp(orderRef) {
- /// <param name='orderRef' type='MobileCRM.Reference'>A reference to a sales order entity.</param>
- var filteredLeadXML =
- '<fetch version="1.0">' +
- '<entity name="product">' +
- '<filter type="and">' +
- '<condition attribute="name" operator="like" value="H%" />' +
- '</filter>' +
- '</entity>' +
- '</fetch>';
- try {
- var ml = new MobileCRM.UI.MultiLookupForm("product");
- ml.source = new MobileCRM.Relationship("salesorderid", orderRef);;
- ml.addEntityFilter("product", filteredLeadXML);
- ml.allowNull = true;
- ml.addView("product", "Active Products", true); // requires "Active Products" view for "product" entity in your mobile project
- var selected = await ml.showAsync();
- var reportText = selected.map(function(a) { return a.primaryName; }).join(", ");
- MobileCRM.bridge.alert(reportText);
- }
- catch (err) {
- MobileCRM.bridge.alert(err);
- }
- }
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. |
moveToNextStage | [15.0] Progresses to the next stage of the active process. |
moveToPreviousStage | [15.0] Moves to the previous stage of the active process. |
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.
- MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var processController = entityForm.getController("process");
- if (processController) {
- var info = processController.currentStateInfo;
- var activeStageRef = new MobileCRM.Reference("workflow", info.ActiveStage, info.ActiveStageName);
- var visibleStageRef = new MobileCRM.Reference("workflow", info.VisibleStage, info.VisibleStageName);
- var processId = prContr.currentStateInfo.ProcessId;
- // NOTE: null reference disables BusinessProcessFlow.
- processController.changeProcess(visibleStageRef, MobileCRM.bridge.alert, null);
- }
- }, MobileCRM.bridge.alert, null);
MobileCRM.UI.ProcessController.moveToNextStage Method
[15.0] Progresses to the next stage of the active process.
Arguments
Argument | Type | Description |
---|---|---|
errorCallback | function(errorMsg) | The errorCallback which is called asynchronously in case of error. |
scope | Object | The scope for callback. |
MobileCRM.UI.ProcessController.moveToPreviousStage Method
[15.0] Moves to the previous stage of the active process.
Arguments
Argument | Type | Description |
---|---|---|
errorCallback | function(errorMsg) | The errorCallback which is called asynchronously in case of error. |
scope | Object | The scope for callback. |
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. |
onCommand | Binds or unbinds the handler for QuestionnaireForm command. |
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. |
trySetImageAnswer | Asynchronously sets the answer value for given image 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.onCommand Function
Binds or unbinds the handler for QuestionnaireForm command.
Arguments
Argument | Type | Description |
---|---|---|
command | String | The name of the QuestionnaireForm command. |
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.trySetImageAnswer Function
Asynchronously sets the answer value for given image question.
Arguments
Argument | Type | Description |
---|---|---|
imageQuestionName | String | A name of the image question. |
base64Data | string | A value that us used to create image answer. If null or empty image will be deleted. |
mimeType | string | The valid mime type of corresponding base64Data. |
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.
- var reportForm = new MobileCRM.UI.ReportForm();
- reportForm.allowedLanguages = [-1, 1033, 1031]; // Allow "Any language", English and German reports only
- reportForm.defaultReport = "Default" // Pre-select the report with the name "Default"
- 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.
- // Register command handler for custom command which was appended to form in Woodford
- MobileCRM.UI.EntityForm.onCommand(
- "custom_PrintReport",
- function (entityForm) {
- fetchReports(3); // 3 is object type code for Opportunity entity (for demonstration)
- },
- true
- );
- function fetchReports(objectTypeCode) {
- // fetch desired reports - Requires "Report" entity being enabled in Woodford!!!
- var entity = new MobileCRM.FetchXml.Entity("report");
- entity.addAttribute("reportid");
- var filter = entity.addFilter();
- filter.where("parentreportid", "null", null); // take just root reports
- // link reportentity filtering just reports for our object type code (Opportunity)
- var linkEntity = entity.addLink("reportentity", "reportid", "reportid", "inner");
- linkEntity.addFilter().where("objecttypecode", "eq", objectTypeCode);
- // Take only reports owned by our business unit (optional)
- linkEntity = entity.addLink("businessunit", "businessunitid", "owningbusinessunit", "inner");
- linkEntity.addFilter().where("businessunitid", "eq-businessid", null);
- // TBD: Optionally define order: entity.orderBy("name", false);
- // Execute online fetch request
- var fetch = new MobileCRM.FetchXml.Fetch(entity);
- fetch.executeOnline(
- "Array", // Take the results as an array of arrays with field values
- function (result) {
- // "result" is array of arrays [[id1],[id2],...[idn]]
- var ids = [];
- for (var i in result) {
- var record = result[i];
- ids.push(record[0]); // take just first (and only) field which is reportid
- }
- showReport(ids);
- },
- function (err) {
- MobileCRM.bridge.alert("Error fetching accounts: " + err);
- },
- null
- );
- }
- function showReport(ids) {
- var reportForm = new MobileCRM.UI.ReportForm();
- reportForm.allowedReportIds = ids;
- //reportForm.defaultReport = "Default"; // Optionally pre-select the report with the name "Default"
- reportForm.show(null, MobileCRM.bridge.alert); // Do nothing on success, say error on failure
- }
MobileCRM.UI.RoutePlan Object
[v14.2] Represents the Javascript equivalent view of RoutePlan form object.
Properties
Property | Type | Description |
---|---|---|
myRoute | DynamicEntity[] | A list of route entities. |
completedEntities | DynamicEntity[] | A list of completed entities that are about to be removed from route plan. |
routeEntityName | String | Logical name of the route visit entity. |
routeDay | Date | Currently selected route day. |
isDirty | Boolean | Controls whether the form is dirty and requires save, or whether it can be closed. |
Methods
Method | Description |
---|---|
suspendPostSave | Suspends current "onPostSave" operations and allows performing another asynchronous tasks before the form is closed. |
suspendSave | Suspends current "onSave" process and allows performing asynchronous tasks to save the data. |
Functions
Function | Description |
---|---|
onItemAdded | Binds or unbinds the handler for "Item Added" event. |
onItemCompleted | Binds or unbinds the handler for "Item Completed" event. |
onItemPostSave | Binds or unbinds the handler for further actions on saved visit entity. |
onItemRemoved | Binds or unbinds the handler for "Item Removed" event. |
onItemSave | Binds or unbinds the handler for validating single visit entity save. |
onPostSave | Binds or unbinds the handler for further actions on saved route. |
onRouteReloaded | Binds or unbinds the handler called after route is reloaded. |
onSave | Binds or unbinds the handler for route save validation. |
requestObject | Requests the managed RoutePlan object. |
MobileCRM.UI.RoutePlan.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.RoutePlan.suspendSave Method
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.RoutePlan.onItemAdded Function
Binds or unbinds the handler for "Item Added" event.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan context object contains property "entity" carrying DynamicEntity object of the new visit record.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 modify new appointment when being included into the route.
- MobileCRM.UI.RoutePlan.onItemAdded(function (routePlan) {
- var newAppointment = routePlan.context.entity;
- newAppointment.properties.description = "Added from RoutePlan";
- }, true);
MobileCRM.UI.RoutePlan.onItemCompleted Function
Binds or unbinds the handler for "Item Completed" event.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan context object contains property "entity" carrying DynamicEntity object af completed visit record being removed from route plan.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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.RoutePlan.onItemPostSave Function
Binds or unbinds the handler for further actions on saved visit entity.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan 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 and property "savedEntity" carrying saved DynamicEntity object.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 initiate the background synchronization if a new visit was saved from route details ("Sync Login" option has to be turned off and "Save Password" turned on in Woodford configuration).
- var itemSyncNeeded = false;
- MobileCRM.UI.RoutePlan.onItemSave(function (routePlan) {
- if (!itemSyncNeeded) {
- // Check if entity being saved isn't new
- itemSyncNeeded = routePlan.context.entityToSave.isNew;
- }
- }, true);
- MobileCRM.UI.RoutePlan.onItemPostSave(function (routePlan) {
- if (itemSyncNeeded) {
- itemSyncNeeded = false;
- MobileCRM.Application.synchronize(true); // new item was saved - force background sync
- }
- }, true);
MobileCRM.UI.RoutePlan.onItemRemoved Function
Binds or unbinds the handler for "Item Removed" event.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan context object contains property "entity" carrying DynamicEntity object of unsaved visit record being removed from route plan.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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.RoutePlan.onItemSave Function
Binds or unbinds the handler for validating single visit entity save.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan context object contains property "errorMessage" that can be used to cancel save with an error and property "entityToSave" carrying visit DynamicEntity record.
Use suspendSave method to suspend the save process if an asynchronous operation is required.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 perform asynchronous route entitiy save validation when saving visit from the route details.
- var handler = routePlan.suspendSave();
- MobileCRM.UI.RoutePlan.onItemSave(function (routePlan) {
- var entityToSave = routePlan.context.entityToSave;
- // Perform additional asynchronous validation on entities that are about to be saved.
- checkParentAccountAsync(entityToSave, function (errorMessage) {
- if (errorMessage)
- handler.resumeSave("Can't save the route: " + errorMessage);
- else
- handler.resumeSave();
- });
- });
MobileCRM.UI.RoutePlan.onPostSave Function
Binds or unbinds the handler for further actions on saved route.
Bound handler is called with the RoutePlan object as an argument.
Use suspendPostSave method to suspend the post-save process if an asynchronous operation is required.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 initiate the background synchronization if saved route contained a new visit ("Sync Login" option has to be turned off and "Save Password" turned on in Woodford configuration).
- var syncNeeded = false;
- MobileCRM.UI.RoutePlan.onSave(function (routePlan) {
- if (!syncNeeded) {
- // Check if some of route entities isn't new
- syncNeeded = routePlan.myRoute.some(function (e) { return e.isNew; });
- }
- }, true);
- MobileCRM.UI.RoutePlan.onPostSave(function (routePlan) {
- if (syncNeeded) {
- syncNeeded = false;
- MobileCRM.Application.synchronize(true); // new item was saved - force background sync
- }
- }, true);
MobileCRM.UI.RoutePlan.onRouteReloaded Function
Binds or unbinds the handler called after route is reloaded.
Bound handler is called with the RoutePlan object as an argument on start or when day or filter field is changed.
Arguments
Argument | Type | Description |
---|---|---|
handler | function(RoutePlan) | 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 react on route changes.
- MobileCRM.UI.RoutePlan.onRouteReloaded(function (routePlan) {
- var day = routePlan.routeDay;
- var routeEntities = routePlan.myRoute;
- calculateStatistics(routeDay, routeEntities);
- }, true);
MobileCRM.UI.RoutePlan.onSave Function
Binds or unbinds the handler for route save validation.
Bound handler is called with the RoutePlan object as an argument.
The RoutePlan 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(RoutePlan) | 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 validate the route entities before saving.
- MobileCRM.UI.RoutePlan.onSave(function (routePlan) {
- var visitEntities = routePlan.myRoute;
- visitEntities.forEach(
- function (appointment) {
- if (appointment.isNew && appointment.properties.scheduledon < new Date()) {
- routePlan.context.errorMessage = "Visits can't be planned to past.";
- }
- });
- }, true, null);
Example 2
This example demonstrates how to perform asynchronous route entities save validation.
- MobileCRM.UI.RoutePlan.onSave(function (routePlan) {
- var handler = routePlan.suspendSave();
- var dirtyEntities = routePlan.myRoute.filter(
- function (appointment) {
- return appointment.isDirty;
- });
- // Perform additional asynchronous validation on entities that are about to be saved.
- checkParentAccountAsync(dirtyEntities, function (errorMessage) {
- if (errorMessage)
- handler.resumeSave("Can't save the route: " + errorMessage);
- else
- handler.resumeSave();
- });
- }, true, null);
MobileCRM.UI.RoutePlan.requestObject Function
Requests the managed RoutePlan object.
Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of RoutePlan object. See MobileCRM.Bridge.requestObject for further details.
Arguments
Argument | Type | Description |
---|---|---|
callback | function(platform) | The callback function that is called asynchronously with serialized RoutePlan object as argument. |
errorCallback | function(errorMsg) | The errorCallback which is called in case of error. |
scope | Object | The scope for callbacks. |
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. |
Example 1
This example demonstrate how to bind handler for creating new appointment on tour plan form.
- /// Register handler on tourplan form for create new event.
- MobileCRM.UI.TourplanForm.onCreateNew(function (tourPlanForm) {
- ///<param name='tourPlanForm' type='MobileCRM.UI.TourplanForm' />
- /// The context of tour plan form object contains "start", "end", "entityName" properties and optionally "subject" property.
- MobileCRM.bridge.alert("Current Date: " + tourPlanForm.view.currentDate + "\n\nOn Create new: " + JSON.stringify(tourPlanForm.context));
- }, true, null);
MobileCRM.UI.TourplanForm.requestObject Function
Requests the managed TourplanForm object.
Method initiates an asynchronous request which either ends with calling the errorCallback or with calling the callback with Javascript version of TourplanForm 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.
- // Create primary command on form with two options
- MobileCRM.UI.ViewController.createCommand(
- true,
- ['Previous', 'Next'],
- function (command) {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- // Handle command and select previous/next tab on the form
- if (command == 'Previous')
- entityForm.form.selectedViewIndex--;
- else
- entityForm.form.selectedViewIndex++;
- return true;
- }
- );
- },
- null
- );
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.
- function loadViews(entityName) {
- MobileCRM.UI.ViewDefinition.loadEntityViews(
- entityName,
- function (views) {
- /// <param name="views" type="Array"/>
- if (views != undefined && views.length > 0) {
- var viewNames = "";
- for (var i in views) {
- viewNames += views[i].name;
- }
- MobileCRM.bridge.alert(viewNames);
- }
- },
- MobileCRM.bridge.alert,
- null
- );
- }
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 |
---|---|
addItemToGrid | [since 13.1] Add detail item to desired position in to grid. |
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.addItemToGrid Method
[since 13.1] Add detail item to desired position in to grid.
Arguments
Argument | Type | Description |
---|---|---|
gridName | String | name of grid item. |
item | MobileCRM.UI.DetailViewItems.Item | Detail item MobileCRM.UI.DetailViewItems.Itemobject. |
column | Number | Optional Column x axis parameter, default is 0. |
row | Number | Optional Row y axis parameter, default is 0. |
colSpan | Number | Optional Column width x axis width , default is 1. |
rowSpan | Number | Optional Row width y axis width, default is 1. |
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"
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var detailView = entityForm.getDetailView("General");
- var linkItem = detailView.getItemByName("SaveLink");
- // ...
- }, 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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var linkItem = detailView.getItemByName("SaveLink");
- if (linkItem) {
- // The item was already inserted on the form.
- // Just set the value property and bind the handler.
- linkItem.setTypedValue("value", "System.String", "Save"); // The type must be set explicitly for LinkItem
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- }
- else {
- // create MobileCRM.UI.DetailViewItems.LinkItem
- linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", "Save");
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- detailView.insertItem(linkItem, -1); // Place the item as the last one.
- }
- var checkBoxItem = detailView.getItemByName("ShowDetails");
- if (checkBoxItem) {
- // The item was already inserted on the form.
- // Just set the value property.
- checkBoxItem.value = true;
- }
- else {
- // create MobileCRM.UI.DetailViewItems.CheckBoxItem
- checkBoxItem = new MobileCRM.UI.DetailViewItems.CheckBoxItem("ShowDetails", "Show Details");
- checkBoxItem.value = true;
- detailView.insertItem(checkBoxItem, 0); // Place the item as the first one.
- }
- }, MobileCRM.bridge.alert, null);
- function onLinkItemClick(itemName, detailViewName) {
- MobileCRM.UI.EntityForm.saveAndClose();
- }
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "ShowDetails") {
- var detailView = entityForm.getDetailView("General");
- var checkBoxItem = detailView.getItemByName("ShowDetails");
- if (checkBoxItem.value) {
- // Show your details
- }
- else {
- // Hide your details.
- }
- }
- },
- 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.
- function registerEvent(itemName){
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var linkItem = detailView.getItemByName(itemName);
- if (linkItem) {
- // The item was already inserted on the form.
- // Just set the value property and bind the handler.
- linkItem.setTypedValue("value", "System.String", itemName); // The type must be set explicitly for LinkItem
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- }
- else {
- // create MobileCRM.UI.DetailViewItems.LinkItem
- linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", itemName);
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- detailView.insertItem(linkItem, -1); // Place the item as the last one.
- }
- },
- MobileCRM.bridge.alert
- );
- }
- function onLinkItemClick(itemName, detailViewName) {
- /// <param name="itemName" type="String">The name of detail view item which has been clicked.</params>
- /// <param name="detailViewName" type="String">The name of detail view which contains the clicked item.</params>
- MobileCRM.UI.EntityForm.saveAndClose();
- }
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.
- function removeItem(itemName) {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var items = detailView.items;
- for (var i in items) {
- if (items[i].name == itemName) {
- detailView.removeItem(i);
- return;
- }
- }
- },
- MobileCRM.bridge.alert
- );
- }
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var items = detailView.items;
- var indexes = [];
- for (var i in items) {
- if (items[i].name == "SaveLink")
- indexes.push(i);
- else if (items[i].name == "TextItem")
- indexes.push(i);
- else if (indexes.length == 2)
- break;
- }
- detailView.removeiItems(indexes);
- },
- MobileCRM.bridge.alert
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var detailView = entityForm.getDetailView("General");
- detailView.startEditItem(1);
- }, 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.
- function updateCustomComboboxSource(name) {
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- /// <param name='entityForm' type='MobileCRM.UI.EntityForm'/>
- var detailView = entityForm.getDetailView("General");
- var itemIndex = detailView.getItemIndex(name);
- if (itemIndex >= 0)
- detailView.updateComboItemDataSource(itemIndex, { "New Option 1": "1", "New Option 2": "2" });
- }, true, null);
- }
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.
- MobileCRM.UI.EntityForm.requestObject(function (entityForm) {
- /// <param name="entityForm" type="MobileCRM.UI.EntityForm"/>
- // Take detail view with name "General"
- var dv = entityForm.getDetailView("General");
- var inlineSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
- // Set Account entity view with name "ContactParents" defining the filter for accounts
- // that should be present in the inline lookup for this field.
- inlineSetup.addView("account", "ContactParents", true);
- // Alternatively, specify the explicit fetch XML filter for inline lookup
- // inlineSetup.addFilter("account", '<fetch version="1.0"><entity name="account">...</entity></fetch>');
- var dialogSetup = new MobileCRM.UI.DetailViewItems.LookupSetup();
- // Set "Default" view for expanded lookup form
- dialogSetup.addView("account", "Default", true);
- //dialogSetup.addFilter("account", '<fetch version="1.0"><entity name="account">...</entity></fetch>');
- var dialogOnly = false; // Allow both inline lookup and expanded lookup dialog
- dv.updateLinkItemViews(0, dialogSetup, inlineSetup, dialogOnly);
- }, onError, null);
- function onError(error) {
- /// <param name="error" type="String"/>
- if (error) MobileCRM.bridge.alert(error);
- }
MobileCRM.UI._DocumentController Object
Represents Media tab controller containing specific kind of document.
This field is not available directly, it is special type of _Controller for Media tab. Use EntityForm.getController to get it.
Properties
Property | Type | Description |
---|---|---|
isEmpty | boolean | Indicated whether the Media tab is empty. |
noteSubject | String | Gets Media tab note subject used for identifying right instance of related attachment. |
view | MobileCRM.UI._DocumentView | _Document view presenting attached document. |
MobileCRM.UI._DocumentInfo Object
Represents information about attached document.
Properties
Property | Type | Description |
---|---|---|
documentKind | number | 0=None, 1=Signature, 2=WebPage, 3=Image, 4=OtherFileType |
fileSize | number | Attachment file size. |
imageHeight | number | Image attachment height. |
imageWidth | number | Image attachment width. |
MobileCRM.UI._DocumentView Object
Represents the document view object containing the attachment document (binary field content).
Properties
Property | Type | Description |
---|---|---|
isVisible | Boolean | Gets or sets whether the view is visible. |
name | String | Gets the name of the view. |
documentInfo | _DocumentInfo | Contains information about attached document. |
fileName | string | Attached document file name". |
isEmpty | boolean | Indicates whether the view is empty or whether user has already provided a document. |
isReadOnly | boolean | Indicates whether the view is read-only. |
mimeType | string | Attached document file MIME type. |
inkTitle | string | Signature title. |
saveSignatureAsImage | boolean | Signature save mode: image or SVG. |
strokeWidth | number | Signature stroke width. |
maxImageWidth | number | Maximum allowed image width. Zero or negative numbers stand for no preference. |
maxImageHeight | number | Maximum allowed image height. Zero or negative numbers stand for no preference. |
desiredRatio | number | Desired width/height ratio. Zero values stand for no preference. Negative ratio means that reverse ratio is also allowed (accepts both 4:3 and 3:4). |
enforcementMode | number | Defines an action to take when image is included into ImageView (captured or selected from gallery). 0=NoEnforcement, 1=AutoCrop, 2=AutoResize, 3=AutoCrop&resize, 32768=OpenImageEditor. |
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.DetailViewItems Namespace
Contains a set of objects representing particular detail view items.
Objects
Object | Description |
---|---|
ButtonItem | [8.0] Represents the duration item. |
CheckBoxItem | [8.0] Represents the checkbox item. |
ComboBoxItem | [8.0] Represents the combobox item. |
DateTimeItem | [8.0] Represents the date/time item. |
DetailGridLength | [13.0] Represents the grid length in grid unit type. |
DropDownFormat | An enumeration defining the values of LinkItem's dropdown format. |
DurationItem | [8.0] Represents the duration item. |
GridItem | [13.0] Represents the grid item. |
GridStyleDefintion | [13.0] Represents the columns and rows style definition for grid 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.ButtonItem Object
[8.0] Represents the duration item.
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.UI.DetailViewItems.ButtonItem object. |
MobileCRM.UI.DetailViewItems.ButtonItem.constructor Method
Constructs an instance of MobileCRM.UI.DetailViewItems.ButtonItem object.
Arguments
Argument | Type | Description |
---|---|---|
name | String | Defines the item name. |
clickText | String | Gets or sets the text content of click button. |
label | String | Defines the item label. |
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var checkBoxItem = detailView.getItemByName("ShowDetails");
- if (checkBoxItem)
- checkBoxItem.value = true;
- else {
- checkBoxItem = new MobileCRM.UI.DetailViewItems.CheckBoxItem("ShowDetails", "Show Details");
- checkBoxItem.value = true;
- checkBoxItem.textChecked = "Checked";
- checkBoxItem.textUnchecked = "Unchecked";
- checkBoxItem.isNullable = false;
- detailView.insertItem(checkBoxItem, 0); // Place the item as the fist one.
- }
- },
- MobileCRM.bridge.alert,
- null
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "ShowDetails") {
- var detailView = entityForm.getDetailView("General");
- var checkBoxItem = detailView.getItemByName("ShowDetails");
- if (checkBoxItem.value) {
- // Show your details
- }
- else {
- // Hide your details.
- }
- }
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var comboItem = detailView.getItemByName("MyOptions");
- if (comboItem)
- comboItem.value = "val1";
- else {
- comboItem = new MobileCRM.UI.DetailViewItems.ComboBoxItem("MyOptions", "Choose Options");
- comboItem.value = "val1";
- comboItem.listDataSource = {
- "Label 1": "val1",
- "Label 2": "val2",
- };
- detailView.insertItem(comboItem, -1); // Place the item as the last one.
- }
- },
- MobileCRM.bridge.alert
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "MyOptions") {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("MyOptions");
- MobileCRM.bridge.alert(item.value); // Show an alert with currently chosen value
- }
- },
- MobileCRM.bridge.alert
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var dateItem = detailView.getItemByName("StartTime");
- if (dateItem)
- dateItem.value = new Date(); // Set current time
- else {
- dateItem = new MobileCRM.UI.DetailViewItems.DateTimeItem("StartTime", "Start Time");
- dateItem.value = new Date(); // Set current time
- dateItem.parts = 1;
- detailView.insertItem(dateItem, -1); // Place the item as the last one.
- }
- },
- MobileCRM.bridge.alert,
- null
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "StartTime") {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("StartTime");
- MobileCRM.bridge.alert(item.value); // Show an alert with changed date&time
- }
- },
- MobileCRM.bridge.alert,
- null
- );
MobileCRM.UI.DetailViewItems.DetailGridLength Object
[13.0] Represents the grid length in grid unit type.
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.UI.DetailViewItems.DetailGridLength object. |
MobileCRM.UI.DetailViewItems.DetailGridLength.constructor Method
Constructs an instance of MobileCRM.UI.DetailViewItems.DetailGridLength object.
Arguments
Argument | Type | Description |
---|---|---|
value | String | Grid length value. |
gridUnitType | MobileCRM.UI.DetailViewItems.DetailGridUnitType | Defines the grid unit type. |
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("EventDuration");
- if (item)
- item.value = 65; // value is in seconds.
- else {
- item = new MobileCRM.UI.DetailViewItems.DurationItem("EventDuration", "Duration");
- item.value = 65;
- detailView.insertItem(item, -1); // Place item as the last one.
- }
- },
- MobileCRM.bridge.alert, null
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "EventDuration") {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("EventDuration");
- MobileCRM.bridge.alert(item.value + " seconds."); // Show an alert with changed duration in seconds.
- }
- },
- MobileCRM.bridge.alert,
- null
- );
MobileCRM.UI.DetailViewItems.GridItem Object
[13.0] Represents the grid item.
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.UI.DetailViewItems.GridItem object. |
addItem | [since 13.1] Add detail item to desired position in to grid. |
MobileCRM.UI.DetailViewItems.GridItem.constructor Method
Constructs an instance of MobileCRM.UI.DetailViewItems.GridItem object.
Arguments
Argument | Type | Description |
---|---|---|
name | String | Defines the item name. |
label | String | Defines the item label. |
gridStyleDefintion | MobileCRM.UI.DetailViewItems.GridStyleDefintion | Gets or sets the style definition for grid item. |
MobileCRM.UI.DetailViewItems.GridItem.addItem Method
[since 13.1] Add detail item to desired position in to grid.
Arguments
Argument | Type | Description |
---|---|---|
item | MobileCRM.UI.DetailViewItems.Item | Detail item MobileCRM.UI.DetailViewItems.Itemobject. |
column | Number | Optional Column x axis parameter, default is 0. |
row | Number | Optional Row y axis parameter, default is 0. |
colSpan | Number | Optional Column width x axis width , default is 1. |
rowSpan | Number | Optional Row width y axis width, default is 1. |
MobileCRM.UI.DetailViewItems.GridStyleDefintion Object
[13.0] Represents the columns and rows style definition for grid item.
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.UI.DetailViewItems.GridStyleDefintion object. |
MobileCRM.UI.DetailViewItems.GridStyleDefintion.constructor Method
Constructs an instance of MobileCRM.UI.DetailViewItems.GridStyleDefintion object.
Arguments
Argument | Type | Description |
---|---|---|
columns | Array | MobileCRM.UI.DetailViewItems.DetailGridLength>">Defines the columns style. |
rows | Array | MobileCRM.UI.DetailViewItems.DetailGridLength>">Defines the rows style. |
MobileCRM.UI.DetailViewItems.Item Object
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var linkItem = detailView.getItemByName("SaveLink");
- if (linkItem) {
- // The item was already inserted on the form.
- // Just set the value property and bind the handler.
- linkItem.setTypedValue("value", "System.String", "Save"); // The type must be set explicitly for LinkItem
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- }
- else {
- // create MobileCRM.UI.DetailViewItems.LinkItem
- linkItem = new MobileCRM.UI.DetailViewItems.LinkItem("SaveLink", "Save");
- detailView.registerClickHandler(linkItem, onLinkItemClick);
- detailView.insertItem(linkItem, -1); // Place the item as the last one.
- }
- }, MobileCRM.bridge.alert, null);
- function onLinkItemClick(itemName, detailViewName) {
- MobileCRM.UI.EntityForm.saveAndClose();
- }
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("Length");
- if (item)
- item.value = 55.333;
- else {
- item = new MobileCRM.UI.DetailViewItems.NumericItem("Length", "Length in meters");
- item.decimalPlaces = 2;
- item.value = 55.333;
- detailView.insertItem(item, -1); // Place the item as the last one.
- }
- },
- MobileCRM.bridge.alert, null
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "Length") {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("Length");
- MobileCRM.bridge.alert(item.value); // Show an alert with changed length
- }
- },
- MobileCRM.bridge.alert,
- null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("SectionSeparator");
- if (!item) {
- item = new MobileCRM.UI.DetailViewItems.SeparatorItem("SectionSeparator", "Next Section");
- detailView.insertItem(item, 2); // Insert item on the third place (index is zero-based). Index -1 puts item as the last one.
- }
- },
- MobileCRM.bridge.alert, null
- );
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.
- MobileCRM.UI.EntityForm.requestObject(
- function (entityForm) {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("Description");
- if (item)
- item.value = "first line \n second line";
- else {
- item = new MobileCRM.UI.DetailViewItems.TextBoxItem("Description", "Description (max 2 lines)");
- item.value = "first line \n second line";
- item.numberOfLines = 2;
- detailView.insertItem(item, -1); // Place the item as the last one.
- }
- },
- MobileCRM.bridge.alert
- );
- MobileCRM.UI.EntityForm.onChange(
- function (entityForm) {
- if (entityForm.context.changedItem == "Description") {
- var detailView = entityForm.getDetailView("General");
- var item = detailView.getItemByName("Description");
- MobileCRM.bridge.alert(item.value); // Show an alert with changed length
- }
- },
- MobileCRM.bridge.alert,
- null
- );
MobileCRM.Services Namespace
Contains non-UI classes for accessing documents...
Objects
Object | Description |
---|---|
AIVision | [v12.3] Represents a service for AI image recognition. |
AIVisionSettings | [v12.3] Represents the settings for AI image recognition service. |
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. |
CompanyInformation | Represents CompanyInformation object. |
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.AIVision Object
[v12.3] Represents a service for AI image recognition.
Properties
Property | Type | Description |
---|---|---|
action | number | Sets action for AI vision service. Capture photo or Select picture. |
settings | Array | Array sets of json formated prediction key and url. |
Methods
Method | Description |
---|---|
recognizeCapturedPhoto | [v12.3] Recognize captured photo using AIVison service. |
recognizeSelectedPicture | [v12.3] Select photo and recognize it with AIVison service. |
Functions
Function | Description |
---|---|
create | [v12.3]Create AIVsion instance using MobileCRM.Services.AIVisionSettings object. |
createFromEntity | [v12.3]Create AIVsion instance using entity name. The name is used to get settings from Woodford AI Image Recognition configuration. |
MobileCRM.Services.AIVision.recognizeCapturedPhoto Method
[v12.3] Recognize captured photo using AIVison service.
Arguments
Argument | Type | Description |
---|---|---|
sucessCallback | function | A callback function that is called with the object having array of tags and its probability and file path properties. {tags:[{tag:"", probability:""}], filePath:""} |
failureCallback | function(errorMsg) | A callback which is called in case of error. |
scope | Object | The scope for callbacks. |
MobileCRM.Services.AIVision.recognizeSelectedPicture Method
[v12.3] Select photo and recognize it with AIVison service.
Arguments
Argument | Type | Description |
---|---|---|
sucessCallback | function | A callback function that is called with the object having array of tags and its probability and file path properties. {tags:[{tag:"", probability:""}], filePath:""} |
failureCallback | function(errorMsg) | A callback which is called in case of error. |
scope | Object | The scope for callbacks. |
MobileCRM.Services.AIVision.create Function
[v12.3]Create AIVsion instance using MobileCRM.Services.AIVisionSettings object.
Arguments
Argument | Type | Description |
---|---|---|
settings | MobileCRM.Services.AIVisionSettings | AIVision settings. |
MobileCRM.Services.AIVision.createFromEntity Function
[v12.3]Create AIVsion instance using entity name. The name is used to get settings from Woodford AI Image Recognition configuration.
Arguments
Argument | Type | Description |
---|---|---|
entityName | String | The entity name of Woodford AI Image Recognition configuration. |
MobileCRM.Services.AIVisionSettings Object
[v12.3] Represents the settings for AI image recognition service.
Properties
Property | Type | Description |
---|---|---|
modelName | String | Gets or sets the model name. |
predictionKey | String | Gets or sets the model prediction key. |
url | String | Gets or sets the url to train model. |
serviceType | String | Gets or sets the service type. By default we use Azure. |
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.
- function onAddressBookService() {
- var addressbook = MobileCRM.Services.AddressBookService.getService(MobileCRM.bridge.alert, null);
- addressbook.getContact("1", processContactRecord, MobileCRM.bridge.alert, null);
- }
- function processContactRecord(contactRecord) {
- /// <param name='contactRecord' type='MobileCRM.Services.AddressBookService.AddressBookRecord'/>
- var jobTitle = contactRecord.jobTitle;
- var firstName = contactRecord.firstName;
- var lastName = contactRecord.lastName;
- MobileCRM.bridge.alert("Contact : " + jobTitle + " " + lastName + " " + firstName);
- }
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.
- var audioRecorder = MobileCRM.Services.AudioRecorder.startRecording(function (res) { }, MobileCRM.bridge.alert, null);
- audioRecorder.stopRecording(function () {
- var filePath = audioRecorder.getRecordFilePath(function (path) {
- if (path) {
- audioRecorder.getRecordBase64(function (base64) {
- // requires HTML 5
- var audioElemet = document.createElement("audio");
- if (audioElemet) {
- audioElemet.src = "data:audio/mp3:base64," + base64;
- }
- }, MobileCRM.bridge.alert, null);
- }
- }, MobileCRM.bridge.alert, null);
- }, 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.
- function joinChannel(entityRef) {
- /// <param name="entityRef" type="MobileCRM.Reference">
- /// Reference to an entity whose channel we want to join.
- /// </param>
- MobileCRM.Services.ChatService.getService(function (service) {
- service.subscribeToEntityChannel(entityRef, true, function () {
- MobileCRM.UI.MessageBox.sayText("You've joined the channel " + entityRef.primaryName);
- }, MobileCRM.bridge.alert);
- }, MobileCRM.bridge.alert);
- }
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.CompanyInformation Object
Represents CompanyInformation object.
Methods
Method | Description |
---|---|
constructor | Constructs an instance of MobileCRM.Services.CompanyInformation object. |
Functions
Function | Description |
---|---|
getCompanyInfoFromVat | Return callback with CompanyInformation object with properties name and address |
MobileCRM.Services.CompanyInformation.constructor Method
Constructs an instance of MobileCRM.Services.CompanyInformation object.
MobileCRM.Services.CompanyInformation.getCompanyInfoFromVat Function
Return callback with CompanyInformation object with properties name and address
Arguments
Argument | Type | Description |
---|---|---|
vat | string | VAT number of company. e.g. "SK2020232390" |
callback | function(CompanyInformation) | 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.DocumentService Object
[v8.1] Represents a service for acquiring the documents.
Properties
Property | Type | Description |
---|---|---|
maxImageSize | String | Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size [640x480,1024x768,1600x1200,2048x1536,2592x1936 ]. |
maxUploadImageSize | String | Gets or sets the maximum uploaded image size. If uploaded image size is greater then image is resized to specified maximum size [640x480,1024x768,1600x1200,2048x1536,2592x1936 ]. |
recordQuality | String | Gets or sets the record quality for audio/video recordings [Low, Medium, High]. |
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.] |
allowCancelHandler | Boolean | Indicates whether to allow handling of cancel event. Callback will pass the null argument in this case. |
Methods
Method | Description |
---|---|
capturePhoto | Asks the user to capture a photo and calls the async callback with file info. |
loadFrom | [13.3.4]Asks the user to choose a file and calls the async callback with file info. |
loadFromMultiple | [13.3.4]Asks the user to choose a multiple files and calls the async callback with file info. |
pasteFile | Takes the file from clipboard and calls the async callback with file info. |
[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. |
selectMultipleFiles | [v14.2.0] Asks the user to choose multiple files and calls the async callback with linked list of file infos (see FileInfo.nextInfo). |
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.
- var service = new MobileCRM.Services.DocumentService();
- service.maxImageSize = "640x480"; // maxImageSize can have one of following values: "Default", "640x480", "1024x768", "1600x1200", "2048x1536", "2592x1936"
- service.capturePhoto(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- if (fileInfo.url)
- testImg.src = fileInfo.url;
- },
- MobileCRM.bridge.alert
- );
MobileCRM.Services.DocumentService.loadFrom Method
[13.3.4]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. |
MobileCRM.Services.DocumentService.loadFromMultiple Method
[13.3.4]Asks the user to choose a multiple files 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. |
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).
- var service = new MobileCRM.Services.DocumentService();
- service.pasteFile(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
- },
- MobileCRM.bridge.alert
- );
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.
- function printFile(filePath) {
- /// <param name="filePath" type="String">A relative path to the file based on the application data root.</param>
- var service = new MobileCRM.Services.DocumentService();
- service.print(filePath, false, MobileCRM.bridge.alert, null);
- }
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).
- var service = new MobileCRM.Services.DocumentService();
- service.recordAudio(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- MobileCRM.bridge.alert("Audio file recorded: " + fileInfo.filePath + '\n' + fileInfo.url);
- },
- MobileCRM.bridge.alert
- );
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).
- var service = new MobileCRM.Services.DocumentService();
- service.recordQuality = "Medium";
- service.recordVideo(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- MobileCRM.bridge.alert("Video file recorded: " + fileInfo.filePath + '\n' + fileInfo.url);
- },
- MobileCRM.bridge.alert
- );
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.
- var service = new MobileCRM.Services.DocumentService();
- service.allowChooseVideo = true;
- service.selectFile(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
- },
- MobileCRM.bridge.alert
- );
MobileCRM.Services.DocumentService.selectMultipleFiles Method
[v14.2.0] Asks the user to choose multiple files 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.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.
- var service = new MobileCRM.Services.DocumentService();
- service.selectPhoto(
- function (fileInfo) {
- /// <param name='fileInfo' type='MobileCRM.Services.FileInfo '/>
- MobileCRM.bridge.alert("File pasted: " + fileInfo.filePath + '\n' + fileInfo.url);
- document.getElementById("imgElement").src = fileInfo.url;
- },
- MobileCRM.bridge.alert
- );
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.
- var addr = new MobileCRM.Services.GeoAddress();
- addr.country = "UK";
- addr.city = "London";
- addr.street = "Downing Street";
- addr.streetNumber = "10";
- addr.toLocation(function (location) {
- // location is {latitude: 51.50344025, longitude: -0.127708109585621}
- MobileCRM.bridge.alert(location.latitude + "\n" + location.longitude);
- }, 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.
- MobileCRM.Services.GeoAddress.fromLocation(51.50344025, -0.127708109585621, function (address) {
- /// <param name="address" type="MobileCRM.Services.GeoAddress"/>
- // Gets the GeoAddress: {streetNumber: "10", street: "Downing Street", city: "London", zip: "SW1A 2AA", stateOrProvice: "England", country: "UK", isValid: true}
- MobileCRM.bridge.alert(address.streetNumber + " " + address.street + "\n" + address.city);
- }, 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. |
sendAsync | [v13.3] 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.sendAsync Method
[v13.3] 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. |
Return value
Type: Promise<IWebResponse>
A Promise object which is asynchronously resolved with the web response object, or rejected with the web response object, where responseText contains error message.
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. |
OAuthError | Boolean | Sync failed because the OAuth access token can't be acquired or refreshed. |
syncDownloadRestartedOnBackground | Boolean | New customization was downloaded. Sync is still downloading data on background. |
warning | Boolean | Sync result contains some warnings that are not critical. |
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. |