You are on page 1of 198

D

R
A
F
T
CRM On Demand
Oracle CRM On Demand
Disconnected Mobile Sales
Developers Reference
Release 1.9
June 2014
CRM TechPubs Draft Modified: April 14, 2014 11:17 am
Copyright 2014 Oracle and/or its affiliates. All rights reserved.
This software and related documentation are provided under a license agreement containing restrictions
on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in
your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast,
modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any
means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for
interoperability, is prohibited.
The information contained herein is subject to change without notice and is not warranted to be error-
free. If you find any errors, please report them to us in writing.
If this is software or related documentation that is delivered to the U.S. Government or anyone licensing
it on behalf of the U.S. Government, the following notice is applicable:
U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software,
any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users
are commercial computer software pursuant to the applicable Federal Acquisition Regulation and
agency-specific supplemental regulations. As such, use, duplication, disclosure, modification, and
adaptation of the programs, including any operating system, integrated software, any programs installed
on the hardware, and/or documentation, shall be subject to license terms and license restrictions
applicable to the programs. No other rights are granted to the U.S. Government.
This software or hardware is developed for general use in a variety of information management
applications. It is not developed or intended for use in any inherently dangerous applications, including
applications that may create a risk of personal injury. If you use this software or hardware in dangerous
applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and
other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any
damages caused by use of this software or hardware in dangerous applications.
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be
trademarks of their respective owners.
Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks
are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD,
Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced
Micro Devices. UNIX is a registered trademark of The Open Group.
This software or hardware and documentation may provide access to or information on content,
products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and
expressly disclaim all warranties of any kind with respect to third-party content, products, and services.
Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due
to your access to or use of third-party content, products, or services.
Documentation Accessibility
For information about Oracle's commitment to accessibility, visit the Oracle Accessibility Program website
at http://www.oracle.com/pls/topic/lookup?ctx=acc&id=docacc.
Access to Oracle Support
Oracle customers have access to electronic support through My Oracle Support. For information,
visit http://www.oracle.com/pls/topic/lookup?ctx=acc&id=info or visit
http://www.oracle.com/pls/topic/lookup?ctx=acc&id=trs if you are hearing impaired.
DRAFT
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
3
DRAFT - Modified May 27, 2014 4:45 pm
Contents
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference 1
Chapter 1: Whats New in This Release
Chapter 2: Overview of Developers Support for Oracle
CRM On Demand Disconnected Mobile Sales for
Tablets
About This Guide 13
Overview of JavaScript Support 13
When to Use JavaScript Code 14
Where to Use JavaScript Code in the Admin Application 15
Supported JavaScript Events 16
Module Code Type and Available Events 17
Overview of HTML Support 20
Chapter 3: Adding JavaScript Code to Oracle CRM On
Demand Disconnected Mobile Sales
Before Adding JavaScript Code 21
Using Cut and Paste 21
Obtaining Module ID and Field Name Information 22
Using Keywords in Queries 24
Custom Device Messages and Multiple Language Installations 25
Creating Device Messages 25
Record ID and Device Record ID 26
Adding JavaScript Code 27
Enabling JavaScript Functionality 27
Adding JavaScript Code to Modules 28
Adding JavaScript Code to Fields 29
Adding JavaScript Code to Quick Selectors 30
Adding JavaScript Code to Tables 31
Adding JavaScript Code to Buttons 32
Configuring Shared JavaScript Libraries 34
Uploading a JavaScript Library to the Server 35
After Adding JavaScript Code 36
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
DRAFT - Modified May 27, 2014 4:45 pm
Contents
4
Sending the Configuration Application Definition File to Users 36
Chapter 4: JavaScript Structure Used in Oracle CRM On
Demand Disconnected Mobile Sales
Overview of JavaScript Structure 37
HTML Header 38
JavaScript Inclusions 38
JavaScript Body 38
Event Handlers: fieldsOnEvent and onEvent 39
Event Handlers: eventJSON 41
Event Handlers: Standard Handlers 42
HTML Footer 42
Chapter 5: Using JavaScript Code to Modify Records in
Oracle CRM On Demand Disconnected Mobile
Sales
Function onDelete in JavaScript Code 43
JavaScript onDelete Functions 43
Defining a Query in the onDelete Function 44
JavaScript onDelete Function Example 1: Checking a Single Condition 44
JavaScript onDelete Function Example 2: Checking Multiple Conditions 46
The onDeleteJSON Function 47
Function onCancel in JavaScript Code 48
JavaScript onCancel Functions 48
Defining a Query in the onCancel Function 49
JavaScript onCancel Function Example 49
Function onCreate in JavaScript Code 50
JavaScript onCreate Functions 50
Defining a Query in the onCreate Function 51
JavaScript onCreate Function Example 1: Read and Insert 52
JavaScript onCreate Function Example 2: Conditional Insert 53
JSON onCreateJSON Function 55
The onPreCreateJSON function 55
The onPostCreateJSON Function 56
Function OnEdit in JavaScript Code 57
JavaScript onEdit Functions 57
JSON onEditJSON Function 57
Function onOpen in JavaScript Code 58
Contents
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
5
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onOpen Functions 58
Defining a Query in the onOpen Function 58
JavaScript onOpen Function Example: Read and Insert 58
Displaying Virtual Fields 59
Functions onSave and onPreSave in JavaScript Code 61
JavaScript onPreSave Functions 61
Defining a Query in the onPreSave Function 62
JavaScript onPreSave Function Example 1: Checking a Single Condition 62
JavaScript onPreSave Function Example 2: Checking Multiple Conditions 65
JavaScript onPreSave Function Example 3: Checking a Parent 67
JavaScript onSave Functions 68
JavaScript onSave Function Example 1: Nonconditional Data 69
JavaScript onSave Function Example 2: Conditional Query 70
JavaScript fieldsOnSave and onSave Functions 71
JavaScript fieldsOnSave and onSave Functions Example 71
The onSaveFixedJSON Function 72
The doneSignature Entry Point 73
Chapter 6: Using JavaScript Code to Filter Information in
Oracle CRM On Demand Disconnected Mobile
Sales
JavaScript Code to Filter Related Items and Quick Selectors 75
Configuring Filters for Reference Fields 75
Configuring Filters for Quick Selectors 76
JavaScript Reference Functions 76
JavaScript Reference Function Example 1: Simple Filter 77
JavaScript Reference Function Example 2: Conditional Filter 77
JavaScript excludeFromPreload Function in Quick Selector Lists 79
Support for Field Condition Scripts in Quick Selector Lists 81
Using showViewAll to Control the Display of the View All Button 81
Chapter 7: Using JavaScript to Invoke Actions in Oracle
CRM On Demand Disconnected Mobile Sales
Using JavaScript to Implement Quick Action and Custom Action Buttons 83
JavaScript Button Functions 83
Passing Data to an External Application 84
Calling External Applications From Oracle CRM On Demand Disconnected Mobile Sales
85
Example Overview 85
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
DRAFT - Modified May 27, 2014 4:45 pm
Contents
6
Oracle CRM On Demand Disconnected Mobile Sales Configuration 86
Starting the Oracle Social Network 88
Writing the External Web Page 88
Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
Applications 91
Starting the Oracle CRM On Demand Disconnected Mobile Sales Application from External
Applications 91
Starting External Applications from the Oracle CRM On Demand Disconnected Mobile Sales
Application 93
Chapter 8: Using Actions in Oracle CRM On Demand
Disconnected Mobile Sales
About Actions 97
Functions Returning Actions 98
JavaScript Object Notation Actions 98
Primary and Secondary Actions 101
Validating Data 101
JSON Select Action 102
JSON Update Action 105
JSON Insert Action 106
JSON Validate Action 107
JSON goToURL Action 107
JSON getCondition Action 108
JSON Showprompt Action 109
Example of Invoked Function 110
Chapter 9: Using the DMS.js JavaScript Library in Oracle
CRM On Demand Disconnected Mobile Sales
Using the DMS.js JavaScript Library 115
DMS.showAlert Function 117
DMS.get Function 117
DMS.checkIfModuleExist function 117
List of Modules and Fields Present in DMS.js 118
Defining JSON Actions for DMS.js 120
DMS.action Function 121
DMS.validateAction Function 121
Select Action 121
Update Action 122
Contents
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
7
DRAFT - Modified May 27, 2014 4:45 pm
Insert Action 122
Delete Action 123
Validate Action 123
Using JavaScript Code in DMS.js 123
DMS.fieldsOnCancel Function 124
DMS.fieldsOnDefault Function 124
DMS.fieldsOnPreSave Function 125
DMS.fieldsOnConditionQuery Function 125
DMS.quickActionDetailer Function 126
Field Condition conditionQuery Function 127
DMS.conditionQuery Function 128
DMS.fieldsOnFilter Function 128
DMS.onValidateJSON Function 129
API Call Logic for Appointment and Attendee Call 129
DMSCall.onSaveJSONCall(options) 129
DMSCall.onAcceptAndSign(options) 130
DMSCall.onSubmitCall(options) 131
Callback Functions 133
onAcceptAndSign and acceptSignData 133
onSubmitCall and validateSubmitData 134
Callback Function Example 135
Call and Record Locking API 136
DMS.fieldsOnDelete Function 136
DMSCall.onDelete Function 137
Quick Selector API and Quick Selector Validate API 137
Quick Selector for Samples, Promotional Items, and Product Detailed 138
Quick Selectors for HCP Contact Allocation 139
Quick Selectors for Blocked Products 139
Controlled Substance Validation API 140
Using JavaScript Localization Code in DMS.js 141
Client Inbound WritebacK API 144
Inbound URL examples 148
Results of a Successful Insert or Update 149
Error Cases 149
Chapter 10: Using HTML in Oracle CRM On Demand
Disconnected Mobile Sales
Using Custom HTML for Oracle CRM On Demand Disconnected Mobile Sales 151
Structure of an HTML File 151
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
DRAFT - Modified May 27, 2014 4:45 pm
Contents
8
Bundling with Collaterals 153
About jQuery 153
Debugging CSS 153
About the melt:// Function 154
Available JSON Actions 154
Directory Structure 154
Creating a Custom User Interface Using HTML 155
Packaging with Collaterals 157
Referring to Other Packages and JS Libraries 157
melt Commands 158
Retrieving Data 158
exitpage Action 159
Adding Customizeable HTML Views 159
Navigating to an HTML View from a Custom Button 160
Creating HTML Page Layouts for Presentations 161
Reading System Keys 163
Configuring HTML Components for Oracle CRM On Demand Disconnected Mobile Sales
for Tablets 164
File Structure for HTML Components on the Mobile Device 167
Chapter 11: Local Database Tables for Oracle CRM On
Demand Disconnected Mobile Sales Client
Overview of Database Tables 169
Viewing Stored Records in the Local Database of the Client Application 170
Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables 170
Local Database Tables Field Definition 172
cad_apprules Table 173
cad_context Table 173
cad_externalappscheme Table 174
cad_fieldgroups Table 174
cad_fieldconditions Table 175
cad_formfields Table 175
cad_implicit_ids Table 176
cad_fieldkeyword Table 176
cad_lookup Table 176
cad_menuitems Table 177
cad_modulefield Table 178
cad_moduleicons Table 178
Contents
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
9
DRAFT - Modified May 27, 2014 4:45 pm
cad_modulerules Table 179
cad_options Table 179
cad_qsfields Table 180
cad_qsfilters Table 180
cad_qsmodules Table 181
cad_quickactions Table 181
cad_stfields Table 182
cad_stfilters Table 182
cad_systemkeys Table 183
me_addressbookuid Table 183
me_alertdata Table 184
me_attachments Table 184
me_calendaruid Table 185
me_datarelation Table 185
me_edited Table 186
me_geocode Table 186
me_login Table 187
me_lookup Table 187
me_lookupresponse Table 188
me_requestqueue Table 188
me_sortfields Table 189
me_temp Table 189
me_uniqueid Table 190
metadata_x Table 190
Appendix A: Example: Using JavaScript Object Notation to
Cascade Copy Records
Cascade Copy Records Example 191
Index
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
DRAFT - Modified May 27, 2014 4:45 pm
Contents
10
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
11
DRAFT - Modified May 27, 2014 4:45 pm
1 Whats New in This Release
Whats New in Oracle CRM On Demand Disconnected Mobile Sales
Developers Reference, Release 1.9
Table 1 lists the changes described in this version of the documentation to support this release of the
software.
NOTE: Oracle CRM On Demand Disconnected Mobile Sales for Tablets Release 1.9 supports Oracle
CRM On Demand Release 24 and later.
Table 1. Chapters in Oracle CRM On Demand Disconnected Mobile Sales Developers Reference,
Release 1.9
Topic Description
Supported JavaScript Events on
page 16
Modified topic. Updated the table on supported JavaScript
events.
Module Code Type and Available
Events on page 17
New topic. Added a topic on module code types and available
events.
Overview of HTML Support on
page 20
New topic. Added a topic on HTML support.
Obtaining Field Name
Information on page 23
Modified topic. Updated information on field names.
Using Keywords in Queries on
page 24
Modified topic. Added information on how to query for date and
time values.
Adding JavaScript Code to
Modules on page 28
Modified topic. Updated the table on module code types and
available events.
JavaScript Inclusions on
page 38
Modified topic. Added information on the DMS.js file.
The onDeleteJSON Function on
page 47
New topic. Added a topic on the onDeleteJSON function.
The onPreCreateJSON function
on page 55
New topic. Added a topic on the onPreCreateJSON function.
The onPostCreateJSON Function
on page 56
New topic. Added a topic on the onPostCreateJSON function.
Displaying Virtual Fields on
page 59
New topic. Added a topic on displaying virtual fields.
The doneSignature Entry Point
on page 73
New topic. Added a topic on the doneSignature entry point.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Whats New in This Release
12
DRAFT - Modified May 27, 2014 4:45 pm
Calling External Applications
From Oracle CRM On Demand
Disconnected Mobile Sales on
page 85
Modified topic. Added information on examples.
Starting the Oracle Social
Network on page 88
New topic. Added a topic on how to launch Oracle Social
Network.
Starting the Oracle CRM On
Demand Disconnected Mobile
Sales Application from External
Applications on page 91
Modified topic. Added information on context information.
Starting External Applications
from the Oracle CRM On Demand
Disconnected Mobile Sales
Application on page 93
Modified topic. Added information on Key Name.
Delete Action on page 123 New topic. Added a topic on the Delete action.
DMS.quickActionDetailer
Function on page 126
Modified topic. Added example code.
OnAcceptAndSign
Considerations on page 131
New topic. Added a topic on onAcceptAndSign considerations.
Using JavaScript Localization
Code in DMS.js on page 141
New topic. Added a topic on localization.
Client Inbound WritebacK API
on page 144
New topic. Added a topic on the client inbound writeback API.
Using HTML in Oracle CRM On
Demand Disconnected Mobile
Sales on page 151
New chapter. Added a new chapter on using HTML coding.
Configuring HTML Components
on page 165
New chapter. Added a new chapter on using HTML components.
Table 1. Chapters in Oracle CRM On Demand Disconnected Mobile Sales Developers Reference,
Release 1.9
Topic Description
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
13
DRAFT - Modified May 27, 2014 4:45 pm
2 Overview of Developers
Support for Oracle CRM On
Demand Disconnected Mobile
Sales for Tablets
This chapter introduces JavaScript support for Oracle CRM On Demand Disconnected Mobile Sales for
Tablets, and describes when and where to use HTML and JavaScript in Oracle CRM On Demand
Disconnected Mobile Sales for Tablets. It contains the following topics:
About This Guide on page 13
Overview of JavaScript Support on page 13
When to Use JavaScript Code on page 14
Where to Use JavaScript Code in the Admin Application on page 15
Supported JavaScript Events on page 16
Overview of HTML Support on page 20
About This Guide
This guide is for users with some coding experience who are familiar with Oracle CRM On Demand,
the Oracle CRM On Demand Disconnected Mobile Sales for Tablets Admin and client applications,
their data structures, and operations.
The purpose of this guide is to provide an introduction to using HTML and JavaScript code by
describing the commands and formatting that are supported within the Oracle CRM On Demand
Disconnected Mobile Sales for Tablets application. This guide shows the level of customization that
is possible for Oracle CRM On Demand Disconnected Mobile Sales for Tablets. Developers can write
both HTML and JavaScript code to support their customizations of Oracle CRM On Demand
Disconnected Mobile Sales for Tablets.
The Oracle CRM On Demand Disconnected Mobile Sales for Tabletsclient application supports
extension of native user interface using a JavaScript event model. Additionally, the client application
supports the creation of custom user interface with HTML. Both methods can reference a shared
library of JavaScript functions.
Overview of JavaScript Support
Oracle CRM On Demand Disconnected Mobile Sales for Tablets allows you to extend and customize
functionality using JavaScript. You enter the JavaScript using the Oracle CRM On Demand
Disconnected Mobile Sales for Tablets Admin application and distribute the JavaScript to users with
the application configuration.
The Oracle CRM On Demand Disconnected Mobile Sales for Tablets client application JavaScript event
model allows registration of JavaScript event handlers in several different contexts. JavaScript event
handlers can be registered for the following:
Module events. For example, creating, updating and deleting records.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets When to Use JavaScript Code
14
DRAFT - Modified May 27, 2014 4:45 pm
Selector events. For example, constraining or validating a record set that can be inserted into
a field.
Button events. For example, running a custom command.
Event handlers are registered automatically when they are added inline to JavaScript code in the
Admin application. You enter the inline JavaScript code for each JavaScript context (for modules,
selectors, or buttons) at different locations in the Admin application.
The Oracle CRM On Demand Disconnected Mobile Sales for Tablets client comes with a library of
supported Life Sciences functionality that can be called by the event handlers. Additionally, a library
management facility is provided for those who want to package and share their own custom
JavaScript library.
The JavaScript event model, default event handlers, and the Life Sciences library are part of the
Oracle CRM On Demand Disconnected Mobile Sales for Tablets product. Any code included in the
product is covered as part of the standard support agreement, including operation of the framework
supporting execution of JavaScript code additions. Any changes to the core code, any customer
developed code, or any code developed by a third-party that is not provided in the core product is
not covered as part of the standard support agreement. The Oracle CRM On Demand Disconnected
Mobile Sales for Tablets extensible framework is a powerful tool and must be used with care. Oracle
cannot directly support customer extensions, nor is Oracle responsible for results from execution of
custom functionality.
When to Use JavaScript Code
You can typically use JavaScript code in a variety of different situations, including the following:
Data validation. You can use data validation to ensure, for example, that an activity End Date
is greater than the Start Date.
Automated data entry. If activities are saved when Status is equal to Complete, then a time
stamp is automatically inserted for the closed date.
Inheriting fields from a parent. If you create a new contact for an Account, then the address
and telephone number fields are automatically populated.
Workflow enhancements. You can use workflow enhancements to ensure that certain tasks
are completed. When creating a new lead, for example, users are automatically directed to enter
in a follow up call.
Custom application tasks. You can use custom application tasks to, for example, allow users
to create custom actions that perform a sequence of actions together.
Linking to external applications. You can link to an external application to, for example, allow
users to pass data from Oracle CRM On Demand Disconnected Mobile Sales for Tablets to an
external application.
Filtering related records. You can include filters so that when you select a product type, only
product records of that type are displayed for selection. For example, if you are entering a lead
and you have to associate a product with the lead, then you can set up a filter to filter products
by product type.
You can use JavaScript when configuring the following in the Admin application:
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Where to Use JavaScript Code in the Admin Application
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
15
DRAFT - Modified May 27, 2014 4:45 pm
Module settings
Quick selectors
Table configurations
Field conditions (for filtering related records)
For more information, see Where to Use JavaScript Code in the Admin Application on page 15.
Where to Use JavaScript Code in the
Admin Application
The location to enter JavaScript code depends on what you are trying to do with it, but the main
areas where you can add JavaScript code in the Admin application are:
Generic module code. The most common area to enter JavaScript code is by using the generic
module code. Generic module code is specific to an entire module and includes the ability to
configure code to handle data validation, the automatic population of fields, to create custom
actions, to inherit fields from other modules, to perform calculations on fields, and so on.
Related item filtering. You can use JavaScript code to filter a list of related items. When
creating a lead, for example, you might only want to display employees from a specific sales
region.
Quick selector configuration. You can use JavaScript code to determine which related items
are available for selection when using the Quick Selector.
Quick selector validation. You can use JavaScript code to validate certain parameters when
using the Quick Selector to perform a soft stop.
Table preload options. You can use JavaScript code to determine which records are preloaded
to a table, if the preload option is being used.
When linking to external applications. You can use JavaScript code to configure which fields
to export to an external application and where to insert the code in the application.
Shared Code. You can use the JavaScript library manager in the Admin application (that is, the
Administrator, Import JS option) to upload JavaScript code that can be included in Oracle CRM
On Demand Disconnected Mobile Sales and which can be called from the different JavaScript
configuration points (for modules, selectors, or buttons) in the Admin application.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Supported JavaScript Events
16
DRAFT - Modified May 27, 2014 4:45 pm
Supported JavaScript Events
Table 2 shows the JavaScript events that are supported by the different features of Oracle CRM On
Demand Disconnected Mobile Sales, lists the available event handlers, and indicates where you can
add or use the events in the Admin application.
Table 2. Supported JavaScript Events and Where to Configure Them
Feature Admin Application Location Event Handlers
Custom Action Module Custom Action
JavaScript Code Type
onActionJSON
Detailer Quick Action Button Module Quick Action Detailer
Button
conditionQueryJSON
External Application Quick
Action
Module Quick Action External
Application Configuration
openExternalApp
Cancel Button Module onCancel JavaScript
Code Type
fieldsOnCancel and onCancel
New Button Module onCreate JavaScript
Code Type
fieldsOnDefault,
getDefaultValueOfMEFIELDNAME,
onPreCreateJSON,
onPostCreateJSON, onCreateJSON
Delete Button Module onDelete JavaScript
Code Type
fieldsOnDelete, onDelete and
onDeleteJSON
Edit Access Checking on
Forms
Module onEdit JavaScript Code
Type
onEditJSON
Defaulting in the Quick
Selector
Module onOpen JavaScript
Code Type
fieldsOnDefault and
getDefaultValueOfMEFIELDNAME
Save button Module onSave JavaScript
Code Type
fieldsOnDefault and
getDefaultValueOfMEFIELDNAME
fieldsOnPreSave and onPreSave
fieldsOnSave and OnSave
onPreSaveJSON
onSaveJSON
Call Accept and Sign Button Appointment and Attendee
Call Module onSave JavaScript
Code Type
onAcceptAndSign
Call Signature and Done
Button
Appointment and Attendee
Call Module onSave JavaScript
Code Type
doneSignature
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Supported JavaScript Events
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
17
DRAFT - Modified May 27, 2014 4:45 pm
Module Code Type and Available Events
Table 3 describes module code types and their available events.
Call Submit Button Quick Selector Filter Required
Type
fieldsOnConditionQuery and
onConditionQuery
conditionQueryJSON
excludeFromPreload
Quick Selector Validation
Button
Quick Selector Filter Validate
Type
onValidateJSON
fieldsOnFilter and onFilter
Reference Field Selector
Filters
Module Field Condition fieldsOnConditionQuery and
onConditionQuery
fieldsOnFilter and onFilter
conditionQueryJSON
excludeFromPreload
Table Display Filters Table Display Filter conditionQueryJSON
Table 3. Module Code Types and Their Available Events
Module Code
Type Description Available Events
onDelete The onDelete event executes when a user tries to
delete a record on a mobile device by selecting
delete.
fieldsOnDelete, onDelete
and onDeleteJSON
onCancel The onCancel event executes when a user enters a
new record on a mobile device, and then selects
Cancel.
fieldsOnCancel and
onCancel
onCreate The onCreate event executes when the New or plus
icon is selected to, for example, create a new record
in the Oracle CRM On Demand Disconnected Mobile
Sales application.
fieldsOnDefault
getDefaultValueOfMEFIE
LDNAME
onPreCreateJSON
onPostCreateJSON
onCreateJSON
onOpen The onOpen event executes when the Quick
Selector is selected.
fieldsOnDefault and
getDefaultValueOfMEFIE
LDNAME
Table 2. Supported JavaScript Events and Where to Configure Them
Feature Admin Application Location Event Handlers
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Supported JavaScript Events
18
DRAFT - Modified May 27, 2014 4:45 pm
onSave The onSave event executes when Save is selected
to save either a new record that is being created or
an existing record that is being updated. The
following actions need a little more information:
onPreCreateJSON() - Used for validation to see if
the user can create records, so in essence a check
which returns a true or false value in a validate
command to determine whether a user can or
cannot create a record.
onPostCreateJSON() - Used for defaulting fields
upon creating a record.
fieldsOnPreSave and
onPreSave
fieldsOnDefault and
getDefaultValueOfMEFIE
LDNAME
fieldsOnSave and
onSave
onPreSaveJSON
onSaveJSON
onSave
(for Appointment
and Activity
only)
In addition to the available OnSave events,
Appointment and Activity also support events that
are specific to collecting, signing, and submitting
calls.
doneSignature
onAcceptAndSign
onSubmitCall
onEdit The onEdit event executes when a user Selects Edit
to modify a record.
onEditJSON
CustomActions The CustomActions event executes when a
customized action in the Oracle CRM On Demand
Disconnected Mobile Sales application is selected.
Configuring JavaScript code as a custom action
adds an icon next to the Edit button in your Oracle
CRM On Demand Disconnected Mobile Sales
application. Selecting CustomActions displays a
drop-down menu, from which the user can choose
an action (or piece of code) to execute.
onActionJSON
Table 3. Module Code Types and Their Available Events
Module Code
Type Description Available Events
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Supported JavaScript Events
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
19
DRAFT - Modified May 27, 2014 4:45 pm
Table 4 describes supported event handlers for Quick Selectors.
Table 5 describes the supported event handlers for Table Filters.
Table 4. Supported Event Handlers for Quick Selectors
Quick Selector
Filter Type Description Available Events
Required The Required context is typically used when the
quick selector list is loaded to identify and
modify the set of records available in the quick
selector list.
You can use the Required context to configure
conditions, exclusions, and filters for the quick
selector list.
conditionQueryJSON
excludeFromPreload
fieldsOnConditionQuery and
conditionQuery
fieldsOnFilter and onFilter
Validate The Validate context is typically used when the
Validate button is selected in a quick selector
list.
You can use the Validate context to configure a
Validate button for the quick selector list.
onValidateJSON
Table 5. Supported Event Handlers for Table Filters
Table Display
Filter Type Description Available Events
Required The Required context is typically used when the
table is loaded to identify and modify the set of
records available in table.
You can use the Required context to configure
conditions, exclusions, and filters for the table.
conditionQueryJSON
excludeFromPreload
fieldsOnConditionQuery
and conditionQuery
fieldsOnFilter and onFilter
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Overview of Developers Support for Oracle CRM On Demand Disconnected Mobile
Sales for Tablets Overview of HTML Support
20
DRAFT - Modified May 27, 2014 4:45 pm
Table 6 describes the supported event handlers for Quick Action Buttons.
Overview of HTML Support
Oracle CRM On Demand Disconnected Mobile Sales for Tablets allows you to extend and customize
functionality using HTML. The Oracle CRM On Demand Disconnected Mobile Sales for Tablets client
application comes with a library of HTML routines that you can use in your customizations.
You enter the HTML using the Oracle CRM On Demand Disconnected Mobile Sales for Tablets Admin
application and distribute the HTML to users with the application configuration.
Table 6. Supported Event Handlers for Quick Action Buttons
Quick Selector
Filter Type Description Available Events
Open External
Application
The external application is called by the defined
Open External Application button, which constructs
the URL to invoke for the external application. If the
event handler is present, other settings such as the
application URL (App URL) and application command
(App Command) are ignored.
openExternalApp
Detailer The detailer context is typically used to provide a
selector for the set of messaging plans that are
available for detailing.
conditionQueryJSON
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
21
DRAFT - Modified May 27, 2014 4:45 pm
3 Adding JavaScript Code to
Oracle CRM On Demand
Disconnected Mobile Sales
This chapter introduces how to add JavaScript code to Oracle CRM On Demand Disconnected Mobile
Sales and highlights some important points to consider both before and after you add the JavaScript
code. It contains the following topics:
Before Adding JavaScript Code on page 21
Adding JavaScript Code on page 27
After Adding JavaScript Code on page 36
Sending the Configuration Application Definition File to Users on page 36
Before Adding JavaScript Code
Before beginning to add JavaScript code to Oracle CRM On Demand Disconnected Mobile Sales,
review the following topics:
Using Cut and Paste on page 21
Obtaining Module ID and Field Name Information on page 22
Obtaining the Module ID on page 22
Obtaining the Module ID Using the Utility Menu on page 23
Obtaining Field Name Information on page 23
Obtaining the Module ID and Field Name in Bulk on page 23
Using Keywords in Queries on page 24
Custom Device Messages and Multiple Language Installations on page 25
Creating Device Messages on page 25
Record ID and Device Record ID on page 26
Using Cut and Paste
Code examples are included throughout this guide. When copying and pasting code into Oracle CRM
On Demand Disconnected Mobile Sales, hidden characters might be inserted that might result in the
code not executing correctly.
CAUTION: Code pasted between applications might not work in Oracle CRM On Demand
Disconnected Mobile Sales.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Before Adding JavaScript Code
22
DRAFT - Modified May 27, 2014 4:45 pm
For example, copying code from Microsoft Word and other email programs can insert hidden
characters that are not supported in the coding application. These characters can include carriage
returns, blank spaces, whitespace characters, other formatting information, and so on. You might
not be able to view these hidden characters nor receive any warnings about them, but the code does
not execute correctly.
If you are using an application to write your code, then you should do the following before using the
copy and paste feature to insert the code into Oracle CRM On Demand Disconnected Mobile Sales:
Enable the viewing of all characters and hidden characters.
Use a text-only editor such as Notepad.
Obtaining Module ID and Field Name Information
When entering JavaScript code for Oracle CRM On Demand Disconnected Mobile Sales, the Module
ID and Me Field Name are used to identify which modules and fields to perform JavaScript queries
against.
Module ID queries a parent module. You cannot query child objects in JavaScript.
If you are using the Admin Application version 7.0.14 or later, then the Module ID column is
displayed on the Module Mapping page. For more information, see Obtaining the Module ID on
page 22. If the Module ID column is not displayed on the Module Mapping page, then you are
using an earlier version of the Admin application and you must obtain the module ID using the
Utility menu. For more information, see Obtaining the Module ID Using the Utility Menu on
page 23.
Me Field Name identifies which Oracle CRM On Demand Disconnected Mobile Sales Server field
to query. For more information, see the Obtaining Field Name Information on page 23.
For more information, se Obtaining the Module ID and Field Name in Bulk on page 23.
Obtaining the Module ID
Use the following procedure to obtain the module ID for a module. This task applies only if you are
using the Admin application version 7.0.14 or later.
To obtain the module I D for a module
1 Start the Admin application.
2 Click Map Settings, then Module Settings on the vertical navigation bar.
The Module Mapping page opens showing the list of mapped modules and the corresponding
module settings configured for each module.
3 The Module ID column, which is read-only, indicates the module ID for the module.
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Before Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
23
DRAFT - Modified May 27, 2014 4:45 pm
Obtaining the Module ID Using the Utility Menu
Use the following procedure to obtain the module ID for a module using the Utility menu. This task
applies only if you are using a version of the Admin application that is prior to version 7.0.14.
To obtain the module I D using the Utility menu
1 In the Admin application, click Utility, and then click Show DB.
2 When prompted, enter your MySQL user name and password.
3 Enter the following query in to the Schema name box:
SELECT MODULEI D, MEMODULENAME, HOSTCRMMODULENAME FROM CFG_TABLEMAPPI NGI NFO
4 Click Fetch.
A list of all Module IDs is returned, including the ME module name, and the description of the
module. You can copy and paste the information into notepad or a word document and save the
information as required.
Obtaining Field Name Information
Use the following procedure to obtain the Me Field Name, which corresponds to the Oracle CRM On
Demand Disconnected Mobile Sales Server field name. This task applies only if you are using Oracle
CRM On Demand Disconnected Mobile Sales Admin application version 7.0.31 or later.
To obtain the Me Field Name
In the Admin application, click Map Settings, and then click the module whose fields you want to
see.
A module page opens showing the mapped fields for the module.
If you are using Oracle CRM On Demand Disconnected Mobile Sales Admin application version
7.0.31 or later, then the Me Field Name is displayed in the third column.
If you are using a version of the Admin application that is prior to version 7.0.31, then the
Me Field Name column might not be displayed so do the following:
Click Details next to a field to display a summary of the fields configured settings, which
includes the Me Field Name (or Oracle CRM On Demand Disconnected Mobile Sales Server
field name).
Obtaining the Module ID and Field Name in Bulk
Use the following procedure to obtain the Module ID and Me Field Name for a large number of fields
at the same time.
To obtain the module I D and field name in bulk
1 In the Admin application, click Utility, and then click Show DB.
2 When prompted, enter your MySQL user name and password.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Before Adding JavaScript Code
24
DRAFT - Modified May 27, 2014 4:45 pm
3 Enter the following query into the Schema name box:
SELECT MODULEI D, MEFI ELDNAME, HOSTCRMFI ELDNAME, BASETYPE FROM CFG_FI ELDMAPPI NGI NFO
4 Click Fetch.
A list of all Module IDs and the modules corresponding Me Field Name is returned, including the
Oracle CRM On Demand field name, and the type of field configured. You can copy and paste the
information into notepad or a word document and save the information as required.
Using Keywords in Queries
Because keywords contain consistent values, keywords are the most common fields used to query
fields within objects, except when the fields are numeric or date fields.
You must use the Keyword Item Alias to perform queries against keywords in JavaScript. The
Keyword Item Alias is the actual value written to Oracle CRM On Demand, not the value displayed to
users on the mobile device. Check the Keyword Item Alias if you plan to use a keyword to ensure
that you are using the correct values.
Date and time values are stored in the database using Unix (also known as Epoch) time. This is an
offset in seconds from 00:00:00 (UTC) on January 1, 1970. For example, when querying for the
following date: November 7, 2010 at 1:00 PM GMT, the resulting Unix time is: 1289134800. There
are Web sites available that convert Unix time to Gregorian calendar and back again. Make sure all
date and time queries are constructed in Unix time.
To view Keyword I tem Alias information in the Admin application
1 In the Admin application, click Keywords.
2 Locate the keyword that you want in the Keyword Names list.
3 Click the keyword to display its values in the Keyword Item Alias column.
The Keyword Items column shows the keyword that is displayed to the user on mobile
devices.
The Keyword Items Alias column shows the actual keyword value that is written to Oracle
CRM On Demand
The keyword value that is displayed to users (Keyword Items column) might be different to the
keyword value that is written to Oracle CRM On Demand (Keyword Items Alias column).
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Before Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
25
DRAFT - Modified May 27, 2014 4:45 pm
Custom Device Messages and Multiple Language
Installations
You can display messages to users in the Oracle CRM On Demand Disconnected Mobile Sales
application to warn them that actions cannot be performed. For example, to check that an End Date
field is greater that the Start Date, you can display a message notifying users why they cannot save
the record. You must use the mel t : / / ShowAl er t : function to display a message to users, for
example, as follows:
{ wi ndow. l ocat i on = " mel t : / / showAl er t : End Dat e must be gr eat er t han St ar t Dat e" ; }
Displaying a message in this way is acceptable, but it means that this message is only editable by
going into the JavaScript code for a module, locating the message and changing it. It also means
that this message is displayed, regardless of the language that is installed on the mobile device.
Instead of embedding messages directly into the code, you can configure the code to display a device
message instead. Device messages are stored in the same location in the Admin application, and you
can change the device messages by switching the Oracle CRM On Demand Disconnected Mobile Sales
Admin application to another language (using the Manage Config feature), and then editing or
translating the message. In this way, you can set up a different message for each language that is
installed.
To use a custom device message, you must place a dollar sign ($) after the show alert command,
followed by the name of the device message that you want to display, for example, as follows:
{ wi ndow. l ocat i on = " mel t : / / showAl er t : $devi ce. message. name" ; }
Using this format, you can name the message as follows:
{ wi ndow. l ocat i on = " mel t : / / showAl er t : $cust om. end. gr eat er . t han. st ar t " ; }
And then create a custom device message named cust om. end. gr eat er . t han. st ar t that is called
from the JavaScript code. You can name the device message using letters, numbers, or the period
symbol (.) in the device message string. Spaces are not allowed in the message name. Precede all
custom messages with the cust om. prefix, so that they are easy to locate in the Admin Application.
When using multiple language installations, each piece of code must be consistent for all languages.
You cannot have one piece of code for an English user and another for a Spanish user.
For keyword fields, Oracle CRM On Demand Disconnected Mobile Sales uses the underlying value
written to Oracle CRM On Demand. If your installation uses Language Independent Codes for
keywords so that the actual value written to Oracle CRM On Demand is the same for all languages
regardless of the display label on mobile devices, then the code works for all languages. However, if
each language has a different Keyword Alias being written to Oracle CRM On Demand, then you have
to code multiple OR queries to configure every language value.
Creating Device Messages
The following procedure shows you how to create a custom device message. Custom device
messages must be configured in each language that is installed or supported by Oracle CRM On
Demand Disconnected Mobile Sales.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Before Adding JavaScript Code
26
DRAFT - Modified May 27, 2014 4:45 pm
To create device messages
1 Start the Admin application.
2 Click Administrator, then Device Messages on the vertical navigation bar.
The Device Message Information page opens with the information shown in the following table.
3 To create a new device message, click New, and then do the following:
a Enter the name of the device message in the Message Key field. For example:
cust om. end. gr eat er . t han. st ar t .
b Enter the message to be displayed in the Message field, and then click Save.
For more information about device messages, see 1491682.1 (Article ID) Oracle CRM On Demand
Disconnected Mobile Sales Administration Guide on My Oracle Support.
Record ID and Device Record ID
Each record in the Oracle CRM On Demand Disconnected Mobile Sales client application has an Oracle
CRM On Demand record ID (uid) field as well as an Oracle CRM On Demand Disconnected Mobile
Sales device record ID (devicerowid) field.
When a record is created in the Oracle CRM On Demand Disconnected Mobile Sales client application
and the record has not been synchronized with Oracle CRM On Demand, then the record is assigned
a temporary record ID. In such a case, the uid field as well as the device Rowid field is identical.
After the record is synchronized with Oracle CRM On Demand and Oracle CRM On Demand has
assigned a record ID to the record, the uid field updates with the Oracle CRM On Demand record ID,
while the devicerowid continues to hold the temporary record ID.
If a record is created in Oracle CRM On Demand, then it does not have a device rowid value and
contains only a uid value.
The following example uses the Select action to retrieve the uid and the devicerowid fields for a
record, and the Update action to update a custom field (CONTTXT05) with the devicerowid:
f unct i on onSaveJ SON( ) { r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " updat eCRMODDevi ceRowI d\ " , \ " par amet er s\ " : [ {\ "
modul ef i el ds\ " : [ { \ " modul e\ " : \ " 2\ " , \ " f i el ds\ " : \ " ui d, devi cer owi d\ " } ] ,
\ " f i l t er \ " : \ " 2. ui d=$2. ui d\ " } ] } ] " ; }
f unct i on updat eCRMODDevi ceRowI d( r ows) { var j sonscr i pt = " [ " ; i f ( r ows. l engt h > 0) {
j sonscr i pt +=" {\ " act i on\ " : \ " updat e\ " , \ " modul e\ " : \ " 2\ " , \ " ui d\ " : \ " " +r ows[ 0] . _2. ui d
+ " \ " , \ " f i el ds\ " : [ { \ " f i el d\ " : \ " CONTTXT05\ " , \ " val ue\ " : \ " " +r ows[ 0] . _2. devi cer owi d
+" \ " } ] , \ " upsync\ " : \ " yes\ " , \ " f i l t er \ " : \ " 2. ui d =" +r ows[ 0] . _2. ui d+" \ " }" ; }
j sonscr i pt += " ] " ; r et ur n j sonscr i pt ; }
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
27
DRAFT - Modified May 27, 2014 4:45 pm
Adding JavaScript Code
To use JavaScript in Oracle CRM On Demand Disconnected Mobile Sales, you must first enable
JavaScript functionality for the Oracle CRM On Demand Disconnected Mobile Sales Server, and then
add the JavaScript code to each module, field, table, or quick selector where you want to use the
JavaScript. For more information about using JavaScript in Oracle CRM On Demand Disconnected
Mobile Sales, see the following topics:
Enabling JavaScript Functionality on page 27
Adding JavaScript Code to Modules on page 28
Adding JavaScript Code to Fields on page 29
Adding JavaScript Code to Quick Selectors on page 30
Adding JavaScript Code to Tables on page 31
Adding JavaScript Code to Buttons on page 32
Configuring Shared JavaScript Libraries on page 34
Uploading a JavaScript Library to the Server on page 35
Enabling JavaScript Functionality
If there is no JavaScript icon available on the Module Mapping page in the Admin application, then
this indicates that JavaScript functionality has not been enabled for the Oracle CRM On Demand
Disconnected Mobile Sales Server. Use the following procedure to enable JavaScript functionality for
Oracle CRM On Demand Disconnected Mobile Sales.
To enable J avaScript functionality
1 Start the Admin application.
2 Click Administrator, then click System Keys on the vertical navigation bar.
3 On the System Key Information page that opens, go to page 2, and set the following key to Yes:
i s. vi si bl e. j s. f unct i onal i t y
Yes is the default value for the i s. vi si bl e. j s. f unct i onal i t y system key. When you disable
JavaScript functionality (by setting this system key to No), any existing JavaScript functions that
have already been configured for modules are also disabled.
4 Click Update to save the changes.
5 Click Map Settings, then Module Settings on the vertical navigation bar.
On the Module Mapping page that opens, the JavaScript icon is available next to the Conditional
Icon Details. The JavaScript icon indicates that you can configure JavaScript functions for
modules.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
28
DRAFT - Modified May 27, 2014 4:45 pm
Adding JavaScript Code to Modules
You can add JavaScript code to individual modules using the JavaScript icon in the Admin application.
To add J avaScript code to a module
1 Start the Admin application.
2 Click Map Settings, and then click Module Settings on the vertical navigation bar.
The Module Mapping page opens showing the existing list of mapped modules and the module
settings configured for each module. There are a number of icons next to each module, one of
which is the JavaScript icon.
3 Click More next to the module that you want to add the JavaScript code to, select JavaScript, and
then select Add JavaScript code.
4 In the dialog box that opens, enter the following information:
a Type. Select the type of code that you want to add from the Type drop-down list. Each type
corresponds to a particular context that exposes one or more events. For more information about
the type of code that you can add to modules, see Table 7.
b Expression. Enter the JavaScript code into the Expression box.
Note that the event handlers must be the first methods mentioned in the inline JavaScript
code in the Expression input box, because the first methods are automatically registered as
the event handlers. Any event handlers that are stored in libraries are not called.
5 Click Save, and then click Close.
Table 7 describes the different code types that you can add to modules and the events that are
available for each module code type.
Table 7. Module Code Type and Available Events
Module Code Type Description Available Events
onDelete The onDelete event executes when a
user tries to delete a record on a
mobile device by selecting delete.
fieldsOnDelete and onDelete
onCancel The onCancel event executes when a
user enters a new record on a mobile
device, and then selects Cancel.
fieldsOnCancel and onCancel
onCreate The onCreate event executes when the
New or plus icon is selected to, for
example, create a new record in the
Oracle CRM On Demand Disconnected
Mobile Sales application.
fieldsOnDefault and
getDefaultValueOfMEFIELDNAME
onCreateJSON
onOpen The onOpen event executes when the
Quick Selector is selected.
fieldsOnDefault and
getDefaultValueOfMEFIELDNAME
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
29
DRAFT - Modified May 27, 2014 4:45 pm
Adding JavaScript Code to Fields
You can add JavaScript code to individual fields using the fields Edit icon in the Admin application,
and then the Field Condition input box. Field conditions can be used when a selector is being opened
for a field. The supported event handlers in this context are:
conditionQueryJSON
excludeFromPreLoad
fieldsOnConditionQuery and conditionQuery
NOTE: These events are paired and must be used together.
fieldsOnFilter and onFilter
NOTE: These events are paired and must be used together.
onSave The onSave event executes when Save
is selected to save either a new record
that is being created or an existing
record that is being updated.
fieldsOnPreSave and onPreSave
fieldsOnDefault and
getDefaultValueOfMEFIELDNAME
fieldsOnSave and onSave
onPreSaveJSON
onSaveJSON
onSave
(for Appointment
and Activity only)
In addition to the available onSave
events, Appointment and Activity also
support events that are specific to
collecting, signing, and submitting
calls.
doneSignature
onAcceptAndSign
onSubmitCall
onEdit The onEdit event executes when a
user Selects Edit to modify a record.
onEditJSON
CustomActions The CustomActions event executes
when a customized action in the
Oracle CRM On Demand Disconnected
Mobile Sales application is selected.
Configuring JavaScript code as a
custom action adds an icon next to the
Edit button in your Oracle CRM On
Demand Disconnected Mobile Sales
application. Selecting CustomActions
displays a drop-down menu, from
which the user can choose an action
(or piece of code) to execute.
onActionJSON
Table 7. Module Code Type and Available Events
Module Code Type Description Available Events
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
30
DRAFT - Modified May 27, 2014 4:45 pm
To add J avaScript code to fields
1 Start the Admin application.
2 Click Map Settings on the vertical navigation bar, and then click the module whose fields you want
to modify.
3 Click Edit next to the field where you want to add the JavaScript code.
4 In the Field Condition input box, enter the JavaScript code.
Note that the event handlers must be the first methods mentioned in the inline JavaScript code
in the Field Condition input box because the first methods are automatically registered as the
event handlers. Any event handlers that are stored in libraries are not called.
5 Click Submit, and then Close.
For more information about JavaScript and field conditions, see Chapter 6, Using JavaScript Code to
Filter Information in Oracle CRM On Demand Disconnected Mobile Sales.
Adding JavaScript Code to Quick Selectors
You can add JavaScript code to individual quick selectors using the Add button on the Quick Selector
page in the Admin application. You can configure filters of type Required or Validate for quick
selectors. The supported event handlers are shown in Table 8 on page 31.
To add J avaScript code to quick selectors
1 Start the Admin application.
2 Click Quick Selector on the vertical navigation bar, and then click the quick selector that you want
to modify.
3 Click the Add button under the Filters list.
4 In the dialog box that opens, enter the following information.
a Type. Quick selector currently supports two contexts for JavaScript: Required or Validate.
Select Required to configure conditions, exclusions, and filters for the quick selector.
Select Validate to configure a Validate button for the quick selector.
For more information about the types of quick selector filters, see Table 8 on page 31.
b Label. This is a text field. Enter a label describing the purpose of your configuration.
c Expression. Enter the JavaScript code in the Expression input box.
Note that the event handlers must be the first methods mentioned in the inline JavaScript
code in the Expression input box because the first methods are automatically registered as
the event handlers. Any event handlers that are stored in libraries are not called.
5 Click Save.
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
31
DRAFT - Modified May 27, 2014 4:45 pm
Table 8 describes the filters that you can configure for quick selectors and shows the supported event
handlers.
For more information about JavaScript and quick selectors, see Chapter 6, Using JavaScript Code to
Filter Information in Oracle CRM On Demand Disconnected Mobile Sales.
Adding JavaScript Code to Tables
You can add JavaScript to tables using the Add button on the Table Display page in the Admin
application. You can configure table filters of type Required only. The supported event handlers in
this context are shown in Table 9 on page 32.
To add J avaScript to tables
1 Start the Admin application.
2 Click Table Display on the vertical navigation bar, and then click the table that you want to modify.
The Table Display page opens showing the filters (if there are any) and columns that are
configured for the table.
3 Click the Add button under the Filters list.
4 In the dialog box that opens, enter the following information.
a Type. Table supports JavaScript of type Required only. For more information about the Required
filter context, see Table 9.
b Label. This is a text field. Enter a label that describes the purpose of your configuration.
Table 8. Quick Selectors: Supported Event Handlers
Quick Selector Filter Type Description Available Events
Required The Required context is typically used
when the quick selector list is loaded
to identify and modify the set of
records available in the quick selector
list.
You can use the Required context to
configure conditions, exclusions, and
filters for the quick selector list.
conditionQueryJSON
excludeFromPreload
fieldsOnConditionQuery
and conditionQuery
fieldsOnFilter and onFilter
Validate The Validate context is typically used
when the Validate button is selected in
a quick selector list.
You can use the Validate context to
configure a Validate button for the
quick selector list.
onValidateJSON
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
32
DRAFT - Modified May 27, 2014 4:45 pm
c Expression. Enter the JavaScript code in the Expression input box.
Note that the event handlers must be the first methods mentioned in the inline JavaScript
code in the Expression input box because the first methods are automatically registered as
the event handlers. Any event handlers that are stored in libraries are not called.
5 Click Save.
Table 9 describes the filter that you can configure for tables and shows the supported event handlers.
For more information about JavaScript and table displays, see Chapter 6, Using JavaScript Code to
Filter Information in Oracle CRM On Demand Disconnected Mobile Sales.
Adding JavaScript Code to Buttons
You can add JavaScript to a modules quick action buttons in the Admin application. You can also add
JavaScript to Custom Action buttons. For more information, see Adding JavaScript Code to Modules
on page 28.
To add J avaScript code to quick action buttons
1 Start the Admin application.
2 Click Map settings on the vertical navigation bar, and then click Module Settings.
3 Click More next to a module whose quick action buttons you want to modify, and then click Quick
Action.
The Quick Action Configuration page opens showing the quick actions and the external
application configurations that are already defined. You can add JavaScript for the following
contexts:
External App Configuration context. For more information, see Adding JavaScript Code
for External Application Configuration on page 33.
Detailer button context. For more information, see Adding JavaScript Code to the Detailer
Button on page 33.
Table 9. Table Filters: Supported Event Handlers
Table Display Filter Type Description Available Events
Required The Required context is typically used
when the table is loaded to identify
and modify the set of records available
in table.
You can use the Required context to
configure conditions, exclusions, and
filters for the table.
conditionQueryJSON
excludeFromPreload
fieldsOnConditionQuery
and conditionQuery
fieldsOnFilter and onFilter
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
33
DRAFT - Modified May 27, 2014 4:45 pm
Adding JavaScript Code for External Application Configuration
The following procedure shows you how to add JavaScript code to configure a button for an external
application.
To add J avaScript code to configure a button for an external application
1 Start the Admin application.
2 Click Map settings on the vertical navigation bar, and then click Module Settings.
3 Click More next to a module, and then click Quick Action.
4 On the Quick Action Configuration page that opens, click either Add under External App
Configuration or Edit next to an existing definition in the External App Configuration list.
5 In the dialog box that opens, enter the following information.
NOTE: When adding JavaScript code for external application event handlers, only the following
fields are used: Display Value and Expression.
a Display Value. This is a text field. Enter a label for the button.
b Expression. Enter the JavaScript code in the Expression input box.
Note that the event handlers must be the first methods mentioned in the inline JavaScript
code in the Expression input box because the first methods are automatically registered as
the event handlers. Any event handlers that are stored in libraries are not called.
6 Click Save, and then click Submit Order Changes.
Adding JavaScript Code to the Detailer Button
The following procedure shows you how to add JavaScript code to configure the Detailer button.
NOTE: The Detailer button is only available for Activities and Appointments in Oracle CRM On
Demand Disconnected Mobile Sales.
To add J avaScript code to the Detailer button
1 Start the Admin application.
2 Click Map settings on the vertical navigation bar, and then click Module Settings.
3 Click More next to a module, and then click Quick Action.
4 On the Quick Action Configuration page that opens, click either Add under Quick Action Button
Configuration or the Edit Button next to an existing definition in the Quick Action Button
Configuration list.
5 In the dialog box that opens, enter the following information.
a Name. Enter Detailer.
b Action. Select Detailer from the Action drop-down list.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
34
DRAFT - Modified May 27, 2014 4:45 pm
c Expression. Enter the JavaScript code in the Expression input box.
Note that the event handlers must be the first methods mentioned in the inline JavaScript
code in the Expression input box because the first methods are automatically registered as
the event handlers. Any event handlers that are stored in libraries are not called.
6 Click Save, and then click Submit Order Changes.
Table 10 describes the filters that you can configure for quick action buttons and shows the supported
event handlers.
For more information about JavaScript and buttons, see Chapter 7, Using JavaScript to Invoke Actions
in Oracle CRM On Demand Disconnected Mobile Sales.
Configuring Shared JavaScript Libraries
You can take all existing scripts of significant size and complexity and put them into a JavaScript
library. You can put the library into script files, and replace any existing inline blocks of code with
calls to the library. For example, the Activity OnSave JavaScript file might change to something like
the following:
<scr i pt t ype=" t ext / j avascr i pt " l anguage=" j avascr i pt " sr c=" Exampl eAct i vi t y. j s" ></
scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onSave ( )
{
r et ur n oAct i vi t yHandl er . onSave ( " Act i vi t y" / ** vs. At t endee Cal l **/ ,
" Sampl eDr op| Pr omoI t em| Pr oduct Det ai l ed" / ** r equi r es si gnat ur e **/ ,
" Sampl eRequest " / ** does not r equi r e si gnat ur e **/ ,
. . . any ot her opt i ons t hat mer i t Or acl e QA suppor t . . . ) ;
}
</ scr i pt >
Table 10. Quick Action Buttons: Supported Event Handlers
Quick Selector Filter Type Description Available Events
Open External Application The external application is called by the
defined Open External Application button,
which constructs the URL to invoke for the
external application. If the event handler is
present, other settings such as the
application URL (App URL) and application
command (App Command) are ignored.
openExternalApp
Detailer The detailer context is typically used to
provide a selector for the set of messaging
plans that are available for detailing.
conditionQueryJSON
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales
Adding JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
35
DRAFT - Modified May 27, 2014 4:45 pm
Using JavaScript libraries allows you to eliminate code duplication and build JavaScript unit tests. If
you decide to use JavaScript libraries, then note the following:
You can enter scripts into the Oracle CRM On Demand Disconnected Mobile Sales Server. For
more information, see Uploading a JavaScript Library to the Server on page 35.
You must keep the Event Handler within inline event scripts rather than the .js file.
You must change the script header to reference the specific library as follows:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " l anguage=" j avascr i pt " sr c=" cal l sampl edr op. j s" ></
scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
</ scr i pt ></ head><body></ body></ ht ml >
where:
sr c is the location of the script library, relative to the subfolder
t ype is always equal to t ext / j avascr i pt
l anguage is always equal to j avascr i pt
Uploading a JavaScript Library to the Server
The following procedure shows you how to upload a JavaScript library to the Oracle CRM On Demand
Disconnected Mobile Sales Server. Only .j s files are supported.
To upload a scripts library to the Oracle CRM On Demand Disconnected Mobile Sales
Server
1 Start the Admin application.
2 Click Administrator on the vertical application bar, and then select import JS.
3 Select one of the following options:
Upload to existing subfolder. Note that you cannot update the Oracle CRM On Demand
Disconnected Mobile Sales subfolder from the UI. Updates to the directory structure must be
included in the war file, or added manually.
Create new subfolder. For a single port configuration, the subfolder is located inside the
following patch:
~\ webapps\ [ Cont ext name] \ i mages\ MESvr Account I d\ J SLi b
For a split port configuration, the subfolder is located inside the following patch:
~\ webapps\ [ Cont ext name] \ consol e\ [ Cont ext name] \ i mages\ MESvr Account I d\ J SLi b
4 Select a folder from the Select folder drop-down list.
5 Click Choose File to browse to the location of the library file on your local drive.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Adding JavaScript Code to Oracle CRM On Demand Disconnected Mobile Sales After
Adding JavaScript Code
36
DRAFT - Modified May 27, 2014 4:45 pm
6 Click Upload.
Script files that you upload overwrite the existing files on the server, and there is currently no
support for removing a script.
After Adding JavaScript Code
After you add and save JavaScript code for Oracle CRM On Demand Disconnected Mobile Sales, note
the following:
The JavaScript code is available to any user who receives a new Configuration Application
Definition (CAD) file. Even if you have only partially entered the JavaScript code, that code is
sent to users as part of the new CAD file.
The CAD file is automatically transmitted when activating a mobile device for the first time only.
However, administrators can manually transmit the latest CAD file to users as and when required.
For more information, see Sending the Configuration Application Definition File to Users on
page 36.
All JavaScript code is stored in the application configuration files, so if you are running multiple
servers and importing scripts from or exporting scripts to another server, then all JavaScript code
is transferred to the new server.
After JavaScript code has been configured and tested, copy the code and document what the
code does so that other users can use and change the code, if required.
Sending the Configuration Application
Definition File to Users
If JavaScript code or a particular device message is created or changed, then you must send the
updated CAD file to users so that the update is visible on mobile devices. It is not necessary to reload
data onto user devices.
To send the CAD to users
1 Click Users on the vertical navigation bar in the Admin application.
2 Select the check box next to each user to whom you want to send the latest configuration data.
3 Click Push To Device, CAD, and then click Yes when prompted for confirmation to rebuild and send
the CAD data.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
37
DRAFT - Modified May 27, 2014 4:45 pm
4 JavaScript Structure Used in
Oracle CRM On Demand
Disconnected Mobile Sales
This chapter describes the JavaScript structure used in Oracle CRM On Demand Disconnected Mobile
Sales. It includes the following topics:
Overview of JavaScript Structure on page 37
HTML Header on page 38
JavaScript Inclusions on page 38
JavaScript Body on page 38
HTML Footer on page 42
Overview of JavaScript Structure
This topic introduces the JavaScript structure that is common to all basic queries that are conducted.
Each piece of JavaScript code usually contains the following components.
HTML Header. For more information, see HTML Header on page 38.
JavaScript Inclusions. (Optional) You can add one or more JavaScript inclusions to the
JavaScript code. For more information, see JavaScript Inclusions on page 38.
JavaScript Body. All event handlers must be located within the JavaScript body. For more
information, see JavaScript Body on page 38.
HTML Footer. For more information, see HTML Footer on page 42.
The following example checks to see whether the end time is greater than the start time. This
example is used throughout this chapter to analyze the structure of JavaScript queries.
<ht ml ><head><t i t l e>Exampl e</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnPr eSave( ) { r et ur n " t hi s. CUSTDT01, t hi s. CUSTDT02" ; }
f unct i on onPr eSave( st ar t t i me, endt i me) {
i f ( endt i me > st ar t t i me ) {
r et ur n t r ue;
}el se{
wi ndow. l ocat i on = DMS. showAl er t ( End t i me must be gr eat er t han st ar t t i me" ) ;
r et ur n f al se;
}
}</ scr i pt ></ head><body></ Body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
JavaScript Structure Used in Oracle CRM On Demand Disconnected Mobile Sales
HTML Header
38
DRAFT - Modified May 27, 2014 4:45 pm
HTML Header
All JavaScript code must be embedded within an HTML page, which starts with an HTML header and
ends with an HTML footer. The HTML header is as follows:
<ht ml ><head><t i t l e>Exampl e</ t i t l e>
The HTML header must be included at the start of all JavaScript code, but you can modify the text
between the <t i t l e></ t i t l e> tags as required. In the previous example header, the name of the
JavaScript code is Example. For more information about the HTML footer, see HTML Footer on
page 42.
JavaScript Inclusions
JavaScript inclusions are optional in JavaScript code. You can add one or more JavaScript inclusions
to the JavaScript code.
JavaScript code can reference functions and variables which are defined in .js files in a JavaScript
library. To reference a JavaScript library, you must use the following script tag:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
The referenced JavaScript library in this example is the Oracle CRM On Demand Disconnected Mobile
Sales library (DMS.js), which is distributed by Oracle. The DMS.js library is used to provide the
DMS.showAlert function in the example shown in Overview of JavaScript Structure on page 37.
Related Topics
Configuring Shared JavaScript Libraries on page 34
Using the DMS.js JavaScript Library on page 115
JavaScript Body
The JavaScript body is mandatory. Oracle CRM On Demand Disconnected Mobile Sales registers event
handlers by detecting their presence in the body of the JavaScript code. All event handlers must be
located within the JavaScript body.
The JavaScript body uses the following script tag structure:
<scr i pt t ype=" t ext / j avascr i pt " >
/ ** Your event handl er s go i nsi de t he scr i pt t ag **/
</ scr i pt >
There must be exactly one JavaScript body and it must have the following type:
scr i pt t ype=" t ext / j avascr i pt "
The code within the JavaScript body must conform to the normal JavaScript rules for an HTML page
with no visible body content. You can use window.location in limited circumstances (for more
information, see showAlert in the example shown in Overview of JavaScript Structure on page 37),
but the HTML page structure should not be used.
JavaScript Structure Used in Oracle CRM On Demand Disconnected Mobile Sales
JavaScript Body
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
39
DRAFT - Modified May 27, 2014 4:45 pm
To facilitate registration, all event handlers must be defined at the start of the JavaScript body.
Thereafter, you can add any valid JavaScript code as required. It is important to adhere to the
JavaScript rules for variable and function declaration. You can use the following types of event
handlers in JavaScript code:
fieldsOnEvent and onEvent handlers. For more information, see Event Handlers:
fieldsOnEvent and onEvent on page 39.
eventJSON handlers. For more information, see Event Handlers: eventJSON on page 41.
Standard handlers. For more information, see Event Handlers: Standard Handlers on page 42.
Event Handlers: fieldsOnEvent and onEvent
The fieldsOnEvent and onEvent handlers use two event handlers to process the event. The
fieldsOnEvent handler declares the set of data that is to be retrieved and passed in to the onEvent
handler. The onEvent handler processes the data and returns the result.
The fieldsOnEvent and onEvent handlers include the following:
fieldsOnCancel and onCancel
fieldsOnDelete and onDelete
fieldsOnPreSave and onPreSave
fieldsOnSave and onSave
fieldsOnConditionQuery and onConditionQuery
fieldsOnFilter and onFilter
fieldsOnDefault and getDefaultValueOfMEFIELDNAME
In the following example code, the onPreSave function is run using the fieldsOnPreSave function
command, and the action is performed before the file is saved. After the function is defined, a return
command, which is inside the braces {}, lists the fields that are to be read:
f unct i on f i el dsOnPr eSave( ) { r et ur n " t hi s. CUSTDT01, t hi s. CUSTDT02" ; }
In analyzing the return command inside the braces {}, note the following:
When reading fields, the return command is always used and the returned fields are included
within quotation marks, followed by a semicolon.
Each field read is separated by a comma.
Fields read are identified using MODULEID.MEFIELDNAME. In this example, the module ID is
replaced with "this" because the fields are contained within the current module. But if reading
fields from a parent, then the module ID of the parent object would be used. For more
information about identifying Module ID and ME Field Name, see Obtaining Module ID and Field
Name Information on page 22.
The CUSTDT01 field stores the start time.
The CUSTDT02 field stores the end time.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
JavaScript Structure Used in Oracle CRM On Demand Disconnected Mobile Sales
JavaScript Body
40
DRAFT - Modified May 27, 2014 4:45 pm
Upon receipt of the field list defined by the fieldsOnEvent handler, the application looks up the
specified field values and calls the onEvent handler with the values passed in as parameters.
In the following example code, fields are not being updated. The onPreSave function is giving the
fields a nickname (or alias), which is used in conditional queries. Because field names might be
difficult to remember, giving a field a descriptive name makes it easier when creating code and also
ensures that others reading the code can understand the query being performed.
Field names are defined in the order that they are read. In the previous example, the CUSTDT01
(Start Time) field was read first followed by the CUSTDT02 (End Time) field. In the following
example, the fields are given the (alias) names starttime and endtime:
f unct i on onPr eSave( st ar t t i me, endt i me)
Thereafter, the onEvent handler is free to process the data as it sees fit. It is important for the
onEvent handler to return the value type that is expected by the event handler. This varies by event.
Failure to return the correct type results in errors.
The IF command in the following example indicates to perform one action if a condition is met, and
another two actions if the condition is not met.
f unct i on onPr eSave( st ar t t i me, endt i me) {
i f ( endt i me > st ar t t i me ) {
r et ur n t r ue;
}el se{
wi ndow. l ocat i on = DMS. showAl er t ( " End t i me must be gr eat er t han st ar t t i me" ) ;
r et ur n f al se;
}
In this example, the end time is checked to see whether it is greater than the start time. If it is, then
the record is saved. However, if it not, then two actions are performed as follows:
A message is displayed to indicate why the record has not been saved.
The user is returned to the record entry screen without saving the record.
With an IF statement, if the condition is met, then the first action is executed. Returning a True value
in an onPreSave conditional query allows you to save a record, so immediately after the conditional
query, the action { r et ur n t r ue; } is inserted. If the condition is not met, then an else parameter
defines what happens as follows:
If the condition is met return a true value, otherwise do the following. . .
In this example, two actions are performed if the condition is not met as follows: (1) a message is
displayed to the user and (2) a False value is returned, which prevents a record from being saved in
an onPresave conditional query. Both actions are contained within the same braces {}, and both
actions are separated by a semicolon. The DMS.showAlert function displays a message within a
window, which the user must close, and the function is followed by the False value (r et ur n f al se; ).
The event handler is closed with another right brace}.
JavaScript Structure Used in Oracle CRM On Demand Disconnected Mobile Sales
JavaScript Body
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
41
DRAFT - Modified May 27, 2014 4:45 pm
Event Handlers: eventJSON
The JSON event handlers register and activate independently. Unlike the fieldsOnEvent and onEvent
handlers, JSON event handlers use actions to retrieve data for processing and return results. For
more information about action processing, see JavaScript Object Notation Actions on page 98 and
the DMS.action Function on page 121.
The set of actions available to each JSON event handler varies by event.
The JSON event handlers include the following:
onActionJSON
conditionQueryJSON
onEditJSON
onCreateJSON
onPreSaveJSON
onSaveJSON
onAcceptAndSign
doneSignature
onSubmitCall
onValidateJSON
Success and Error Codes
The JSON event handlers allow you to include code at the end of each invoked function to handle
error codes and display a message to the end user as required. If an error occurs, then the
onErrorInvoke function is invoked immediately. The error message contains information regarding
the error.
The typical format of an error invoke function is as follows:
f unct i on onEr r or I nvoke( r ows) {
Each row contains the error code and the error message.
If an Insert or an Update action is performed, then a message is returned according to the success
or failure of the action is as follows:
If the Insert or Update action is successful, then the following is returned:
J avaScr i pt er r or code 0 i s r et ur ned
If the Update or Insert action fails, then one of the following error codes is returned:
101 - The SQL query is invalid. This error might be due to incorrect field names being
used. The error message returned is sent from the database and indicates the location where
the problem occurred.
102 - Insert action was unsuccessful. The error message returned is sent from the
database and indicates the location where the problem occurred.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
JavaScript Structure Used in Oracle CRM On Demand Disconnected Mobile Sales
HTML Footer
42
DRAFT - Modified May 27, 2014 4:45 pm
103 - Invalid action. This error message is returned if an action other than those actions
that are defined is entered or mistyped.
104 - JSON is invalid. This error message indicates that there is a problem with the code,
some of the functions in the code, or with parenthesis. The function in which the error occurs,
is also returned.
The following example code shows how an error code is handled in a function. It is assumed that this
code is entered at the end of an invoked function, which returns multiple rows as part of a dataset.
f unct i on onEr r or I nvoke( r ows) {
i f ( r ows. l engt h > 0) {
wi ndow. l ocat i on=" mel t : / / showAl er t : " + r ows[ 0] . message;
}
}
This example states that if an error occurs, as long as the error does not relate to a blank row (no
action performed), then display the message for the current row to the user.
Adding the following code to the invoked function returns r ow1 dataset, and displays any errors if
there are any:
f unct i on onEr r or I nvoke( r ow1) {
wi ndow. l ocat i on=" mel t : / / showAl er t : " + r ow1. message;
}
Event Handlers: Standard Handlers
Similar to the JSON event handlers, standard event handlers register and activate independently.
Unlike other handlers, standard handlers pass in a fixed set of parameters. The parameters and
return values vary by event.
The standard handlers include the following:
openExternalApp
excludeFromPreload
HTML Footer
All JavaScript functions or code must contain a header and footer to indicate where the code begins
and ends. The code must be written between valid HTML header and footer tags. The HTML footer is
as follows:
</ head><body></ body></ ht ml >
For more information about the HTML header, see HTML Header on page 38.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
43
DRAFT - Modified May 27, 2014 4:45 pm
5 Using JavaScript Code to Modify
Records in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter describes how use the onDelete, onCancel, onCreate, onSave, and onPreSave
JavaScript functions to modify records in Oracle CRM On Demand Disconnected Mobile Sales. It
includes the following topics:
Function onDelete in JavaScript Code on page 43
Function onCancel in JavaScript Code on page 48
Function onCreate in JavaScript Code on page 50
Function OnEdit in JavaScript Code on page 57
Function onOpen in JavaScript Code on page 58
Functions onSave and onPreSave in JavaScript Code on page 61
Function onDelete in JavaScript Code
You can configure the onDelete function to execute whenever a user tries to delete a record on a
device. The onDelete function is typically used to restrict records from being deleted on a device. For
example, to prevent users from deleting open activities on a device. You can also use onDelete to
control the record deletion on a device by using a value in a parent record. For example, if there is
a locked field set to Yes or No to indicate whether an account is locked or not, then you can perform
a check to only allow contacts to be deleted if the parent account has a locked status of No. For more
information about the structure of JavaScript code, see Chapter 4, JavaScript Structure Used in Oracle
CRM On Demand Disconnected Mobile Sales.
JavaScript onDelete Functions
The onDelete functions include the following:
fieldsOnDelete. Defines the fields against which a query is performed.
onDelete. Defines an action by executing, for example, an IF query and returning either a True
or False value. Returning True allows record deletion, but returning False prevents record
deletion.
showAlert. Similar to a callback function, showAlert displays a message to users on their device.
You can also use showAlert within an onDelete query to inform users why a record cannot be
deleted. You can embed the message or use custom device messages. For more information, see
Custom Device Messages and Multiple Language Installations on page 25.
OnDeleteJSON. For more information, see The onDeleteJSON Function on page 47.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onDelete in JavaScript Code
44
DRAFT - Modified May 27, 2014 4:45 pm
Defining a Query in the onDelete Function
The following procedure shows you how to define a query in onDelete, which involves defining what
you want to query or check, and what you want to happen as a result of running the query.
To define a query in the onDelete function
1 Define which field to use in the query (for example, CUSTKW02).
2 Check if the field, CUSTKW02 in this case, contains the value Open.
3 If the condition in Step 2 is met, then display a message and return a False value.
Record deletion is not allowed in this case.
4 If the condition in Step 2 is not met, then return a True value.
Record deletion is allowed in this case.
JavaScript onDelete Function Example 1: Checking a
Single Condition
This example shows you how to prevent an activity from being deleted when the activity status is
set to open. A message is displayed to users indicating why the activity cannot be deleted. In this
example, note the following:
Only a single field is queried and that field is within the object that is not being deleted, so it is
not necessary to get the parent module ID (MODULEID) or to obtain the status field ID
(MEFIELDNAME). For more information, see Obtaining Module ID and Field Name Information on
page 22.
The status is a Keyword, so the Keyword Item Alias value must be obtained. Keyword and
Keyword Item Alias are used for all queries. For more information, see Using Keywords in
Queries on page 24.
MEFIELDNAME is equal to CUSTKW02.
The Keyword Item Alias that is being checked is equal to Open.
The typical structure of an onDelete query, which checks a single condition, is as follows:
f unct i on f i el dsOnDel et e( ) {
r et ur n " MEFI ELDNAME" ;
}
f unct i on onDel et e( f i el d1) {
i f ( f i el d1 == ' f i el d val ue' ) {
wi ndow. l ocat i on = " MELT: / / showAl er t : Message t o di spl ay" ;
r et ur n f al se;
}el se{
r et ur n t r ue;
}
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onDelete in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
45
DRAFT - Modified May 27, 2014 4:45 pm
An example of a complete onDelete query with header and footer information, which checks a single
condition, is as follows:
<ht ml ><head><t i t l e>OnDel et eExampl e1</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDel et e( ) {
r et ur n " CUSTKW02" ;
}
f unct i on onDel et e( st at us) {
i f ( st at us == ' Open' ) {
wi ndow. l ocat i on = " MELT: / / showAl er t : You cannot del et e open Act i vi t i es" ;
r et ur n f al se;
}el se{
r et ur n t r ue;
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f unct i on f i el dsOnDel et e( ) { r et ur n " MEFI ELDNAME" ; } defines which field to read. To read the
value stored in the CUSTKW02 field, the following is defined in onDelete example 1:
f i el dsOnDel et e( ) { r et ur n " CUSTKW02" ; }
f unct i on onDel et e( f i el d1) indicates to run a query against the field that is just read, and
allows you to name the field by inserting a value inside the brackets. You can use the actual field
name (CUSTKW02) or something more memorable like st at us. The code in onDelete example 1
is as follows:
f unct i on onDel et e( st at us)
The conditional query begins with a left brace {followed by the i f ( f i el d1 == ' f i el d val ue' )
condition to define what to check. To check whether the status field that was just named contains
the value Open, the code in onDelete example 1 is as follows:
i f ( st at us == ' Open' )
{wi ndow. l ocat i on = " MELT: / / showAl er t : Message t o di spl ay" ; r et ur n f al se; } defines what
happens if the previous condition is met using the code. According to the code, a message is
displayed and a False value is returned preventing the record from being deleted. To define which
message to display, the code in onDelete example 1 is as follows:
{wi ndow. l ocat i on = " MELT: / / showAl er t : You cannot del et e open Act i vi t i es" ; r et ur n
f al se; }
When displaying messages, rather than embedding the message in the code, you can use a
device message. For more information, see Custom Device Messages and Multiple Language
Installations on page 25.
A right brace } defines the end of the first action. Then an else parameter determines what
happens if the conditional query is not met. In this case, returning a True value allows record
deletion. The code in onDelete example 1 is as follows:
el se{ r et ur n t r ue; }
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onDelete in JavaScript Code
46
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onDelete Function Example 2: Checking
Multiple Conditions
This example expands the query detailed in JavaScript onDelete Function Example 1: Checking a
Single Condition on page 44 by showing how to prevent open activities from being deleted if the
parent (Account) is a customer. In this case, deleting records that are open for prospects is allowed,
but not for customers. The following assumptions are made in this example:
The status is stored in the field CUSTKW02.
The status value that is being checked is Open.
The parent (Account) module ID is 2.
The Account Type field in the parent is ACCTKW01.
The value that is being checked in Account Type is Customer.
An example of a complete onDelete query, which checks multiple conditions, is as follows:
<ht ml ><head><t i t l e>OnDel et eExampl e2</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDel et e( ) {
r et ur n " CUSTKW02, 2. ACCTKW01" ;
}
f unct i on onDel et e( st at us, act t ype) {
i f ( st at us == ' Open' && acct t ype == ' Cust omer ' ) {
wi ndow. l ocat i on = " MELT: / / showAl er t : You cannot del et e open Act i vi t i es
f r omCust omer Account s" ;
r et ur n f al se;
}el se{
r et ur n t r ue;
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f unct i on f i el dsOnDel et e( ) { r et ur n " CUSTKW02" ; } is enhanced to include a second field to
check for. A comma is inserted first to indicate another field, and as that field is in a parent
module, the Module ID of the parent object must be included with a period symbol (.) separating
the module ID and field name. The code in onDelete example 2 is as follows:
f unct i on f i el dsOnDel et e( ) { r et ur n " CUSTKW02, 2. ACCTKW01" ; }
A name is given to the second fields so f unct i on onDel et e( st at us) is enhanced to include the
second field called accttype. The code in onDelete example 2 is as follows:
onDel et e( st at us, acct t ype)
i f ( st at us == ' Open' ) is enhanced to include the second parameter (does acttype include
Customer?). A double ampersand (&&) after the first line separates the two parameters. The
code in onDelete example 2 is as follows:
i f ( st at us == ' Open' && acct t ype == ' Cust omer ' )
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onDelete in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
47
DRAFT - Modified May 27, 2014 4:45 pm
The message changes from You cannot delete open Activities in onDelete example 1 to You
cannot delete open Activities from Customer Accounts in onDelete example 2.
The onDeleteJSON Function
You can use the JSON entry point called onDeleteJSON on onDelete event of a record. The
onDeleteJSON function can be used to validate before delete in case there arises a need to query for
records. The following code sample illustrates the use of the onDeleteJSON function.
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
var cal l ui d;
var act i vi t yui d;
f unct i on onDel et eJ SON( )
{
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " sel ect Par ent \ " , \ " par amet er s\ " : [ {\ " modul ef i el
ds\ " : [ {\ " modul e\ " : \ " 63\ " , \ " f i el ds\ " : \ " CUSTREF1\ "
}] , \ " f i l t er \ " : \ " 63. ui d=$63. ui d\ " }] }] " ;
}
f unct i on sel ect Par ent ( r ow1)
{
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " sel ect Gr ant Par ent \ " , \ " par amet er s\ " : [ {\ " modul
ef i el ds\ " : [ {\ " modul e\ " : \ " 62\ " , \ " f i el ds\ " : \ " CUSTREF2, CUSTREF5\ " }] , \ " f i l t er \ " : \ " 62. u
i d = " +r ow1[ 0] . _63. CUSTREF1 +" \ " }] }] " ;
}
f unct i on sel ect Gr ant Par ent ( r ow1)
{
i f ( r ow1. l engt h > 0) {
cal l ui d = r ow1[ 0] . _62. CUSTREF2;
act i vi t yui d = r ow1[ 0] . _62. CUSTREF5;
i f ( cal l ui d) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " val i dat eCondi t i on1\ " , \ " par amet er s\ " : [ {\ " modu
l ef i el ds\ " : [ {\ " modul e\ " : \ " 7\ " , \ " f i el ds\ " : \ " CLOGSTATUS\ "
}] , \ " f i l t er \ " : \ " 7. ui d=" +cal l ui d+" \ " }] }] " ;
}el se i f ( act i vi t yui d) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " val i dat eCondi t i on2\ " , \ " par amet er s\ " : [ {\ " modu
l ef i el ds\ " : [ {\ " modul e\ " : \ " 64\ " , \ " f i el ds\ " : \ " CLOGSTATUS\ "
}] , \ " f i l t er \ " : \ " 64. ui d=" +act i vi t yui d+" \ " }] }] " ;
}
}el se{
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " } ] " ;
}
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCancel in JavaScript Code
48
DRAFT - Modified May 27, 2014 4:45 pm
f unct i on val i dat eCondi t i on1( r ow)
{
var r esul t ;
r esul t = " t r ue" ;
i f ( r ow. l engt h>0) {
i f ( r ow[ 0] . _7. CLOGSTATUS == " Submi t t ed" ) {
r esul t = " f al se" ;
}}
i f ( r esul t ==" f al se" )
{wi ndow. l ocat i on = " mel t : / / showAl er t : $cant . del et e. message" ; }
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " " + r esul t + " \ " } ] " ;
}
f unct i on val i dat eCondi t i on2( r ow)
{
var r esul t ;
r esul t = " t r ue" ;
i f ( r ow. l engt h>0) {
i f ( r ow[ 0] . _64. CLOGSTATUS == " Submi t t ed" ) {
r esul t = " f al se" ;
}}
i f ( r esul t ==" f al se" )
{wi ndow. l ocat i on = " mel t : / / showAl er t : $cant . del et e. message" ; }
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " " + r esul t + " \ " } ] " ;
}
</ scr i pt >
</ head></ ht ml >
Function onCancel in JavaScript Code
The onCancel function prevents a user from cancelling record creation. The onCancel function has no
effect if a record is being edited, You typically use onCancel in conjunction with an onSave command,
in which a user is expected to complete record creation. For more information about the structure of
JavaScript code, see Chapter 4, JavaScript Structure Used in Oracle CRM On Demand Disconnected
Mobile Sales.
JavaScript onCancel Functions
The onCancel functions include the following:
fieldsOnCancel. Defines the fields against which a query is performed.
onCancel. Defines an action by executing, for example, a query and returning either a True or
False value if the condition is met. Returning True allows the user to cancel record creation, but
returning false prevents cancellation of record creation.
showAlert. Similar to a callback function, showAlert displays a message to users on their device.
You can also use showAlert within an onCancel query to inform users why record creation cannot
be cancelled. You can embed the message or use custom device messages. For more information,
see Custom Device Messages and Multiple Language Installations on page 25.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCancel in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
49
DRAFT - Modified May 27, 2014 4:45 pm
Defining a Query in the onCancel Function
The following procedure shows you how to define a query in onCancel, which involves defining what
you want to query or check, and what you want to happen as a result of running the query.
To define a query in the onCancel function
1 Define what you want to check in the query (for example, the records in module ID 7).
2 Check if other records exist, for example, by using an IF query.
3 If the condition in Step 2 is met, then display a message and return a False value.
In this case, you cannot cancel record creation.
4 If the condition in Step 2 is not met, then return a True value.
In this case, you can cancel record creation.
JavaScript onCancel Function Example
In this example, a user creates a lead, which has an activity child object. The administrator creates
an onSave action so that whenever a lead is saved, a new activity screen opens. The onCancel
function that is created prevents the user from cancelling an activity (such as a follow up call), if no
other activity exists. As a result, a lead cannot be created without an associated activity. The
following assumptions are made in this example:
The onSave code already exists, and it opens the activity object when a lead has been saved.
The activities have a Module ID of 7.
For more information about locating module IDs and field names, see Obtaining Module ID and Field
Name Information on page 22.
The typical structure of an onCancel query is as follows:
f unct i on f i el dsOnCancel ( ) {
r et ur n " modul ei d. count " ;
}
f unct i on onCancel ( count ) {
i f ( count <= 0) {
wi ndow. l ocat i on = " MELT: / / showAl er t : message t o di spl ay t o t he user " ;
r et ur n f al se;
}el se{
r et ur n t r ue;
}
}
An example of a complete onCancel query with header and footer information is as follows:
<ht ml ><head><t i t l e>onCancel </ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnCancel ( ) {
r et ur n " 7. count " ;
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
50
DRAFT - Modified May 27, 2014 4:45 pm
f unct i on onCancel ( count ) {
i f ( count <= 0) {
wi ndow. l ocat i on = " MELT: / / showAl er t : You can not cancel t hi s r ecor d, at l east one
Act i vi t y r ecor d i s r equi r ed f or t hi s Lead" ;
r et ur n f al se;
}el se{
r et ur n t r ue;
}
}</ scr i pt ></ head><body></ Body></ ht ml >
where:
f unct i on f i el dsOnCancel ( ) { r et ur n " modul ei d. count " ; } defines which module to count.
To check the number of activity modules (module ID 7) associated with the current Lead and
replace the module number with 7, the code used in the onCancel example is as follows:
f unct i on f i el dsOnCancel ( ) { r et ur n " 7. count " ; }
The command f unct i on onCancel ( count ) names the result and gives the result the name count.
The conditional query { i f ( count <=0) defines what to check for. In this case, to check if the
count (that is, the number of other activity modules) is less than or equal to zero. Because this
is the start of a conditional query, a left brace { is inserted at the beginning of the command.
If the condition is met, then two commands are performed: a message is displayed to tell the
user why the user cannot cancel record creation, and a False result is returned preventing the
user from using the Cancel button. The commands are included inside braces {}, and separated
by a semicolon in the onCancel example as follows:
{ i f ( count <= 0) { wi ndow. l ocat i on = " MELT: / / showAl er t : You can not cancel t hi s
r ecor d, at l east one Act i vi t y r ecor d i s r equi r ed f or t hi s Lead " ; r et ur n f al se; }
el se{ r et ur n t r ue; } defines what happens if the conditional query is not met (that is, when
other activities exist), and allows you to cancel creating the current activity.
A right brace } closes the conditional query, and the footer follows.
Function onCreate in JavaScript Code
The onCreate function is called whenever a user creates a new record. Several commands are
typically run to automatically populate the fields according to values that are held in the parent
object. The onCreate action is typically called when a user chooses to create a new record, and when
record creation is triggered from within onSave JavaScript code. For more information about the
structure of JavaScript code, see Chapter 4, JavaScript Structure Used in Oracle CRM On Demand
Disconnected Mobile Sales.
JavaScript onCreate Functions
The onCreate functions include the following:
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
51
DRAFT - Modified May 27, 2014 4:45 pm
fieldsOnDefault. Defines the fields that you want to set. Values can either be read directly from
a parent object and inserted in the child, or you can run a conditional query to determine the
value to be set.
getDefaultValueOfMEFIELDNAME. Sets a value in the field specified by MEFIELDNAME. If
running a conditional query to determine the value to write to the field, then the conditional
query must also be entered using the getDefaultValueOfMEFIELDNAM function.
onCreateJSON. Prompts the user with a warning or question before creating a record.
Defining a Query in the onCreate Function
The following procedure shows you how to define a query in onCreate, which involves reading and
inserting fields from a parent but without running a query.
To define a query in the onCreate function
1 Define the fields that you want to write.
2 Define the value to be inserted into those fields.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
52
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onCreate Function Example 1: Read and
Insert
In this example, a new Contact record is created, which has a parent Account. The main phone
number and fax number are read from the Account record and inserted into the Telephone and Fax
number fields in the Contact record. The user can change the value in the fields before saving if
required. In this example, the following assumptions are made:
The module ID of the parent (Account) is 2.
The phone number MEFIELDNAME in the parent (Account) is ACCTPHONE01.
The fax number MEFIELDNAME in the parent (Account) is ACCTFAX01.
The phone number MEFIELDNAME in the current object (Contact) is CONTPHONE01.
The fax number MEFIELDNAME in the current object (Contact) is CONTFAX01.
For more information about locating the module IDs and field names, see Obtaining Module ID and
Field Name Information on page 22.
The typical structure of an onCreate query, which reads fields and inserts fields from a parent, is as
follows:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " MEFI ELDNAME" ; }
f unct i on get Def aul t Val ueOf MEFI ELDNAME( ) { r et ur n " MODULEI D. MEFI ELDNAME" }
NOTE: The onCreate code is saved in the Module Settings for the Contact module.
An example of a complete onCreate query with header and footer information, which reads fields and
inserts fields from a parent, is as follows:
<ht ml ><head><t i t l e>onCr eat eExampl e1</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDef aul t ( ) { r et ur n " CONTPHONE01, CONTFAX01" ; }
f unct i on get Def aul t Val ueOf CONTPHONE01( ) { r et ur n " 2. ACCTPHONE01" }
f unct i on get Def aul t Val ueOf CONTFAX01( ) { r et ur n " 2. ACCTFAX01" }
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f i el dsOnDef aul t ( ) { r et ur n " MEFI ELDNAME" ; } defines the fields to be set. To set the value in
the two fields (CONTPHONE01 and CONTFAX01) within the contact, the MEFIELDNAME is
replaced with these two values and separated by a comma in onCreate example 1 as follows:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " CONTPHONE01, CONTFAX01" ; }
f unct i on get Def aul t Val ueOf MEFI ELDNAME( ) { r et ur n " MODULEI D. MEFI ELDNAME" } sets each
field. It lists the field to be set in the get Def aul t Val ueOf command and the value to insert
(return) from the parent by listing the module ID and field name of the parent field. Do this one
field at a time in onCreate example 1 as follows:
f unct i on get Def aul t Val ueOf CONTPHONE01( ) { r et ur n " 2. ACCTPHONE01" }
f unct i on get Def aul t Val ueOf CONTFAX01( ) { r et ur n " 2. ACCTFAX01" }
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
53
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onCreate Function Example 2: Conditional
Insert
In this example, a conditional query determines which fields are entered into a child object. A Quote
module is already set up, and the user wants to add a child Call record. There is a Sales Stage
keyword within the Quote object, which defines whether the quotation is Tentative, Confirmed or
Ordered. When the call details are entered, the Subject field relates to the status of the quote. If the
quotes Sales Stage is confirmed, then the Call Subject field states something similar to the
following: Call regarding Confirmed Quotation. In this example, the following assumptions are made:
The MODULEID of the parent object (Quote) is 4.
The FIELDID of the parent field (Quote Sales Stage) is CUSTKW03.
The Keyword values of the parent field is Tentative / Confirmed / Ordered.
The FIELDID of the child field (Call Subject) is CUSTTXT02.
For more information about identifying MODULEID and FIELDID information, see Obtaining Module
ID and Field Name Information on page 22. For more information about identifying keyword values,
see Using Keywords in Queries on page 24.
The typical structure of an onCreate query, which uses a conditional insert, is as follows:
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " MEFI ELDNAME- MODULEI D. MEFI ELDNAME" ;
}
f unct i on get Def aul t Val ueOf MEFI ELDNAME( val ue) {
i f ( val ue == ' 1' ) {
r et ur n " a" ;
}el se i f ( val ue == ' 2' ) {
r et ur n " b" ;
}el se i f ( val ue == ' 3' ) {
r et ur n " c" ;
}el se{
r et ur n " " ;
}
}
An example of a complete onCreate query with header and footer information, which uses a
conditional insert, is as follows:
<ht ml ><head><t i t l e>onCr eat eExampl e2</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " CUSTTXT02- 4. CUSTKW03" ;
}
f unct i on get Def aul t Val ueOf CUSTTXT02( st age) {
i f ( st age == ' Tent at i ve' ) {
r et ur n " Cal l r egar di ng Tent at i ve Quot at i on" ;
}el se i f ( st age == ' Conf i r med' ) {
r et ur n " Cal l r egar di ng Conf i r med Quot at i on" ;
}el se i f ( st age == ' Or der ed' ) {
r et ur n " Cal l r egar di ng Or der Conf i r mat i on" ;
}el se{
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
54
DRAFT - Modified May 27, 2014 4:45 pm
r et ur n " " ;
}
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " MEFI ELDNAME- MODULEI D. FI ELDI D" ; } reads the fields
that are used in the conditional query. When defining a conditional query, f i el dsOnDef aul t sets
the field to be updated and the field used to calculate the field being set. The first field listed
(MEFIELDNAME) is the name of the field to be updated. The minus sign (-) is inserted to identify
that the field being updated is calculated using the value stored in another field.
MODULEI D. MEFI ELDNAME is the name of the field being read to perform the calculation. In this
example, the values " CUSTTXT02- 4. CUSTKW03" are inserted. The code used in onCreate example
2 is therefore as follows:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " CUSTTXT02- 4. CUSTKW03" ; }
f unct i on get Def aul t Val ueOf MEFI ELDNAME( val ue) specifies to update a field and gives a
nickname to the parent field being read. Because MEFIELDNAME is being replaced with
CUSTTXT02 (which is the field being written to), 4. CUSTKW03 is given a nickname to use in the
conditional query. The nickname is defined inside the brackets. The ( val ue) variable is replaced
with ( st age) so that the function used in onCreate example 2 is as follows:
f unct i on get Def aul t Val ueOf CUSTTXT02( st age)
The IF query starts with a left brace { and closes with a right brace }. Between the braces, the
name of the field being checked changes from val ue to st age, the ( 1, 2, 3) values being looked
for are replaced with ( Tent at i ve, Conf i r med, Or der ed), and the returned ( a, b, c) values are
replaced with the message to display. Each query is separated by an else if command to check
each value in turn. A final else command specifies that if none of the previous conditions are met,
then insert a blank value. The conditional query used in onCreate example 2 is as follows:
{ i f ( st age == ' Tent at i ve' ) { r et ur n " Cal l r egar di ng Tent at i ve Quot at i on" ; }
el se i f ( st age == ' Conf i r med' ) { r et ur n " Cal l r egar di ng Conf i r med Quot at i on" ; }
el se i f ( st age == ' Or der ed' ) { r et ur n " Cal l r egar di ng Or der Conf i r mat i on" ; }
el se{ r et ur n " " ; }
}
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
55
DRAFT - Modified May 27, 2014 4:45 pm
JSON onCreateJSON Function
You can use the JSON entry point called onCreateJSON on the onCreate event of a record. The
onCreateJSON function prompts the user with a warning or question before creating a record.
The onCreateJSON function in the following example code prompts the user with a message that an
address is being created under the parent Account.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
/ ** sampl e scr i pt t o war n i f cr eat i ng addr ess under Account **/
f unct i on onCr eat eJ SON( ) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " get Par ent \ " , \ " par amet er s\ " : [ {\ " modul ef i el ds\
" : [ { \ " modul e\ " : \ " 1\ " , \ " f i el ds\ " : \ " ui d\ " }
] , \ " f i l t er \ " : \ " 1. ui d=$par ent . ui d\ " }] }] " ;
}
f unct i on get Par ent ( r ow) {
i f ( r ow. l engt h>0) {
/ ** i t means t hat we ar e cr eat i ng addr ess under Account par ent **/
r et ur n
" [ {\ " act i on\ " : \ " showpr ompt \ " , \ " i nvoke\ " : \ " cal l backWi t hBut t onTi t l e\ " , \ " t i t l e\ " : \ " $c
onf i r m. addr ess. cr eat e\ " , \ " ot her but t ont i t l es\ " : [ \ " cr eat e\ " ] ,
\ " cancel but t ont i t l e\ " : \ " cancel \ " }] " ;
}el se {
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " } ] " ;
}
}
f unct i on cal l backWi t hBut t onTi t l e( ot her but t ont i t l e1) {
i f ( ot her but t ont i t l e1 == " cr eat e" ) {
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " } ] " ;
}el se {
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " f al se\ " } ] " ;
}
}
f unct i on onEr r or I nvoke( r ows) {
i f ( r ows. l engt h > 0) {
wi ndow. l ocat i on = " mel t : / / showAl er t : " + message;
}
}
</ scr i pt ></ head><body></ Body></ ht ml >
The onPreCreateJSON function
You can use the JSON entry point called onPreCreateJSON on the onCreate event of a record. The
onPreCreateJSON function can be used to check values before creating records in an onCreate script.
The following code sample checks for the presence of contact before creating the sample request:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onCreate in JavaScript Code
56
DRAFT - Modified May 27, 2014 4:45 pm
f unct i on onPr eCr eat eJ SON( ) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " checkCont act Exi st \ " , \ " par amet er s\ " : [ {\ " modul
ef i el ds\ " : [ {\ " modul e\ " : \ " 7\ " , \ " f i el ds\ " : \ " CLOGREF2\ " }] , \ " f i l t er \ " : \ " 7. ui d=$7. ui d\ "
}] }] " ;
}
f unct i on checkCont act Exi st ( cont act Row) {
ar g=ar gument s;
var r esul t =" f al se" ;
i f ( cont act Row[ 0] . _7. CLOGREF2) ) {
r esul t =" t r ue" ;
}el se{
r esul t = " f al se" ;
wi ndow. l ocat i on = " mel t : / / showAl er t : Not pr i mar y owner " ;
}
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " " +r esul t +" \ " }] " ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
The onPostCreateJSON Function
You can use the JSON entry point called onPostCreateJSON on the onCreate event of a record. You
can set default values using the onPostCreateJSON function with the toscreen filter in an onCreate
routine. The following code sample illustrates the use of the onPostCreateJSON function:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onPost Cr eat eJ SON( )
{
r et ur n " [ {\ " act i on\ " : \ " updat e\ " , \ " f i el ds\ " : [ { \ " f i el d\ " : \ " CLOGTXT01\ " ,
\ " val ue\ " : \ " Dor i an Test \ " }] , \ " f i l t er \ " : \ " \ " , \ " t oscr een\ " : \ " yes\ " }] " ;
}
</ scr i pt >
</ head></ ht ml >
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function OnEdit in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
57
DRAFT - Modified May 27, 2014 4:45 pm
Function OnEdit in JavaScript Code
The onEdit function is called whenever a user edits a field. For more information about the structure
of JavaScript code, see Chapter 4, JavaScript Structure Used in Oracle CRM On Demand Disconnected
Mobile Sales.
JavaScript onEdit Functions
The onEdit function includes the following:
onEditJSON. The onEditJSON function validates a value or formula when a field is changed.
JSON onEditJSON Function
You can use the JSON entry point called onEditJSON on the onEdit event of a record. The onEditJSON
function validates a value or formula as follows:
If the result is True, then the record enters edit mode and you can edit the record.
If the result is False, then the record does not enter edit mode and you cannot edit the record.
The onEditJSON function in the following example code disables edit when the account type is equal
to hospital.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
/ ** di sabl e edi t i f account t ype = hospi t al **/
f unct i on onEdi t J SON( )
{
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " checkCondi t i on\ " , \ " par amet er s\ " : [ {\ " modul ef i
el ds\ " : [ { \ " modul e\ " : \ " 1\ " , \ " f i el ds\ " : \ " ACCTKW11\ " }
] , \ " f i l t er \ " : \ " 1. ui d=$1. ui d\ " }] }] " ;
}
f unct i on checkCondi t i on( r ow)
{
var r esul t ;
r esul t = " t r ue" ;
i f ( r ow. l engt h>0) {
i f ( r ow[ 0] . _1. ACCTKW11 == " Hospi t al " ) {
wi ndow. l ocat i on = " mel t : / / showAl er t : $message. not . edi t abl e" ;
r esul t = " f al se" ;
}
}
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " " + r esul t + " \ " } ] " ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onOpen in JavaScript Code
58
DRAFT - Modified May 27, 2014 4:45 pm
Function onOpen in JavaScript Code
The onOpen function is called when a user opens a quick selector for a module. For example, the
onOpen function defined for the Attendee Call module is called when a user selects the quick selector
to add an Attendee Call to the parent. You can use onOpen to set field values by default in any quick
selector list. Typically, fields are automatically populated with a default value, with values held in
other fields, with values held in the parent object, or with values held by other parent objects. For
more information about the structure of JavaScript code, see Chapter 4, JavaScript Structure Used
in Oracle CRM On Demand Disconnected Mobile Sales.
JavaScript onOpen Functions
The onOpen functions include the following:
fieldsOnDefault. Defines which fields to set. Values are read directly from a parent object and
inserted in the child object.
getDefaultValueofMEFIELDNAME. Sets the value in whichever field you specify in
MEFIELDNAME. Note that conditional queries are not supported.
loadVirtualFields. Display fields in objects on the client that do not exist in Oracle CRM On
Demand.
Defining a Query in the onOpen Function
The following procedure shows you how to define a query in onOpen, which involves inserting fields
from a parent object.
To define a query in the onOpen function
1 Define the fields to write to.
2 Define the values to insert into those fields.
JavaScript onOpen Function Example: Read and Insert
This example shows you how to add an Attendee Call using the quick selector list. To speed up data
entry, the start time and end time are read from the parent call and inserted into the start time and
end time fields in the Attendee Call record. You can change the values in these fields if required
before saving. In this example, the following assumptions are made:
The module ID of the parent call is 7.
The start time MEFIELDNAME in the parent account is CLOGSTARTTIME.
The fax number MEFIELDNAME in the parent account is CLOGENDTIME.
The start time MEFIELDNAME in the current attendee call object is CLOGSTARTTIME.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onOpen in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
59
DRAFT - Modified May 27, 2014 4:45 pm
The end time MEFIELDNAME in the current attendee call object is CLOGENDTIME.
For more information about locating module IDs and field names, see Obtaining Module ID and Field
Name Information on page 22.
The typical structure of an onOpen query, which inserts fields from a parent object, is as follows:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " MEFI ELDNAME" ; }
f unct i on get Def aul t Val ueOf MEFI ELDNAME( ) { r et ur n " MODULEI D. MEFI ELDNAME" }
The onOpen code is saved in the Module Settings of the Attendee Call module. An example of a
complete onOpen query with header and footer information, which inserts fields from a parent
object, is as follows:
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " > f unct i on
f i el dsOnDef aul t ( ) { r et ur n " CLOGSTARTTI ME| CLOGENDTI ME" ; } f unct i on
get Def aul t Val ueOf CLOGSTARTTI ME( ) {r et ur n " 7. CLOGSTARTTI ME" ; }
f unct i on get Def aul t Val ueOf CLOGENDTI ME( ) {r et ur n " 7. CLOGENDTI ME" ; } </ scr i pt ></ head></
ht ml >
where:
f i el dsOnDef aul t ( ) { r et ur n MEFI ELDNAME; } defines the fields to be set. In this example,
the value in two different fields is being set within the contact, CLOGSTARTTIME and
CLOGENDTIME, so MEFIELDNAME must be replaced with these two values, separated by a
comma:
f unct i on f i el dsOnDef aul t ( ) { r et ur n CLOGSTARTTI ME| CLOGENDTI ME; }
f unct i on get Def aul t Val ueOf MEFI ELDNAME( ) { r et ur n " MODULEI D. MEFI ELDNAME" } sets each
field. Each field to set is listed in the get Def aul t Vaul ueOf command, and the value to insert
(return) from the parent is specified using the module ID and field name of the parent field. The
fields are set one field at a time. The code for the first field in the onOpen example is as follows:
f unct i on get Def aul t Val ueOf CLOGSTARTTI ME( ) { r et ur n 7. CLOGSTARTTI ME }
The code for the second field in the onOpen example is as follows:
f unct i on get Def aul t Val ueOf CLOGENDTI ME( ) { r et ur n 7. CLOGENDTI ME }
Displaying Virtual Fields
You can configure Virtual fields in the ME server, when combined with an onOpen script containing
the function loadVirtualFields(). Virtual fields enable administrators to display fields in objects on the
client that do not exist in Oracle CRM On Demand. For example, you can display a value from a
grandparent record on its grandchild record. You could also use custom JavaScript code to display
calculated fields in the client.
NOTE: Virtual fields are read-only fields; they are not editable on a device and cannot be
synchronized to Oracle CRM On Demand.
To add a virtual field in the server
1 Select Map Settings
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Function onOpen in JavaScript Code
60
DRAFT - Modified May 27, 2014 4:45 pm
2 Click on the module below the Map Settings heading.
3 Select Map Fields.
4 Enter a label for the new field and click Save.
The new field is added to the list of Oracle CRM On Demand fields and can now be mapped as
normal.
The following is a sample script:
/ *** sampl e scr i pt t o set val ues on vi r t ual f i el d CONTTXT22 i n Cont act modul e when
di spl ayi ng a r ecor d. You can put t hi s scr i pt i n an onOpen event of Cont act modul e **/
<ht ml ><head><t i t l e>Test </ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on l oadVi r t ual Fi el ds( )
{
/ ** get t i ng t he val ue f r omr el at ed addr ess modul e **/
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " set Addr essFi el ds\ " , \ " par amet er s\ " : [ {\ " modul e
f i el ds\ " : [ { \ " modul e\ " : \ " 20\ " , \ " f i el ds\ " : \ " CUSTDESCRI PTI ON\ " }
] , \ " f i l t er \ " : \ " 20. CUSTREF3=$2. ui d\ " }] }] " ;
}
f unct i on set Addr essFi el ds( r ows)
{
var r et St r i ng =
" [ {\ " act i on\ " : \ " updat e\ " , \ " modul e\ " : \ " 2\ " , \ " t oscr een\ " : \ " yes\ " , \ " f i el ds\ " : [ " ;
i f ( r ows. l engt h>0) {
i f ( r ows[ 0] . _20. CUSTDESCRI PTI ON) { / ** t o avoi d di spl ayi ng val ue as ' undef i ned' **/
r et St r i ng += " { \ " f i el d\ " : \ " CONTTXT22\ " ,
\ " val ue\ " : \ " " +r ows[ 0] . _20. CUSTDESCRI PTI ON+" \ " } " ;
}
}
r et St r i ng += " ] }] " ;
r et ur n r et St r i ng;
}
</ scr i pt ></ head><body></ Body></ ht ml >
Virtual fields can be configured in the ME server, when combined with an onOpen script containing
the function loadVirtualFields(). Virtual fields enable administrators to display fields in objects on the
client that do not exist in Oracle CRM On Demand. For example, when viewing a grandchild record
you could display a value from its grandparent record. You could also use custom JavaScript code to
display calculated fields in the client.
To add a virtual field in the server
1 In the Admin Console select Map Settings, then click on a module below the Map Settings
heading.
2 Select Map Fields.
3 Click Add Virtual Fields.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
61
DRAFT - Modified May 27, 2014 4:45 pm
4 Enter a label for the new field, enter and click Save.
The new field can now be mapped as normal. Virtual fields are read-only fields, they are not editable
on a device and cannot be synchronized up to Oracle CRM On Demand.
Functions onSave and onPreSave in
JavaScript Code
The onSave function is called whenever a user saves a new or modified record by selecting the Save
button. You can use the onSave function to perform several actions, including the following:
To automatically complete fields according to the values stored in existing fields, including hidden
and read-only fields.
To save a field value, overwriting any user-entered values.
To perform data validation to check that conditions are met (such as is end time greater than
start time?).
To perform data validation to ensure that fields are completed according to the values in a parent
module.
To automatically open an object for creation after the current record is saved.
Two actions are available when the Save button is selected, and you enter both actions into the
onSave code. The actions, which you can combine within the same piece of code, are as follows:
onPreSave. Performs data validation, and either allows records to be saved or prevents records
from being saved. For more information, see JavaScript onPreSave Functions on page 61.
onSave. Sets the values or triggers another record to be created. For more information, see
JavaScript onSave Functions on page 68.
For more information about the structure of JavaScript code, see Chapter 4, JavaScript Structure
Used in Oracle CRM On Demand Disconnected Mobile Sales.
JavaScript onPreSave Functions
JavaScript onPreSave code is entered into the onSave action, and it must include the following
functions as part of the code:
fieldsOnPreSave. Defines which fields to read, either from the current object or a parent object,
to perform a conditional query against.
onPreSave. Names the individual fields. If running a conditional query to determine the value
to write to a field, then the conditional query must also be entered using the onPreSave function.
onPreSaveJSON. The Save and Save and New buttons appear for modules in the client
application when editing or creating records. When a user selects either of these buttons, the
onPreSaveJSON function is called. You can configure the onPreSaveJSON function in any module
that has the Save and Save and New buttons, and onPreSaveJSON is called before the record is
saved. You use the onPreSaveJSON function for data validation, and to either allow or prevent
record saving.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
62
DRAFT - Modified May 27, 2014 4:45 pm
onSaveJSON. The Save and Save and New buttons appear for modules in the client application
when editing or creating records. When a user selects either of these buttons, the onSaveJSON
function is called. You can configure the onSaveJSON function in any module that has the Save
and Save and New button, and onSaveJSON is called after the record is saved.
onAcceptAndSign. The Accept and Sign button appears on the Signature page in the client
application. When a user selects Accept and Sign, the onAcceptAndSign function is called. You
configure the AcceptAndSign function in the Signature module.
doneSignature. The Done button appears on the Signature page in the client application. When
a user selects Done, the doneSignature function is called. You configure the doneSignature
function in the Appointments and Attendee Call modules.
onSubmitCall. The Submit button appears in the client application (top left-hand corner) when
viewing record details for Account, Professional, or Attendee Calls. When a user selects Submit,
the onSubmitCall function is called. You configure the onSubmitCall function in the Appointments
and Attendee Call modules.
Defining a Query in the onPreSave Function
The following procedure shows you how to define a query in onPreSave, which involves defining what
you want to query or check, and what you want to happen as a result of running the query.
To define a query in the onPreSave function
1 Read the fields to use in the query. For example, the Due and Planned Start Time fields.
2 Give both fields a name to use in the conditional query.
3 Enter the conditional query that checks whether the Due field is greater than the Planned Start
Time.
If it is, then allow the record to be saved.
If it is not, then display a message, and do not allow the record to be saved.
JavaScript onPreSave Function Example 1: Checking a
Single Condition
In Oracle Oracle CRM On Demand, there are validation rules in place which must be replicated in the
Oracle CRM On Demand Disconnected Mobile Sales application. In an Activity for example, the
Planned Start Time must be before the date that the Activity is due (Due field). Both fields are stored
in the current object (Activity). In this example, the following assumptions are made:
The MEFIELDNAME of the Due field is TASKDT01.
The MEFIELDNAME of the Planned Start Time field is TASKDT02.
For more information about identifying module ID and field name information, see Obtaining Module
ID and Field Name Information on page 22.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
63
DRAFT - Modified May 27, 2014 4:45 pm
The typical structure of an on PreSave query, which checks a single condition, is as follows:
f unct i on f i el dsOnPr eSave( ) {
r et ur n " MEFI ELDNAME, MEFI ELDNAME" ;
}
f unct i on onPr eSave( val ue1, val ue2)
{ i f ( val ue1 > val ue2 )
{ r et ur n t r ue; }
el se{ wi ndow. l ocat i on = " mel t : / / showAl er t : message t o di spl ay" ;
r et ur n f al se; }
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
64
DRAFT - Modified May 27, 2014 4:45 pm
An example of a complete onPreSave query with header and footer information, which checks a
single condition, is as follows:
<ht ml ><head><t i t l e>Pr eSaveExampl e1</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnPr eSave( ) {
r et ur n " TASKDT01, TASKDT02" ;
}
f unct i on onPr eSave( due, pl anned)
{ i f ( due > pl anned )
{ r et ur n t r ue; }
el se{ wi ndow. l ocat i on = " mel t : / / showAl er t : $due. gr eat er . t han. pl anned" ;
r et ur n f al se; }
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f unct i on f i el dsOnPr eSave( ) { r et ur n " MEFI ELDNAME, MEFI ELDNAME" ; } specifies which fields to
check. To replace the two MEFIELDNAMEs with the IDs of the fields that are read, the code in
onPreSave example 1 is as follows:
f unct i on f i el dsOnPr eSave( ) { r et ur n " TASKDT01, TASKDT02" ; }
f unct i on onPr eSave( val ue1, val ue2) names the two fields that are read. The ( val ue 1, val ue
2) fields are replaced with the names ( due, pl anned) . The fields are named in the order that
they are defined in the f i el dsOnPr eSave( ) command:
f unct i on onPr eSave( due, pl anned)
A left brace { starts the query to check whether the due date is greater than the planned date
as follows:
{ i f ( due > pl anned)
{ r et ur n t r ue; } defines what to do if the query (due date is greater than planned date) is
correct. In this example, the user is allowed to save the record if the due date is greater than
the planned date.
The else command defines what to do if the condition (due date is greater than planned date) is
not correct. In this example, a message is displayed using the wi ndow. l ocat i on command, and
a False value is returned preventing the user from saving the record. A custom device message
is defined by inserting the dollar symbol ($) after the showAl er t : command, and a new message
must be created as shown in Custom Device Messages and Multiple Language Installations on
page 25. The code in onPreSave example 1 is as follows:
el se{ wi ndow. l ocat i on = " mel t : / / showAl er t : $due. gr eat er . t han. pl anned" ; r et ur n
f al se; }
A right brace } signals the end of the IF query.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
65
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onPreSave Function Example 2: Checking
Multiple Conditions
This example expands the query detailed in JavaScript onPreSave Function Example 1: Checking a
Single Condition on page 62 by including two further checks, each with a unique message. In this
example, the following checks are made:
Is the due date greater than the planned date (as shown in onPreSave example 1)?
Is the planned completion date greater than the planned date?
Has the completed date been entered and if so, is it greater than the start date?
The following assumptions are made about the field IDs in this example:
The Planned Completion field ID is TASKDT03.
The Started field ID is TASKDT04.
The Completed field ID is TASKDT05.
For more information about identifying module ID and field name information, see Obtaining Module
ID and Field Name Information on page 22.
The onPreSave example 1 on page on page 62 checks only a single condition. The onPreSave example
2 checks multiple conditions. An example of a complete onPreSave query with header and footer
information, which checks multiple conditions, is as follows:
<ht ml ><head><t i t l e>Pr eSaveExampl e2</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnPr eSave( ) {
r et ur n " TASKDT01, TASKDT02, TASKDT03, TASKDT04, TASKDT05" ;
}
f unct i on onPr eSave( due, pl anned, pl annedcomp, st ar t ed, compl et ed)
{ i f ( due > pl anned )
{ i f ( pl annedcomp > pl anned )
{ i f ( compl et ed==0 | | compl et ed > st ar t ed)
{ r et ur n t r ue; }el se{ wi ndow. l ocat i on = " mel t : / /
showAl er t : $cust om. compl et ed. gr eat er . t han. st ar t ed" ; r et ur n f al se;
} }el se{
wi ndow. l ocat i on = " mel t : / /
showAl er t : $cust om. pl annedcomp. gr eat er . t han. pl anned" ;
r et ur n f al se;
} }el se{
wi ndow. l ocat i on = " mel t : / / showAl er t : $cust om. due. gr eat er . t han. pl anned" ;
r et ur n f al se;
}
}</ scr i pt ></ head><body></ Body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
66
DRAFT - Modified May 27, 2014 4:45 pm
where:
f unct i on f i el dsOnPr eSave( ) { r et ur n " TASKDT01, TASKDT02, TASKDT03, TASKDT04, TASKDT05" ; }
defines all the fields that must be read.
f unct i on onPr eSave( due, pl anned, pl annedcomp, st ar t ed, compl et ed) defines the names for the
fields that must be read.
The multiple conditions are then defined. The structure of the multiple conditions in onPreSave
example 2 is as follows:
{ i f ( condi t i on 1 )
{ i f ( condi t i on 2 )
{ i f ( condi t i on 3 )
{ r et ur n t r ue; }
el se{ message 3; r et ur n f al se; }
}el se{ message 2; r et ur n f al se; }
}el se{ message 1; r et ur n f al se; }
}
If all the conditions are met, then a True value is returned allowing the record to be saved. If the
conditions are not met, then a message is displayed indicating which condition was not met, and
a False value is returned preventing the record from being saved.
NOTE: Notice that r et ur n t r ue; is defined first. If all conditions are met, then the code exits
and the user can save the record. The other conditions are checked in the reverse order that they
are listed, so the messages displayed are defined in the reverse order also. Nested IF arguments
are checked in a similar way also.
In onPreSave example 2, the code is as follows:
Condi t i on 1 = ( due > pl anned )
Condi t i on 2 = ( pl annedcomp > pl anned)
Condi t i on 3 = ( compl et ed==0 | | compl et ed > st ar t ed )
In the third condition, the completed field date is checked first to see if it is blank. Because date
time fields are numeric, you can check if it is equal to zero (0). The double bar or pipe symbols
(||) indicates to include an OR query. So the condition is met if the completed date is blank OR
the completed date is greater than the start date.
If the activity is in progress, then the Completed field might not be populated. If you do not
include the code compl et ed==0 and a completed date is not entered, then the condition is not
met and the record is not saved. Custom device messages are displayed, in reverse order, in
onPreSave example 2 as follows:
Message 3 = $cust om. compl et ed. gr eat er . t han. st ar t ed
Message 2 = $cust om. pl annedcomp. gr eat er . t han. pl anned
Message 1 = $cust om. due. gr eat er . t han. pl anned
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
67
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onPreSave Function Example 3: Checking a
Parent
A quotation is entered in this example. The quotation has a parent Account, which contains a
Customer Type keyword to indicate whether the customer is a preferred or a standard customer.
Users are allowed to enter a discount if the customer is a preferred customer only. To perform this
query, this example makes the following assumptions:
The parent account MODULEID is 2.
The MEFIELDNAME for the Customer Type field in the parent account is ACCTKW05.
The possible values in Customer Type keyword are Preferred or Standard.
The MEFIELDNAME for the Discount field is CUSTTXT07.
For more information about identifying module ID and field name information, see Obtaining Module
ID and Field Name Information on page 22.
The query in this example is based on the code used in onPreSave example 1:
<ht ml ><head><t i t l e>Pr eSaveExampl e1</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnPr eSave( ) {
r et ur n " TASKDT01, TASKDT02" ;
}
f unct i on onPr eSave( due, pl anned)
{ i f ( due > pl anned )
{ r et ur n t r ue; }
el se{ wi ndow. l ocat i on = " mel t : / / showAl er t : $due. gr eat er . t han. pl anned" ;
r et ur n f al se; }
}
</ scr i pt ></ head><body></ Body></ ht ml >
The complete code for onPreSave example 3 with header and footer information is as follows:
<ht ml ><head><t i t l e>Pr eSaveExampl e3</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnPr eSave( ) {
r et ur n " CUSTTXT07, 2. ACCTKW05" ;
}
f unct i on onPr eSave( di scount , cust t ype)
{ i f ( di scount ==0 | | cust t ype==' Pr ef er r ed' )
{ r et ur n t r ue; }
el se{ wi ndow. l ocat i on = " mel t : / / showAl er t : You can onl y ent er a di scount
f or Pr ef er r ed cust omer s" ; r et ur n f al se; }
}
</ scr i pt ></ head><body></ Body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
68
DRAFT - Modified May 27, 2014 4:45 pm
For onPreSave example 3, the following changes are made to onPreSave example 1 code:
1 The f i el dsOnPr eSave f unct i on is changed to read the field in the current object and the field
from the parent as follows:
" CUSTTXT07, 2. ACCTKW05"
2 Different names are used for the fields by changing the onPreSave function to the following:
onPr eSave( di scount , cust t ype)
3 Two checks are performed: to return a true value if the discount is equal to zero (di scount ==
0), and to return a true value if the Customer Type is Preferred (cust t ype==' Pr ef er r ed' )
because preferred customers are allowed a discount. Both queries are combined by using an OR
query with a double bar or pipe symbols (||) as follows:
{ i f ( di scount ==0 | | cust t ype==' Pr ef er r ed' ) { r et ur n t r ue ; }
4 The message that is displayed when the condition is not met is changed, and a False value is
returned preventing the record from being saved as follows:
wi ndow. l ocat i on = " mel t : / / showAl er t : You can onl y ent er a di scount f or Pr ef er r ed
cust omer s" ; r et ur n f al se; }
JavaScript onSave Functions
You use the JavaScript onSave code to set the value of fields or to trigger creating another object.
The onSave functions include the following:
fieldsOnDefault. Sets the values in fields. Values are either read directly from a parent object
and inserted in a child object, or a conditional query is run to determine the value that to set.
getDefaultValueOfMEFIELDNAM. You use getDefaultValueOfMEFIELDNAM in conjunction with
fieldsOnDefault to set a value in the field specified in MEFIELDNAME. Using the
getDefaultValueOfMEFIELDNAM function, you also enter the conditional query being used to
determine the value that must be written.
fieldsOnSave. Defines which fields are read if performing a query for the onSave function. For
example, to create a new record if the status field is set to Complete, then define the status field
using the fieldsOnSave function.
onSave. If using the fieldsOnSave function, then you must also include an onSave action. You
cannot save values to fields using onSave. You must use onSave with the MELT command to
display a message or create a new record.
For more information about the structure of JavaScript code, see Chapter 4, JavaScript Structure
Used in Oracle CRM On Demand Disconnected Mobile Sales.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
69
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onSave Function Example 1: Nonconditional
Data
This example shows you how to create or update a quotation on a mobile device. The parent account
object has an account number field stored within it that must be saved in the quotation. The field is
a read-only field on mobile devices, to prevent users accidently entering the wrong information. You
structure this example as an onCreate action. However, if users can create Quotes as a top level
object, then there is no account associated with the record until a user selects one, so the account
number cannot be read when the record is created. If a user selects a customer during the quotation
entry and then saves, then the account number is inserted at this point. The following assumptions
are made in this example:
The MODULEID of the parent account is 2.
The MEFIELDNAME of the Account Number field in the parent account is ACCTTXT11.
The MEFIELDNAME, which saves the account number, in the current child Quote object is
CUSTTXT07.
For more information about identifying module ID and field name information, see Obtaining Module
ID and Field Name Information on page 22.
The typical structure of an onSave query is as follows
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " MEFI ELDNAME" ;
}
f unct i on get Def aul t Val ueOf MEFI ELDNAME ( ) {
r et ur n " MODULEI D. MEFI ELDNAME" ;
}
An example of a complete onSave query with header and footer information and nonconditional data
is as follows:
<ht ml ><head><t i t l e>onSaveExampl e1</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " CUSTTXT07" ;
}
f unct i on get Def aul t Val ueOf CUSTTXT07( ) {
r et ur n " 2. ACCTXT11" ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
f i el dsOnDef aul t lists the field (in this example, CUSTTXT07) that is to be updated in the
MEFIELDNAME parameter. The code in onSave example 1 is as follows:
f unct i on f i el dsOnDef aul t ( ) { r et ur n " CUSTTXT07" ; }
get Def aul t Val ueOf MEFI ELDNAME( ) writes a value to the field and the value to return (in this
example, " 2. ACCTXT11"). The code in onSave example 1 is as follows:
f unct i on get Def aul t Val ueOf CUSTTXT07 ( ) { r et ur n " 2. ACCTTXT11" ; }
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
70
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript onSave Function Example 2: Conditional
Query
In this example, a user is entering time sheet information. An Activity Type is selected as a parent
object, and depending on the value stored in the parent, a different value is stored in the current
record. The following assumptions are made in this example:
The MODULEID of the Activity Type parent module is 8.
The MEFIELDNAME of the Type parent field is CUSTKW01.
The MEFIELDNAME of the Cost Type field to update is CUSTTXT05.
The following code used in JavaScript onCreate Function Example 2: Conditional Insert on page 53 is
adapted for onSave example 2.
<ht ml ><head><t i t l e>onCr eat eExampl e2</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " CUSTTXT02- 4. CUSTKW03" ;
}
f unct i on get Def aul t Val ueOf Fi el dCUSTTXT02( st age) {
i f ( st age == ' Tent at i ve' ) {
r et ur n " Cal l r egar di ng Tent at i ve Quot at i on" ;
}el se i f ( st age == ' Conf i r med' ) {
r et ur n " Cal l r egar di ng Conf i r med Quot at i on" ;
}el se i f ( st age == ' Or der ed' ) {
r et ur n " Cal l r egar di ng Or der Conf i r mat i on" ;
}el se{
r et ur n " " ;
}
}
</ scr i pt ></ head><body></ Body></ ht ml >
An example of a complete onSave query with header and footer information and a conditional query
is as follows:
<ht ml ><head><t i t l e>onSaveExampl e2</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnDef aul t ( ) {
r et ur n " CUSTTXT05- 8. CUSTKW01" ;
}
f unct i on get Def aul t Val ueOf CUSTTXT05( t ype) {
i f ( t ype == ' 50%over t i me' ) {
r et ur n " Over t i me" ;
}el se i f ( t ype == ' 100%over t i me' ) {
r et ur n " Over t i me" ;
}el se i f ( t ype == ' Nor mal ' ) {
r et ur n " St andar d" ;
}
}
</ scr i pt ></ head><body></ Body></ ht ml >
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
71
DRAFT - Modified May 27, 2014 4:45 pm
where:
r et ur n " CUSTTXT02- 4. CUSTKW03" ; changes because you want to calculate the value of
CUSTTXT05 based on a value stored in module 8, field CUSTKW01:
r et ur n " CUSTTXT05- 8. CUSTKW01" ;
f unct i on get Def aul t Val ueOf Fi el dCUSTTXT02( st age) changes to include the new name of the
field to update (CUSTTXT05), and to give the field being calculated a new name (Type):
f unct i on get Def aul t Val ueOf CUSTTXT05( t ype)
In this example, the following values are searched for: " 50%over t i me" and " 100%over t i me". If
either value is stored, then the field updates to "Overtime". If the value read contains the value
" Nor mal ", then the value " St andar d" is returned.
To define which values are stored in the keyword and the values to write into the current record, see
Using Keywords in Queries on page 24.
JavaScript fieldsOnSave and onSave Functions
When using the fieldsOnSave and onSave functions, you can choose to either display a message or
to create a new record when the save has completed. The code is only called after a record has been
saved. Any code defined within fieldsOnDefault, getDefaultValueOf, fieldsOnPresave, or onPresave is
executed before the code is run.
The fieldsOnSave and onSave commands include the following:
window.location = "melt://showAlert:message to display". Displays a message
prompting users to select OK to close, for example, a window.
window.location = "melt://createNew:MODULEID". Creates a new record in the module ID
specified. If required, then you can use this command in conjunction with onCancel to prevent
users from cancelling record creation. For more information, see Function onCancel in JavaScript
Code on page 48.
JavaScript fieldsOnSave and onSave Functions Example
In this example, if a user creates a lead record and saves its status as Qualified, then a message is
displayed prompting (forcing) a follow up call to be created by immediately opening a new Call
record. The fieldsOnSave command reads the value currently set in the Status field. The onSave
command executes the action by checking to see if the status is equal to Qualified. The following
assumptions are made in this example:
The MEFIELDNAME of the status field in the current Lead module is LEADKW01.
The MODULEID for the Call module is 8.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
72
DRAFT - Modified May 27, 2014 4:45 pm
The typical format for a fieldsOnSave or onSave query is as follows:
f unct i on f i el dsOnSave( ) { r et ur n " MODULEI D. MEFI ELDNAME" ; }
f unct i on onSave( name) {
i f ( name == ' Qual i f i ed' )
{ wi ndow. l ocat i on = " mel t : / / showAl er t : Message t o di spl ay" ;
wi ndow. l ocat i on = " mel t : / / cr eat eNew: MODULEI D" ; }
}
An example of a complete fieldsOnSave query with header and footer information is as follows:
<ht ml ><head><t i t l e>f i el dsOnSave</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnSave( ) { r et ur n " t hi s. LEADKW01" ; }
f unct i on onSave( st at us) {
i f ( st at us == ' Qual i f i ed' )
{ wi ndow. l ocat i on = mel t : / / showAl er t : You must cr eat e a cal l f or Qual i f i ed Leads;
wi ndow. l ocat i on = mel t : / / cr eat eNew: 8; }
}
</ scr i pt ></ head><body/ ></ ht ml >
where:
f i el dsOnSave defines which field to read. The field being read is Status, which is the LEADKW01
field in the current Lead module. Because the field is within the current module, you can use the
actual field instead of the module ID. In the fieldsOnSave example, the code is as follows:
f unct i on f i el dsOnSave( ) { r et ur n " t hi s. LEADKW01" ; }
f unct i on onSave( name) gives the status keyword an alias name to use in the conditional query.
In the fieldsOnSave example, the code is as follows:
f unct i on onSave( st at us)
A left brace { begins the IF query, which specifies the condition to check for, for example, as
follows:
i f ( st at us == ' Qual i f i ed' )
The actions to perform are specified next, enclosed within braces {}. In this example, two actions
are performed, and they are separated by a semicolon. The first action is to display a message,
and the second action is to create a new call record (Module ID 8). In the fieldsOnSave example,
the code is as follows:
{ wi ndow. l ocat i on =" mel t : / / showAl er t : You must cr eat e a cal l f or Qual i f i ed Leads" ;
wi ndow. l ocat i on = " mel t : / / cr eat eNew: 8" ; }
A right brace } closes the IF query.
The onSaveFixedJSON Function
The onSaveFixedJSON function ensures that signed and submitted pages are adequately protected.
The onSaveFixedJSON function can be used in an onSave script to protect fields while fixing
erroneous records in the sync log.
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
73
DRAFT - Modified May 27, 2014 4:45 pm
The DMS.onSaveFixedJSON (module, fields) can be called inside the onSaveFixedJSON function in an
onSave script. The first argument is the module and second argument is the array of fields that are
to be protected. The module is either APPOINTMENT or ATTENDEE_CALL. You can either use the
JavaScript object notation for fields or the string values representing the fields. You can fix the
records using the sync log only if the system key allow.user.to.edit.failed.records has the value Yes.
For example:
f unct i on onSaveFi xedJ SON( ) {
var cur r ent = APPOI NTMENT;
var f i el ds = [ APPOI NTMENT. STARTTI ME, APPOI NTMENT. ENDTI ME, APPOI NTMENT. STATUS] ;
r et ur n DMS. onSaveFi xedJ SON( cur r ent , f i el ds) ;
}
The doneSignature Entry Point
You can use the JSON entry point called doneSignature on onSave event of Appointment and
Attendee Call. The doneSignature is invoked after the user signs the record and also requires that
system key prompt.password.signature has value no. The following code sample illustrates the use
of doneSignature:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onAccept AndSi gn( ) {
var opt i ons = {
modul e : APPOI NTMENT,
cont r ol l edSubst anceVal i dFn : cust omCont r ol l edSubst anceVal i dat e
};
r et ur n DMSCal l . onAccept AndSi gn( opt i ons) ;
}
f unct i on doneSi gnat ur e( ) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " checkSampl eRequest Exi st \ " , \ " par amet er s\ " : [ {\
" modul ef i el ds\ " : [ {\ " modul e\ " : \ " cad_menui t ems\ " , \ " f i el ds\ " : [ \ " modul e_i d\ " ] }] , \ " f i l t
er \ " : \ " modul e_i d=78 or modul e_i d=79\ " }] }] " ;
}
f unct i on checkSampl eRequest Exi st ( r ows) {
. . .
}
</ scr i pt ></ head><body></ body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Modify Records in Oracle CRM On Demand Disconnected
Mobile Sales Functions onSave and onPreSave in JavaScript Code
74
DRAFT - Modified May 27, 2014 4:45 pm
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
75
DRAFT - Modified May 27, 2014 4:45 pm
6 Using JavaScript Code to Filter
Information in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter describes how to use JavaScript to filter related item and quick selector information. It
includes the following topics:
JavaScript Code to Filter Related Items and Quick Selectors on page 75
JavaScript Reference Functions on page 76
JavaScript excludeFromPreload Function in Quick Selector Lists on page 79
Support for Field Condition Scripts in Quick Selector Lists on page 81
Using showViewAll to Control the Display of the View All Button on page 81
JavaScript Code to Filter Related Items
and Quick Selectors
In some situations, a complete list of objects is required on user devices, but in other circumstances
only a subset might be required. In such cases, the ability to filter the related items and quick
selector lists in Oracle CRM On Demand Disconnected Mobile Sales in useful. You can configure a
filter for a related item list or quick selector list so that only certain records are displayed in the list.
You can use JavaScript code to filter the records that are available for selection in related item lists
and quick selector lists in the client application, provided that a reference field is defined. Reference
fields are inserted to indicate that there is a link to a parent object in Oracle CRM On Demand
Disconnected Mobile Sales. For more information, see Configuring Filters for Reference Fields on
page 75 and Configuring Filters for Quick Selectors on page 76.
Configuring Filters for Reference Fields
The filters for parent products are configured in the Field Condition input box in the child object. The
following procedure shows you how to configure a JavaScript filter in the Oracle CRM On Demand
Disconnected Mobile Sales Admin Application.
To configure a J avaScript filter
1 Start the Admin application.
2 Click Quick Selector on the vertical navigation bar, then select the quick selector list that you
want to modify.
3 To add a new filter, click Add below the filters table, enter the following values for the new quick
selector list filter, and then click Save.
Type. Select the type of filter, which is one of the following: Required, Toggle, or Validate.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales JavaScript Reference Functions
76
DRAFT - Modified May 27, 2014 4:45 pm
Label. Enter a suitable name for the quick selector list filter in the Label field.
Expression. Enter the JavaScript expression in the Expression box.
4 To edit an existing filter, click edit next to the filter in the filters table, edit the JavaScript code,
and then click Update.
Configuring Filters for Quick Selectors
The following procedure shows you how to configure a JavaScript filter for a quick selector list in the
Oracle CRM On Demand Disconnected Mobile Sales Admin Application.
NOTE: It is not possible to set field values by default in a quick selector by adding JavaScript to the
quick selector. The values must be defined in the onOpen function. For more information, see
Function onOpen in JavaScript Code on page 58.
To configure a J avaScript filter for a quick selector list
1 Start the Admin application.
2 Click Map Settings, then select the module where you want to insert the filter.Click Edit next to
the Reference field to modify the field settings.
3 In the Field Condition input box, enter the JavaScript code.
4 Click Submit, then Submit Order Changes.
JavaScript Reference Functions
When using a filter for reference fields to limit which fields to display, use one of the following
JavaScript reference functions:
fieldsOnConditionQuery. Reads the set of fields in a conditional query to determine which
records to display. MODULEID and MEFIELDNAME must be included in the set of fields.
conditionQuery. Defines the filter to determine which records are displayed.
conditionQueryJSON. You can add JavaScript expressions to the Field Condition attribute of a
field to apply filters to the field or to a quick selector. When filters are defined for a field or a
quick selector, the conditionQueryJSON function is called.
onValidateJSON. This function validates a quick selector before performing a save, and is
considered to be a soft stop rather than a hard stop. You can still save records if validation of the
quick selector, as specified by the onValidateJSON function, fails.
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales JavaScript Reference Functions
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
77
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript Reference Function Example 1: Simple Filter
This example uses an inventory management module to track the movement of material products.
The user selects a material type, the serial number, and specifies when and where the product moves
from and to. There is a reference field, which the user uses to select a product from the Products
module to record the type of product being tracked. There are approximately 1500 products on the
user device, but only 60 are material products. The user only wants to see products of type Material.
The following assumptions are made in this example:
The MEFIELDNAME, which contains the value Material in the parent module (Products), is
CLOGTXT04.
The MODULEID of the parent module (Products) is 7.
For more information about identifying the MODULEID and MEFIELDNAME, see Obtaining Module ID
and Field Name Information on page 22.
In this example, it is not necessary to query any fields because products are being displayed based
on the static filter, t ype=Mat er i al . The fieldsOnConditionQuery function is not required either.
However, you must specify the field to use for the query using the following format:
f unct i on condi t i onQuer y( ) { r et ur n " MODULEI D. MEFI ELDNAME = xxxxxxxxxx" ; }
According to this command, MODULEI D. MEFI ELDNAME is replaced with the field containing " Type"
( 7. CLOGTXT04) , and xxxxxxxxx is replaced with the value that is being looked for (which is, Material).
The complete code example including header and footer information is as follow:
<ht ml ><head><t i t l e>Ref er enceSampl e1</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on condi t i onQuer y( )
{ r et ur n " 7. CLOGTXT04 = Mat er i al " ; }
</ scr i pt ></ head><body/ ></ ht ml >
JavaScript Reference Function Example 2: Conditional
Filter
In this example, the filter defined in JavaScript Reference Function Example 1: Simple Filter on
page 77 is expanded so that not only are related records being filtered by their type, but also by
Product Group in the current object. Product Group is a keyword that contains all product groups, as
well as an All keyword to allow the user to select all products. The purpose of this example is to filter
related records that are of type Material, but which also match the Product Group that the user has
selected. The following assumptions are made in this example:
The MEFIELDNAME, which contains the value Material in the parent module (Products), is
CLOGTXT04.
The MEFIELDNAME, which contains the Product Group keyword in the parent module (Products),
is CLOGTXT01.
The MODULEID of the parent module (Products) is 7.
The MODULEID of the current module (Material) is 15.
The MEFIELDID of the Product Group keyword in current module (Material) is CUSTKW02.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales JavaScript Reference Functions
78
DRAFT - Modified May 27, 2014 4:45 pm
For more information about identifying the MODULEID and MEFIELDNAME, see Obtaining Module ID
and Field Name Information on page 22.
To determine which related records to display, the example queries what the user selects in the
current module for the product group keyword (15. CUSTKW02). The example also includes a filter to
only return products of type Material. Three conditions are defined in this example based on what
should happen if the user selects no product group, all product groups, or any product group as
follows:
If no product group is selected, then display all Material products.
If all product groups are selected, then display all Material products.
If any product group is selected, then display Material products that have the same product group
that the user selected.
The structure of the query is as follows:
f unct i on f i el dsOnCondi t i onQuer y( ) { r et ur n " MODULEI D. MEFI ELDNAME" ; }
f unct i on condi t i onQuer y( name)
{ i f ( name == ' Al l ' ) { r et ur n " MODULEI D. MEFI ELDNAME = Mat er i al " ; }
el se i f ( name == ' ' ) { r et ur n " MODULEI D. MEFI ELDNAME = Mat er i al " ; }
el se{ r et ur n " MODULEI D. MEFI ELDNAME = " +name+" AND MODULEI D. MEFI ELDNAME = Mat er i al " ;
}
}
An example of a complete JavaScript reference function with header and footer information, using
the fieldsOnCondition query, is as follows:
<ht ml ><head><t i t l e>Ref er enceSampl e2</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on f i el dsOnCondi t i onQuer y( ) { r et ur n " 15. CUSTKW02" ; }
f unct i on condi t i onQuer y( pr oduct t ype)
{ i f ( pr oduct t ype == ' Al l ' ) { r et ur n " 7. CLOGTXT04 = Mat er i al " ; }
el se i f ( pr oduct t ype == ' ' ) { r et ur n " 7. CLOGTXT04 = Mat er i al " ; }
el se{ r et ur n " 7. CLOGTXT01 = " +pr oduct t ype+" AND 7. CLOGTXT04 = Mat er i al " ; }
}
</ scr i pt ></ head><body/ ></ ht ml >
where:
f unct i on f i el dsOnCondi t i onQuer y( ) { r et ur n " 15. CUSTKW02" ; } defines which field to query
using the fieldsOnConditionQuery command, and which field the user enters (15. CUSTKW02).
f unct i on condi t i onQuer y( pr oduct t ype) gives the field being queried a name (pr oduct t ype) to
use in the condition using the conditionQuery function.
The query begins with a left { brace, followed by the first IF statement.
i f ( pr oduct t ype == ' Al l ' ) { r et ur n " 7. CLOGTXT04 = Mat er i al " ; } is the first IF statement.
If pr oduct t ype is equal to All, then return records where Type is in the Product record
(7. CLOGTXT04 = Mat er i al ).
A second IF statement with an ELSE IF defines what happens if the user selects no value. It is
similar to the previous query, but ' Al l ' is replaced with two single quote marks, which means
none.
i f ( pr oduct t ype == ' Al l ' ) { r et ur n " 7. CLOGTXT04 = Mat er i al " ; }
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales JavaScript excludeFromPreload Function in Quick Selector Lists
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
79
DRAFT - Modified May 27, 2014 4:45 pm
The last condition defines what happens if neither of the two previous conditions are met. To
return a list of related records that have the same product group that the user selects (this is
stored in 7. CLOGTXT01 in Products) and that also have Material set as a type, the code used in
the example is as follows:
el se{ r et ur n " 7. CLOGTXT01 = " +pr oduct t ype+" AND 7. CLOGTXT04 = Mat er i al " ; }
NOTE: Because you are using an alias (producttype) and you want to take that value as entered and
submit it as a query against Products, it cannot be contained within the double quotation marks
because it is not a fixed value. Therefore, you must close the quotation marks and insert a plus
symbol (+) before and after the alias name, and then reopen the quotation marks for the remaining
item. After producttype, you must use the AND parameter because you are inserting another
condition that must be met (type = Material).
JavaScript excludeFromPreload
Function in Quick Selector Lists
When a reference field is included in a quick selector list in Oracle CRM On Demand Disconnected
Mobile Sales, provided there is no conditionQuery or fieldsOnFilter JavaScript defined, the default
behavior is to preload the quick selector table with all parents found for the parent listed in the
reference field.
A requirement for Products Detailed is to allow users to preload only certain reference fields using
JavaScript (such as products), while allowing users to select parents from a list (for example,
Objective or Next Objective). To do this, a method for selecting which parents to exclude from being
preloaded is needed. The excludeFromPreload function allow users to choose which fields are not
automatically preloaded.
To use the excludeFromPreload function in Oracle CRM On Demand Disconnected Mobile Sales, you
must add it to a quick selector list as shown in the following procedure.
To use the exlcudeFromPreload function in a quick selector list
1 Start the Admin application.
2 Click Quick Selector on the vertical application bar, then select the quick selector list that you
want to modify.
3 Add the reference field you want to exclude from preloading to the list of columns for the quick
selector (if it does not already exist).
4 Edit or create a required filter.
5 Insert the following function after the HTML header, but before any conditionQuery or
fieldsOnFilter code, where xxxxxx is the ME Field Name of the reference field (for example,
CUSTREF1):
f unct i on excl udeFr omPr el oad( ) { r et ur n " xxxxxx" ; }
You can include more than one field in the function, by separating the fields returned by a
comma, for example, as follows:
{ r et ur n " xxxxxx, yyyyyy" ; }
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales JavaScript excludeFromPreload Function in Quick Selector Lists
80
DRAFT - Modified May 27, 2014 4:45 pm
6 Save the changes and deploy the updated metadata configuration to users for the changes to
take effect.
An example of the complete code for adding the excludeFromPreload function to the Product Detailed
QS list, with header and footer information, is as follows:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on excl udeFr omPr el oad( ) { r et ur n " CUSTREF3, CUSTREF4" ; }
f unct i on condi t i onQuer y( ) {
r et ur n DMS. condi t i onQuer y( PRODDETAI LED) ;
}
f unct i on f i el dsOnFi l t er ( ) {
r et ur n DMS. f i el dsOnFi l t er ( [ APPOI NTMENT. STARTTI ME. par ent ,
ALLOCATI ON. ENDDATE. f ul l ] ) ;
}
f unct i on onFi l t er ( cal l St ar t Dat e, Al l ocEndDat e) {
i f ( cal l St ar t Dat e <= Al l ocEndDat e| | Al l ocEndDat e == ' nul l ' ) {
r et ur n t r ue;
} el se {
r et ur n f al se;
}
}
</ scr i pt ></ head><body></ Body></ ht ml >
This example returns a blank field where the reference field is listed. Users are able to select a parent
to associate with the record being created. The following assumptions are made in this example:
The Objective or Next Objective exist as a parent object.
Product Detailed contains a reference to these objects (Objective or Next Objective).
CUSTREF3 and CUSTREF4 are the fields in this example.
The CUSTREF3 and CUSTREF4 fields have been added to the Columns displayed in the Quick
Selector list.
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales Support for Field Condition Scripts in Quick Selector Lists
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
81
DRAFT - Modified May 27, 2014 4:45 pm
Support for Field Condition Scripts in
Quick Selector Lists
This feature relates to the excludeFromPreload function. Support for field condition scripts in quick
selector lists is available by default in Oracle CRM On Demand Disconnected Mobile Sales, and applies
when you are not preloading all reference fields with data. If any JavaScript exists in the Field
Condition field for the reference field, then the code is also implemented in the quick selector list.
As a result, users see the same records in the quick selector list as they see when clicking a reference
field to select a parent to associate with a record. That is, if adding a single record using the standard
data entry form.
No additional configuration is required to provide support for field condition scripts in quick selector
lists. Any existing filters defined in the Field Condition field are used and still apply. However, to be
able to select a parent (rather than all possible values being preloaded), an excludeFromPreload
parameter must exist in the JavaScript Required filter.
Using showViewAll to Control the
Display of the View All Button
The ability to disable the View All button for reference fields in Oracle CRM On Demand Disconnected
Mobile Sales for Tablets has been implemented. To prevent the View All button from appearing in the
client application on user devices, the following showViewAll parameter must be added to the
condi t i onQuer yJ SON( ) function:
\ " showVi ewAl l \ " : \ " no\ "
The showViewAll parameter can have two possible values:
yes. Indicates to display the view all button.
no. Indicates to hide the view all button.
To preserve any existing functionality (where the View All button is displayed), no change is required
on the field condition code. If the code does not exist, then the View All button is displayed.
The showViewAll parameter must be added to the first parameter defined after the action command.
In the following example, it is added immediately after the get condi t i on action with a comma
separating the elements:
f unct i on condi t i onQuer yJ SON( ) { r et ur n " [
{\ " act i on\ " : \ " get condi t i on\ " , \ " f i l t er \ " : \ " CLOGSTATUS! =Submi t t ed and CLOGSTATUS ! =
Si gned\ " } ] " ; }
f unct i on condi t i onQuer yJ SON( ) { r et ur n " [
{\ " act i on\ " : \ " get condi t i on\ ", \ " showVi ewAl l \ " : \ " no\ ", \ " f i l t er \ " : \ " CLOGSTATUS! =Submi
t t ed and CLOGSTATUS ! = Si gned\ " } ] " ; }
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript Code to Filter Information in Oracle CRM On Demand Disconnected
Mobile Sales Using showViewAll to Control the Display of the View All Button
82
DRAFT - Modified May 27, 2014 4:45 pm
In the following example, the showViewAll parameter is added immediately after the Sel ect action:
f unct i on condi t i onQuer yJ SON( ) {
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " get Condi t i onQuer r y\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 25\ " , \ " f i el ds\ " : \ " CUSTREF2\ " } ] ,
\ " f i l t er \ " : \ " \ " , \ " i sf r omscr een\ " : \ " yes\ " } ] } ] " ;
}
f unct i on condi t i onQuer yJ SON( ) {
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " showVi ewAl l \ " : \ " no\ ", \ " i nvoke\ " : \ " get Condi t i onQuer r y\ " , \ "
par amet er s\ " : [ {\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 25\ " , \ " f i el ds\ " : \ " CUSTREF2\ " }
] , \ " f i l t er \ " : \ " \ " , \ " i sf r omscr een\ " : \ " yes\ " } ] } ] " ;
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
83
DRAFT - Modified May 27, 2014 4:45 pm
7 Using JavaScript to Invoke
Actions in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter describes how to use JavaScript code to implement a quick action or custom action
button. It includes the following topics:
Using JavaScript to Implement Quick Action and Custom Action Buttons on page 83
JavaScript Button Functions on page 83
Passing Data to an External Application on page 84
Calling External Applications From Oracle CRM On Demand Disconnected Mobile Sales on page 85
Integrating Oracle CRM On Demand Disconnected Mobile Sales with External Applications on
page 91
Using JavaScript to Implement Quick
Action and Custom Action Buttons
You can use JavaScript code to implement a quick action or custom action button in the Admin
application. For more information, see the following:
To configure custom action buttons, see Adding JavaScript Code to Modules on page 28.
To configure quick action buttons, see Adding JavaScript Code to Buttons on page 32.
To configure a quick action button for an external application, see Adding JavaScript Code for
External Application Configuration on page 33.
To configure a Detailer button for Activities and Appointments, see Adding JavaScript Code to the
Detailer Button on page 33.
Passing Data to an External Application on page 84
Calling External Applications From Oracle CRM On Demand Disconnected Mobile Sales on page 85
JavaScript excludeFromPreload Function in Quick Selector Lists on page 79
JavaScript Button Functions
When using a function to implement a custom button, the following JavaScript reference functions
are available:
openExternalApp. You can configure this function for any module to pass data to an external
application. If configured, then an Open External Application icon appears in the client application
(in the top right-hand corner) when viewing record details. This function is called when the user
taps the Open External Application icon.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Passing Data to an External Application
84
DRAFT - Modified May 27, 2014 4:45 pm
onActionJSON. You can configure a custom action button to perform a custom action by adding
a JavaScript function of type CustomActions (where Type is equal to CustomActions) to the
module of your choice. Once configured, the custom action button appears for the module in
client applications, and the onActionJSON function is called whenever a user selects the custom
action button.
Passing Data to an External Application
When viewing a record, you can pass data to an external application, using a simple query to read
the current fields and to pass them to the external application. In the following example, data is
passed from the current module (Module ID 7) to the external application with the App URL
testsales://spots/.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
var ext er nal AppUr l ;
f unct i on openExt er nal App( r ows) {
ext er nal AppUr l = " t est sal es: / / spot s/ " ;
i f ( r ows. l engt h > 0) {
ext er nal AppUr l += " Cal l I d=" + r ows[ 0] . _7. ui d + " &Cont act =" + r ows[ 0] . _7. CLOGREF2 +
" &DUE DATE=" + r ows[ 0] . _7. CLOGDT01 + " &START TI ME=" + r ows[ 0] . _7. CLOGSTARTTI ME +
" &STATUS=" + r ows[ 0] . _7. CLOGSTATUS + " &SUBJ ECT=" + r ows[ 0] . _7. CLOGTXT01 +
" &PAPERSI GN=" + r ows[ 0] . _7. CLOGKW04;
}
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " ur l \ " : \ " " + ext er nal AppUr l + " \ " }] " ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
var ext er nal AppUr l ; creates an externalAppUrl variable.
f unct i on openExt er nal App( r ows) defines the function to open the external application, and
prepares the rows to pass from the current record to the function.
" t est sal es: / / spot s/ " is the first value entered into the externalAppUrl variable, so it contains
some data.
i f ( r ows. l engt h > 0) { inserts an if query so that the action is only completed if the current
record contains data.
When all the fields are added to the externalAppUrl variable, the fields being written to are
inserted, followed by the field being sent from the current object (Module ID 7). The code used
is as follows:
ext er nal AppUr l +=" Cal l I d=" +r ows[ 0] . _7. ui d +" &Cont act =" +r ows[ 0] . _7. CLOGREF2
+ " &DUE DATE=" + r ows[ 0] . _7. CLOGDT01 + " &START TI ME=" + r ows[ 0] . _7. CLOGSTARTTI ME
+ " &STATUS=" + r ows[ 0] . _7. CLOGSTATUS + " &SUBJ ECT=" + r ows[ 0] . _7. CLOGTXT01 +
" &PAPERSI GN=" + r ows[ 0] . _7. CLOGKW04;
The following fields are added to the variable (the destination is listed first, followed by the
source field):
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
85
DRAFT - Modified May 27, 2014 4:45 pm
Cal l I d=ui d
Cont act =CLOGREF2
DUE DATE=CLOGDT01
START TI ME=CLOGSTARTTI ME
STATUS=CLOGSTATUS
SUBJ ECT=CLOGTXT01
PAPERSI GN=CLOGKW04
The goToURL function is executed, and all of the values stored in the externalAppUrl variable are
inserted. The code used is as follows:
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " ur l \ " : \ " " + ext er nal AppUr l + " \ " }] " ;
Calling External Applications From
Oracle CRM On Demand Disconnected
Mobile Sales
This example shows you how to call an external application from within the Oracle CRM On Demand
Disconnected Mobile Sales application. It includes the following topics:
Example Overview on page 85
Oracle CRM On Demand Disconnected Mobile Sales Configuration on page 86
Starting the Oracle Social Network on page 88
Writing the External Web Page on page 88
Example Overview
The example in this appendix calls a Web page hosted locally, shows the data in an HTML table, and
upon submit redirects to the Oracle CRM On Demand Disconnected Mobile Sales application showing
the original record that was open before the outbound call. The overall steps in this example, which
are the typical steps for calling external applications from within the Oracle CRM On Demand
Disconnected Mobile Sales application, are:
Call the external application from within the Oracle CRM On Demand Disconnected Mobile Sales
application.
Pass data from the Oracle CRM On Demand Disconnected Mobile Sales application to the external
application.
Return to the same record that was open in the Oracle CRM On Demand Disconnected Mobile
Sales application before launching the external application.
The following assumptions are made in this example:
The Oracle CRM On Demand Disconnected Mobile Sales Server and client is version 1.8 or later.
The Contacts module is available.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
86
DRAFT - Modified May 27, 2014 4:45 pm
A Web container (for example, nodejs) is available, which can listen for HTTP requests.
Oracle CRM On Demand Disconnected Mobile Sales
Configuration
There are two places where JavaScript code must be configured in Oracle CRM On Demand
Disconnected Mobile Sales for this example. For more information, see the following:
Preserving the devicerowid on page 86
Writing the openExternalApp Function on page 87
Preserving the devicerowid
Typically, the application which receives the call from Oracle CRM On Demand Disconnected Mobile
Sales must have the devicerowid to query Oracle CRM On Demand for the actual record. As a result,
the devicerowid must be synchronized with Oracle CRM On Demand as well. The following procedure
shows you how to update the devicerowid field and synchronize the changes with Oracle CRM On
Demand.
To update the devicerowid field and synchronize the changes with Oracle CRM On
Demand
1 Choose a field in Oracle CRM On Demand to set aside for storing the devicerowid of a record.
For example, use CONTTXT01 which is the ME field used to store the Description in the Contact
module.
2 Create an onSaveJSON function in the Contact module as follows:
a Start the Admin application.
b Click Map Settings, and then select Module Settings on the vertical application bar.
c Click More next to the Contact module, click JavaScript, and then select Add JavaScript Code.
d Select onSave from the Type drop-down list, and then enter the onSave JavaScript code.
An example of the complete code with header and footer information follows. In this example, the
uid and the devicerowid of the newly created Contact record are read and the IDs are passed to
the UpdateCRMODDeviceRowId method, which updates the CONTXT01 field with the devicerowid.
The devicerowid is synchronized with the Description field in Oracle CRM On Demand.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onSaveJ SON( )
{
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " updat eCRMODDevi ceRowI d\ " , \ " par amet er s\ " : [ {\ "
modul ef i el ds\ " : [ { \ " modul e\ " : \ " 2\ " , \ " f i el ds\ " : \ " ui d, devi cer owi d\ " } ] ,
\ " f i l t er \ " : \ " 2. ui d=$2. ui d\ " } ] } ] " ;
}
f unct i on updat eCRMODDevi ceRowI d( r ows)
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
87
DRAFT - Modified May 27, 2014 4:45 pm
{
var j sonscr i pt = " [ " ;
i f ( r ows. l engt h > 0) { j sonscr i pt +=
" {\ " act i on\ " : \ " updat e\ " , \ " modul e\ " : \ " 2\ " , \ " ui d\ " : \ " " + r ows[ 0] . _2. ui d +
" \ " , \ " f i el ds\ " : [ { \ " f i el d\ " : \ " CONTTXT01\ " , \ " val ue\ " : \ " " +r ows[ 0] . _2. devi cer owi d
+" \ " } ] , \ " upsync\ " : \ " yes\ " , \ " f i l t er \ " : \ " 2. ui d =" +r ows[ 0] . _2. ui d+" \ " }" ; }
j sonscr i pt += " ] " ;
r et ur n j sonscr i pt ;
}
f unct i on onEr r or I nvoke( r ows) {
i f ( r ows. l engt h > 0) {
wi ndow. l ocat i on=" mel t : / / showAl er t : " + r ows[ 0] . message; }
}
</ scr i pt ></ head><body></ body></ ht ml >
Writing the openExternalApp Function
You must write an openExternalApp function to configure a quick action button to load an external
application.
To write an openExternalApp function
1 Start the Admin application.
2 Click Map Settings, and then select Module Settings on the vertical application bar.
3 Click More next to the Contact module, and then select Quick Action.
4 Click Add in the External App Configuration section to configure a new action.
5 Configure the fields for the external application as follows:
a App URL. Enter the application URL that loads the external application into the App URL input
box.
b Display Value. Enter a display value to identify the external application. The display value is
the name that appears when the user selects the quick action button in the client application.
c Enter the JavaScript Object Notation (JSON) code into the input box.
d Create the openExternalApp function, which contains the logic for calling out to the external
application, and enter the code into the input box.
An example of the complete code for the openExternalApp function, with header and footer
information, is as follows.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on openExt er nal App( r ows)
{
var ext er nal AppURL=" ht t p: / / l ocal host / Test . ht ml " ;
ext er nal AppURL+=" ?Cont Fr st Name=" +r ows[ 0] . _2. CONTFI RSTNAME;
ext er nal AppURL+=" &Cont Lst Name=" +r ows[ 0] . _2. CONTLASTNAME;
ext er nal AppURL+=" &Pr esRowI d=" +r ows[ 0] . _2. CONTTXT01;
ext er nal AppURL+=" &I d=" +r ows[ 0] . _2. ui d;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
88
DRAFT - Modified May 27, 2014 4:45 pm
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " noescape\ " : \ " t r ue\ " , \ " ur l \ " : \ " " +
ext er nal AppURL + " \ " } ] " ;
}
</ scr i pt ></ head></ ht ml >
In this example, note the following key points:
A call out to a Web page is made. The First name, Last name, and CONTTXT01 values of the
Contact are passed over to display on the Web page. The Web page has a submit button,
which launches the Oracle CRM On Demand Disconnected Mobile Sales client application.
The externalAppURL variable holds the value of the URL, which is to be called out. Data is
passed from the Contact using the query parameters in the URL.
Passing the record row ID, r ows[ 0] . _2. ui d, helps the external application to determine
which record is being viewed.
The goToURL action calls out to the external application URL, which opens the Safari browser
and loads the requested URL.
NOTE: There is a noescape parameter in the goToURL action, which specifies whether or not to
encode the URL. The noescape parameter can be set to either True or False. Do not use spaces
in the URL when setting to True (noescape=true) or False (noescape=false).
Starting the Oracle Social Network
Starting the Oracle Social Network uses the openExternalApp function, but requires a special syntax
to launch it properly. The following code sample illustrates this use of openExternalApp.
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
var ext er nal AppUr l ;
f unct i on openExt er nal App( r ows) {
ext er nal AppUr l = " osn: / / ?act i on=openConver sat i on&conver sat i onI D=18430823" ;
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " noescape\ " : \ " t r ue\ " , \ " ur l \ " : \ " " +
ext er nal AppUr l + " \ " }] " ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
Writing the External Web Page
The following code creates an HTML page to show the query parameters in a table, as well as two
submit buttons. The submit button redirects the Web page back to the Oracle CRM On Demand
Disconnected Mobile Sales application based on the query parameters Id (which stores the uid
value) and PresRowId (which stores the devicerowid value) that were passed to the Web page from
the Oracle CRM On Demand Disconnected Mobile Sales application.
NOTE: After the Oracle CRM On Demand Disconnected Mobile Sales application synchronizes with
Oracle CRM On Demand, the Submit button which uses the devicerowid is no longer able to find the
record, because the ID of the record is overwritten with the ID generated by Oracle CRM On Demand
and stored in the uid field of the record.
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
89
DRAFT - Modified May 27, 2014 4:45 pm
The inbound URL to launch Oracle CRM On Demand Disconnected Mobile Sales is:
" Or acl eCRMODDMS: / / Modul eLaunch?Modul eI d=2&I d=" +d;
The complete code example with header and footer information is as follows:
<ht ml >
<head>
<st yl e>
ht ml {over f l ow- y: scr ol l ; }
body{
f ont - si ze: 12px;
col or : #000000;
backgr ound- col or : #F6F4F0;
mar gi n: 0px;
wi dt h: 960px;
}
p, t d, ul {
l i ne- hei ght : 140%;
}
body, p, h1, h2, h3, h4, t abl e, t d, t h, ul , ol , t ext ar ea, i nput {
f ont - f ami l y: ver dana, hel vet i ca, ar i al , sans- ser i f ;
}
i f r ame {mar gi n: 0px; }
di v {wi dt h: 100%; }
i mg {bor der : 0; }
t abl e, t h, t d, i nput , t ext ar ea{
f ont - si ze: 100%;
}
t abl e {
mar gi n- l ef t : 30px;
}
t abl e. r ef er ence, t abl e. t ecspec{
bor der - col l apse: col l apse; wi dt h: 100%;
}
t abl e. r ef er ence t r : nt h- chi l d( odd) {backgr ound- col or : #F6F4F0; }
t abl e. r ef er ence t r : nt h- chi l d( even) {backgr ound- col or : #f f f f f f ; }
t abl e. r ef er ence t r . f i xzebr a {backgr ound- col or : #F6F4F0; }
t abl e. r ef er ence t h{
col or : #f f f f f f ; backgr ound- col or : #555555; bor der : 1px sol i d #555555; f ont -
si ze: 12px; paddi ng: 3px; ver t i cal - al i gn: t op; t ext - al i gn: l ef t ;
}
t abl e. r ef er ence t h a: l i nk, t abl e. r ef er ence t h a: vi si t ed{
col or : #f f f f f f ;
}
t abl e. r ef er ence t h a: hover , t abl e. r ef er ence t h a: act i ve{
col or : #EE872A;
}
t abl e. r ef er ence t d{
bor der : 1px sol i d #d4d4d4; paddi ng: 5px; paddi ng- t op: 7px; paddi ng- bot t om: 7px; ver t i cal -
al i gn: t op;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Calling External Applications From Oracle CRM On Demand Disconnected Mobile
90
DRAFT - Modified May 27, 2014 4:45 pm
}
t abl e. r ef er ence t d. exampl e_code
{
ver t i cal - al i gn: bot t om;
}
</ st yl e>
<scr i pt t ype=" t ext / j avascr i pt " >
onl oad=f unct i on( ) {
var nr Col s=2;
var maxRows=4;
var nr Rows=maxRows+1;
var r oot =document . get El ement ByI d( ' myi d' ) ;
var t ab=document . cr eat eEl ement ( ' t abl e' ) ;
t ab. cl assName=" r ef er ence" ;
var t bo=document . cr eat eEl ement ( ' t body' ) ;
var r ow, cel l ;
var i nput But t on;
var i nput But t on1;
r ow=document . cr eat eEl ement ( ' t h' ) ;
r ow. appendChi l d( document . cr eat eText Node( " Quer y Par am" ) ) ;
t bo. appendChi l d( r ow) ;
r ow=document . cr eat eEl ement ( ' t h' ) ;
r ow. appendChi l d( document . cr eat eText Node( " Quer y Val ue" ) ) ;
t bo. appendChi l d( r ow) ;
var a=document . URL;
var b=a. spl i t ( " ?" ) ;
var c=b[ 1] . spl i t ( " &" ) ;
d = nul l ;
f or ( var i =0; i <c. l engt h; i ++) {
i f ( c[ i ] . spl i t ( " =" ) [ 0] ==' Pr esRowI d' ) {
i nput But t on1=document . cr eat eEl ement ( " BUTTON" ) ;
i nput But t on1. appendChi l d( document . cr eat eText Node( " Devi ceRowI d" ) ) ;
d = ( c[ i ] . spl i t ( " =" ) ) [ 1] ;
i nput But t on1. addEvent Li st ener ( ' mouseup' , f unct i on( ) {
wi ndow. l ocat i on = " Or acl eCRMODDMS: / / Modul eLaunch?Modul eI d=2&I d=" +d;
}) ;
cont i nue;
}
i f ( c[ i ] . spl i t ( " =" ) [ 0] ==' I d' ) {
i nput But t on=document . cr eat eEl ement ( " BUTTON" ) ;
i nput But t on. appendChi l d( document . cr eat eText Node( " Ui d" ) ) ;
d = ( c[ i ] . spl i t ( " =" ) ) [ 1] ;
i nput But t on. addEvent Li st ener ( ' mouseup' , f unct i on( ) {
wi ndow. l ocat i on = " Or acl eCRMODDMS: / / Modul eLaunch?Modul eI d=2&I d=" +d;
}) ;
cont i nue;
}
r ow=document . cr eat eEl ement ( ' t r ' ) ;
f or ( var j =0; j <nr Col s; j ++) {
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
91
DRAFT - Modified May 27, 2014 4:45 pm
cel l =document . cr eat eEl ement ( ' t d' ) ;
cel l . appendChi l d( document . cr eat eText Node( c[ i ] . spl i t ( " =" ) [ j ] ) )
r ow. appendChi l d( cel l ) ;
}
t bo. appendChi l d( r ow) ;
}
t ab. appendChi l d( t bo) ;
r oot . appendChi l d( t ab) ;
r oot . appendChi l d( i nput But t on) ;
r oot . appendChi l d( i nput But t on1) ;
}
</ scr i pt >
</ head>
<body>
<di v i d=" myi d" ></ di v>
</ body>
</ ht ml >
Integrating Oracle CRM On Demand
Disconnected Mobile Sales with External
Applications
This topic introduces how to integrate Oracle CRM On Demand Disconnected Mobile Sales with
external applications. It includes the following topics:
Starting the Oracle CRM On Demand Disconnected Mobile Sales Application from External
Applications on page 91
Starting External Applications from the Oracle CRM On Demand Disconnected Mobile Sales
Application on page 93
Starting the Oracle CRM On Demand Disconnected
Mobile Sales Application from External Applications
You can start the Oracle CRM On Demand Disconnected Mobile Sales application with or without
context information from an external application in iPad, and then proceed to use the Oracle CRM On
Demand Disconnected Mobile Sales application from within the external application. To configure the
Oracle CRM On Demand Disconnected Mobile Sales application to start from an external application
on iPad, the following components are required in the order listed:
OracleCRMODDMS://ModuleLaunch. The URL to launch the Oracle CRM On Demand
Disconnected Mobile Sales application where OracleCRMODDMS:// is the registered application
URL, and ModuleLaunch is the application command to launch a module.
ModuleId. The module ID for the top-level (or parent) module that you want the Oracle CRM On
Demand Disconnected Mobile Sales application to launch with. For example, you can configure
the application to launch with the Signature, Call, Account, or Contact modules.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
92
DRAFT - Modified May 27, 2014 4:45 pm
Context information. You can specify context information in the form of the following:
Id. The record Id (for example, activity, contact, or account ID) within the top-level module that
you want the Oracle CRM On Demand Disconnected Mobile Sales application to start with.
Context information must always be provided if you want the Oracle CRM On Demand
Disconnected Mobile Sales application to start with the Signature page. If context information is
not provided, then an error occurs.
Context information is optional if you want the Oracle CRM On Demand Disconnected Mobile
Sales application to start with the Appointment, Account, or Contact modules. If you do not
specify context information for the Appointment, Account, or Contact modules, then the Oracle
CRM On Demand Disconnected Mobile Sales application starts with no context information
showing the corresponding module list.
Example URL API Addresses
In the following example, the inbound URL API address starts the Oracle CRM On Demand
Disconnected Mobile Sales application from an external application with the Account screen for a
specific account:
Or acl eCRMODDMS: / / Modul eLaunch?Modul eI d=1&I d=A1234
The following inbound URL API address starts the Oracle CRM On Demand Disconnected Mobile Sales
application from an external application with the Contact screen, and there is no context information:
Or acl eCRMODDMS: / / Modul eLaunch?Modul eI d=2
Modules Supported by the ModuleLaunch Command
ModuleLaunch is an inbound API command. The ModuleLaunch command only supports navigation
to the following top-level modules in the Oracle CRM On Demand Disconnected Mobile Sales
application:
Appointment (Call, Activity)
Account
Contact
Signature
NOTE: This launches the signature page directly for calls that do not have a signature capture.
Other top-level modules, such as custom objects.
Obtaining the ModuleId
Use the following procedure to obtain the module ID for a module.
To obtain the moduleI d for a module
1 Start the Admin application.
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
93
DRAFT - Modified May 27, 2014 4:45 pm
2 Click Map Settings, then Module Settings on the vertical navigation bar.
The Module Mapping page opens showing the list of mapped modules and the corresponding
module settings configured for each module.
3 The Module ID field, which is read-only, indicates the module ID for the module.
Screen and User Key Mappings
For each top-level module that can be used to start the Oracle CRM On Demand Disconnected Mobile
Sales application from an external application in iPad, you can specify to start the module and to
navigate directly to a specific record by specifying the user key based on the module screen and user
key mappings in Table 11.
NOTE: You can also use other sets of user keys to start a top-level module in the Oracle CRM On
Demand Disconnected Mobile Sales application.
Starting External Applications from the Oracle CRM On
Demand Disconnected Mobile Sales Application
You can start an external application from the Oracle CRM On Demand Disconnected Mobile Sales
application by configuring a quick action button to launch the external application. When starting an
external application from within the Oracle CRM On Demand Disconnected Mobile Sales application,
you can pass key field values for the current parent record.
NOTE: URL lengths are limited by the operating system and the destination application. When a limit
is encountered, the destination truncates the URL without warning. Keep URLs short to avoid
truncation. Use short URL parameter names and limit the number of fields in the URL. It is also
recommended that you test your outbound URLs with the target application on the target user
device. For reference, 2000 characters is a popular destination application URL length limit.
Configuring a Quick Action Button to Launch an External Application
You can configure quick action buttons for the following modules: Appointment (Call), Account,
Contact, and Signature. To configure a quick action button to launch an external application, you
must configure the quick action button first, and then complete the following procedure. You can
configure more than one external application URL for a quick action button.
Table 11. Module Screen and User Key Mappings
Module Screen User Keys Comment
Signature Activity Id Signature can only be started with a context. Signature
cannot be started without a context.
Account Account Id Account can be started with or without a context.
Contact Contact Id Contact can be started with or without a context.
Call Activity Id Call can be started with or without a context.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
94
DRAFT - Modified May 27, 2014 4:45 pm
To configure a button to launch an external application
1 Configure a quick action button.
For more information, see Using JavaScript to Implement Quick Action and Custom Action Buttons
on page 83.
2 Configure the quick action button to launch an external application as follows:
a Click Map Settings, then Module Settings on the vertical navigation bar.
b Click More next to the module that you want, and then select Quick action.
The Quick Action Configuration window opens.
c In the External App Configuration section, click Add.
The New External App window opens.
d Complete the following fields:
App URL. Enter the application URL that loads the external application. The URL that you
enter must be the external application custom URL up to but not including the command
portion of the URL. The URL can include the following: URL scheme, server name (if there is
one), and server port (if there is one). An example of a valid URL is as follows:
http://www.oracle.com
App Command. Enter an optional command for the application. App Command represents
the path or page part of the application custom URL. The format varies for different
applications. Include any delimiters that follow the application URL and precede the key
values. In a typical Web URL, this includes the leading slash (/) and the training question
mark (?).
Display Value. This field must exactly match the entry for the quick action buttons Name
field.
Key Name. Enter a key name. Include the name and value pairs where the name is the
custom URL parameter name and the value comes from the active records on the current
page. Lists of records are not supported. The values must be Oracle CRM On Demand
Disconnected Mobile Sales Server names for the related fields that are mapped. The key
values are URL encoded when they are written to the custom URL.
Module Names. Choose an applicable module name from the menu. You can currently
configure a button to launch an external application from the following modules:
Appointment, Account, Contact, Address, and Signature.
Value. Choose an applicable value from the menu.
e Click Add, and then click Save.
3 To configure more than one external application URL for the quick action button, repeat Step 2
as required.
4 To change the button order, revise the order numbers to the left of each button and then click
Submit Order Changes.
5 To edit an existing button, click its Edit button.
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
95
DRAFT - Modified May 27, 2014 4:45 pm
6 To remove an existing button, click its Remove button.
7 When finished, click Submit Order Changes.
Configuring a Simple External Application URL for an External
Application Button
You can configure a simple external application URL for an external application button by specifying
the application URL in the App URL field and then adding the JavaScript for the application URL as
shown in the following procedure.
To configure an external application button to launch a simple external application
URL
1 Click Map Settings, then Module Settings on the vertical navigation bar.
2 Click the Action button next to the module that you want.
3 Click More next to the module that you want, and then select Quick action.
4 In the External App Configuration section, click Add.
The New External App window opens.
5 Complete the following fields:
App URL. Enter the application URL that loads the external application in, for example, one
of the following formats:
<URL scheme or ser ver name>: / /
<App_Name>: / / <some_gener i c_val ue>
where:
<App_Name>is the application name.
<some_gener i c_val ue>can be phone number, email address, ?, or something else as
defined by the target application that you want to launch.
For example:
ht t p: / /
<App_Name>: / / CELL_PHONE_NUMBER
<App_Name>: / / EMAI L_ADDRESS
<App_Name>: / / ?
Display Value. Enter a display value to match or identify the external application URL.
6 In the text box, enter the JavaScript to launch the external application URL, for example, as
follows:
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
var ext er nal AppUr l ;
f unct i on openExt er nal App( r ows) {
ext er nal AppUr l =" ht t p: / / www. or acl e. com/ " ;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using JavaScript to Invoke Actions in Oracle CRM On Demand Disconnected Mobile
Sales Integrating Oracle CRM On Demand Disconnected Mobile Sales with External
96
DRAFT - Modified May 27, 2014 4:45 pm
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " ur l \ " : \ " " + ext er nal AppUr l + " \ " }] " ;
}
</ scr i pt ></ head><body></ Body></ ht ml >
The externalAppURL variable must be set to the same value as the App URL in Step 5.
7 Click Save, and then click Submit Order Changes.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
97
DRAFT - Modified May 27, 2014 4:45 pm
8 Using Actions in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter introduces actions and describes how to use actions in Oracle CRM On Demand
Disconnected Mobile Sales. It includes the following topics:
About Actions on page 97
JSON Select Action on page 102
JSON Update Action on page 105
JSON Insert Action on page 106
JSON Validate Action on page 107
JSON goToURL Action on page 107
JSON getCondition Action on page 108
JSON Showprompt Action on page 109
Example of Invoked Function on page 110
About Actions
JavaScript Object Notation (JSON) event handlers allow complex operations to be performed
between the event handler implementation (in JavaScript) and the application. This is done by having
the event handler pass back an array of actions using JSON.
As with all JavaScript code, actions are only performed against records on a mobile device. Oracle
CRM On Demand Disconnected Mobile Sales cannot run an action or query against the Oracle CRM
On Demand database.
Before beginning to write any code involving actions, identify the following:
The MODULEID of all modules that are being queried, read, or modified.
The MEFIELDID of any fields being queried, read, or modified.
For more information about identifying these items, see Obtaining Module ID and Field Name
Information on page 22.
Each JSON event handler is capable of returning a different set of actions. For more information
about the set of actions supported by an event handler, see Functions Returning Actions on page 98
and JavaScript Object Notation Actions on page 98.
To code an array of actions, use JSON to return the array of actions. Note that an array must be
returned even if there is only one action. As a result, the return value of every JSON event handler
looks similar to the following:
r et ur n " [ { comma separ at ed l i st of act i ons }] "
The return value must always be string encoded.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales About Actions
98
DRAFT - Modified May 27, 2014 4:45 pm
Functions Returning Actions
Actions are returned by the following predefined functions:
openExternalApp. You can configure this event for any module to pass data to an external
application. If configured, then an Open External Application icon appears in the client application
(in the top right-hand corner) when viewing record details. This event is called when the user
taps the Open External Application icon.
onAcceptAndSign. The Accept and Sign button appears on the Signature page in the client
application. When a user selects Accept and Sign, the onAcceptAndSign event is called. You
configure the AcceptAndSign event in the Signature module.
doneSignature. The Done button appears on the Signature page in the client application. When
a user selects Done, the doneSignature event is called. You configure the doneSignature event
in the Appointments and Attendee Call modules.
onSubmitCall. The Submit button appears in the client application (top left-hand corner) when
viewing record details for Account, Professional, or Attendee Calls. When a user selects Submit,
the onSubmitCall event is called. You configure the onSubmitCall event in the Appointments and
Attendee Call modules.
onActionJSON. You can configure a custom action button to perform a custom action by adding
a JavaScript function of type CustomActions (where t ype is equal to Cust omAct i ons) to the
module of your choice. When configured, the custom action button appears for the module in
client applications, and the onActionJSON event is called whenever a user selects the custom
action button.
onPreSaveJSON. The Save and Save and New buttons appear for modules in the client
application when editing or creating records. When a user selects either of these buttons, the
onPreSaveJSON event is called. You can configure the onPreSaveJSON event in any module that
has the Save and Save and New buttons, and onPreSaveJSON is called before the record is saved.
You use the onPreSaveJSON event for data validation, and to either allow or prevent record
saving.
onSaveJSON. The Save and Save and New buttons appear for modules in the client application
when editing or creating records. When a user selects either of these buttons, the onSaveJSON
event is called. You can configure the onSaveJSON event in any module that has the Save and
Save and New button, and onSaveJSON is called after the record is saved.
conditionQueryJSON. You can add JavaScript expressions to the Field Condition attribute of a
field to apply filters to the field or to a quick selector. When filters are defined for a field or a
quick selector, the conditionQueryJSON event is called.
onValidateJSON. This event validates a quick selector before performing a save, and is
considered to be a soft stop rather than a hard stop. You can still save records if validation of the
quick selector, as specified by the onValidateJSON event, fails.
JavaScript Object Notation Actions
Table 12 describes the JSON actions that you can use in JavaScript code.
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales About Actions
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
99
DRAFT - Modified May 27, 2014 4:45 pm
Table 12. JSON Actions
Action Type Description
Select Primary Action Defines which modules and fields to use to determine when
an action is performed. You also use the Select function to
filter which records are read. For more information, see
JSON Select Action on page 102.
Update Primary or
Secondary Action
Updates an existing record with new values. You use Update
almost exclusively as a secondary action, after using Select
and Invoke to read data and perform data validation.
You can also use Update as a primary action. In this case,
the Update action runs when the predefined JSON function
button is selected and no data validation or checks are
carried out.
For more information, see JSON Update Action on
page 105.
Insert Primary or
Secondary Action
Creates a new record, and inserts values into any of the
fields within that record. You use Insert almost exclusively
as a secondary action.
You can also use Insert as a primary action. In this case, the
Insert action runs when the predefined JSON function
button is selected and no validation is carried out on
existing data.
For more information, see JSON Insert Action on page 106.
Validate Secondary Action The validate action is usually performed from within an
invoked function, which determines a set of conditions. If
the conditions are met, then a variable is set to True. If the
conditions are not met, then a variable is set to False.
If a True value is included in a Validate action, then the user
is allowed to change the current record. If a False value is
included in a Validate action, then the user is not allowed to
change the current record and is returned to the data entry
page.
For more information, see JSON Validate Action on
page 107.
goToURL Alternate Action Sends data to an external application using the device URL
code for the external application. For more information, see
JSON goToURL Action on page 107.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales About Actions
100
DRAFT - Modified May 27, 2014 4:45 pm
getCondition Alternate Action Selects which records to display to the user. For more
information, see JSON getCondition Action on page 108.
Showprompt Alternate Action Presents a dialog box with a message to the user, and waits
for a response from the user. For more information, see
JSON Showprompt Action on page 109.
Table 12. JSON Actions
Action Type Description
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales About Actions
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
101
DRAFT - Modified May 27, 2014 4:45 pm
Primary and Secondary Actions
Select is a primary action in Table 12 on page 99 and all the other actions are secondary. Until a Select
action is run, there is no defined dataset, so there is nothing to perform a secondary action with.
The Select action is not just used to define a dataset. Once data is read, you can use the Invoke
command to run another set of subfunctions on the data. Within these subfunctions, you can use
conditional queries to define what to do with the data. For example, you can create queries to read
several fields and conditions, and then create the code necessary to perform one of the secondary
actions. You can run several separate checks within the same piece of code.
For example, to validate a set of data to check whether three separate conditions are met, use the
code structure shown in Validating Data on page 101.
Validating Data
The following procedure shows you how to validate data to check whether three separate conditions
are met. The procedure allows you to perform multiple checks on the data and return a number of
different outcomes before performing the secondary action, which is to run the Validate action. As a
result, the code structure follows the following format:
Action: Select
Invoke: Subfunction
Subfunction: Checks the data and performs the secondary action
To validate data
1 Perform a Select action to return a set of data.
2 Invoke the CheckValidation function, to check the following:
Check if field 1 is greater than field 2. If not, then set the result to False and display message
A.
Check if field 3 is equal to field 4. If not, then set the result to False and display message B.
Check if field 5 is less than field 6. If not, then set the result to false and display message C.
Otherwise, set the result to True.
3 Execute a Validate action from within the CheckValidation function, and then insert the result
from the query in Step 2 to either allow the record to be saved (True) or to return the user to the
data entry (False) page.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Select
Action
102
DRAFT - Modified May 27, 2014 4:45 pm
JSON Select Action
The Select action defines which fields are returned, and which subfunction to invoke to do something
with the data. You can also use a Select action to filter which data to return. The typical format of a
Select action is as follows:
\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " subFunct i on\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { f i el ds t o f et ch} ] , \ " f i l t er \ " : \ " f i l t er par amet er s\ " }]
Table 13 explains the Select action.
Table 13. JSON Select Action
Code Segment Description
" act i on\ " : This command starts the select function.
" subFunct i on\ " A subfunction performs further actions on the data returned.
" par amet er s\ " : This flag specifies which fields to return, and the filter to use to
determine from which records fields are retrieved.
All parameters are enclosed within brackets []. Within the
parameters flag, the following options are available.
{\ " modul ef i el ds\ " }
, \ " f i l t er \ " : \
{\ " modul ef i el ds\ " } The entire modul ef i el ds array is enclosed within braces {}. All
fields within these braces are read and stored in a single row of
data. Note that you can read more than one dataset by adding a
comma (,) after the closing bracket, and performing another
{\ " modul ef i el ds\ " } query.
Each set of data is stored in its own row. When the subfunction is
called, you define how you want each dataset to be named. In the
previous example, if you used three modulefields functions to
retrieve three sets of data, then you must name all three sets of
data within the subfunction that you want to invoke. For example,
use the following code to name the three datasets row1, row2 and
row3:
f unct i on subFunct i on( r ow1, r ow2, r ow3)
, \ " f i l t er \ " : \ Specifies the filter that is being used to select the dataset being
retrieved.
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Select
Action
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
103
DRAFT - Modified May 27, 2014 4:45 pm
JSON Modulefields Parameter
The [ {f i el ds t o f et ch} ] code in the modulefields parameter defines which fields are to be read.
The fields that you want to retrieve must be enclosed in brackets []. Each module that you want to
retrieve must be enclosed within braces {}. You can retrieve more than one module by inserting a
comma between each module specified. For example:
[ { f i el ds f r ommodul e1 }, { f i el ds f r ommodul e2 }, { f i el ds f r ommodul e3} ]
Table 14 describes the flags to set when defining which fields to fetch from each module.
JSON Filter Parameter
The filter parameter is complex. In the following example, which updates a sample inventory when
the Done button is selected on the Signature page, you use the filter parameter to determine how
to filter a dataset:
\ " f i l t er \ " : \ " 27. CUSTREF1 = 16. CUSTSAMPLE and 27. CUSTREF2 = 15. CUSTLOTNUMBER and
15. CUSTPRODUCT = 16. ui d and 15. ui d i n ( sel ect chi l di d f r omme_dat ar el at i on wher e
par ent t ype=7 and chi l dt ype=15 and ( par ent i d=$7. ui d or devi cer owi dpar ent =$7. ui d ) ) \ "
In this example, a dataset is returned under the following conditions:
When CUSTREF1 in Module 27 is equal to CUSTSAMPLE in Module 16
When CUSTREF2 in Module 27 is equal to CUSTLOTNUMBER in Module 15
When CUSTPRODUCT in Module 15 is equal to uid (rowid) in Module 16
The uid (rowid) in Module 15 is listed as a child record in the me_datarelation table where:
Module 7 is the parent
Module 15 is the child
The parent uid (rowid) is stored in the Module 15 record (as a rowid from Oracle CRM On Demand
or within the temporary rowid on a mobile device).
Table 14. Modulefields Parameter
Code Segment Description
\ " modul e\ " : \ " MODULEI D\ " Specifies the module ID from which to read data. For example, if
you are reading from Activities (MODULEID 7), then specify the
following:
\ " modul e\ " : \ " 7\ "
If you do not want to read any fields from the module, for example,
if you require the uid (row id), then do not set any other options.
, \ " f i el ds\ " : \
" MEFI ELDNAME\ "
Specifies the fields from which to read data. To read more than one
field, separate each field with a comma (,). You must use the
MEFIELDNAME.
, \ " f i el ds\ " : \
" count ( *) \ "
Counts the modules that have data inserted into them.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Select
Action
104
DRAFT - Modified May 27, 2014 4:45 pm
All conditions are joined with AND statements, so only rows from the dataset that meet all conditions
are retrieved. For every parent or child relationship that is in the data, there is an entry in the
me_datarelation table. Table 15 describes the columns in the me_datarelation table.
To retrieve all contacts for an account from the me_datatable, then set the following in the query:
par ent t ype = 1, chi l dt ype = 2, par ent i d=[ Account r owi d] , devi cer owi dpar ent =[
account r owi d] and r ef er encet ype=4
The resulting children are your dataset. The reason for checking both parentid and devicerowidparent
is because the records might have been created offline, and they might not have the full Oracle CRM
On Demand row ID at the time.
Table 16 describes an important flag that the filter parameter can also include.
Table 15. Filter Parameter me_datarelation Table
Column Description
par ent t ype = MODULEI D The MODULEID of a parent, which specifies the records that have a
particular parent object.
chi l dt ype = MODULEI D The MODULEID of a child, which identifies the data to which a
particular child object is associated.
par ent i d = Specifies the parent row ID of the record.
devi cer owi dpar ent = You usually use devicerowidparent in conjunction with the parentid
(explained in the previous row). The parentid only returns the
Oracle CRM On Demand row ID, but devicerowidparent also includes
any temporary row IDs stored on a device. This occurs if the device
has not managed to synchronize with the Oracle CRM On Demand
Server since the record was created.
chi l di d = Specifies the row ID of a child record.
devi cer owi dchi l d = Specifies the temporary row ID stored on a device, if the device has
not yet synchronized with Oracle CRM On Demand.
r ef er encet ype Determines the type of reference field that is being filtered. Possible
values follow. If no value is selected, then the default value is 4.
A value of 4 indicates REFERENCE fields.
A value of 14 indicates MULTI-ASSOCIATIONS.
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Update
Action
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
105
DRAFT - Modified May 27, 2014 4:45 pm
JSON Update Action
An Update action is usually defined as part of an invoked function and called from within a select
query. You can set a number of variables in the invoked function, including the row IDs of several
records. All variables and row IDs are updated as part of the same piece of code.
The typical format of an Update action follows. In this example, it is assumed that a query has been
run to determine the value of xxxrowid and the value being written to valuexxx.
[ {\ " modul e\ " : \ " MODULEI D\ " , \ " ui d\ " : \ " xxxr owi d\ " , \ " f i el ds\ " : [ {
\ " f i el d\ " : \ " MEFI ELDI D\ " , \ " val ue\ " : \ " val uexxx" \ " } ] , \ " act i on\ " : \ " updat e\ " ,
\ " upsync\ " : \ " yes\ " , \ " f i l t er \ " : \ " MODULEI D. ui d =" xxxr owi d\ " }"
where:
\ " modul e\ " : \ " MODULEI D\ " determines which module is being updated.
\ " ui d\ " : \ " xxxr owi d\ " specifies the rowid of the record that is read during the invoked function
query.
\ " f i el ds\ " : [ { \ " f i el d\ " : \ " MEFI ELDI D\ " , \ " val ue\ " : \ " val uexxx" \ " } ] specifies the field
to update, followed by the value parameter to determine the value to write to the record.
\ " act i on\ " : \ " updat e\ " executes the Update action.
\ " upsync\ " : \ " yes\ " determines whether the Update action is written to Oracle CRM On Demand
(Yes), or if only the local database stored on the device is updated (No). Synchronization upload
allows user devices to maintain a record of objects such as an updated inventory, without
submitting those changes to Oracle CRM On Demand. If no flag is specified, then upsync defaults
to Yes (update Oracle CRM On Demand).
\ " f i l t er \ " : \ " MODULEI D. ui d =" xxxr owi d\ " ensures that only the record that is read is updated
during the invoked function by specifying the row ID to update.
Table 16. Filter Parameter me_datarelation Table
Flag Description
\ " i sf r omscr een\ " : \ " yes\ " If the i sf r omscr een flag is set to Yes, then data is read from the
current module before the record is saved. Any data that is already
typed on a device by a user is read as part of the current query.
The i sf r omscr een flag is inserted at the end of the filter string after
all field conditions used to determine the filter conditions are set. A
comma is inserted and then the flag is defined, for example, as
follows:
\ " f i l t er \ " : \ " 27. CUSTREF1 = 16. CUSTSAMPLE and
27. CUSTREF2 = 15. CUSTLOTNUMBER and 15. CUSTPRODUCT =
16. ui d and 15. ui d i n ( sel ect chi l di d f r om
me_dat ar el at i on wher e par ent t ype=7 and chi l dt ype=15 and
( par ent i d=$7. ui d or devi cer owi dpar ent =$7. ui d ) ) \ " ,
\ " i sf r omscr een\ " : \ " yes\ "
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Insert
Action
106
DRAFT - Modified May 27, 2014 4:45 pm
JSON Insert Action
You use the Insert action to create a new record. Records are created either by following a Select
action or by being executed as part of an invoked function. The typical format of an Insert action is
as follows:
[ {\ " act i on\ " : \ " i nser t \ " , \ " modul e\ " : \ " MODULEI D\ " ,
\ " par ent modul e\ " : \ " PARENTMODULEI D\ " , \ " par ent ui d\ " : \ " r owi dxxx\ " , \ " f i el ds\ " :
[ { \ " f i el d\ " : \ " MEFI ELDNAME\ " , \ " val ue\ " : \ " Val ue t o i nser t \ " }
] , \ " upsync\ " : \ " yes\ " }]
where:
\ " act i on\ " : \ " i nser t \ " starts the Insert action.
\ " modul e\ " : \ " MODULEI D\ " defines the type of record to create. If you are creating a record
within module 18 for example, then replace MODULEID with 18.
\ " par ent modul e\ " : \ " PARENTMODULEI D\ " specifies which record to relate this object to (if
applicable) using the parentmodule parameter. PARENTMODULEID is replaced with the module
number of the parent object.
\ " par ent ui d\ " : \ " r owi dxxx\ " determines the exact record to which the new record is related.
The rowid of the parent is inserted into rowidxxx. The rowid (uid) is usually returned as a variable
from an invoked function. You can also use a Select action to select an individual record.
\ " f i el ds\ " : [ { \ " f i el d\ " : \ " MEFI ELDNAME\ " , \ " val ue\ " : \ " Val ue t o i nser t \ " } ] defines
which field is being updated and the value being written. MEFIELDNAME defines the field being
updated, and " Val ue t o i nser t \ " is replaced with the data or variable (if part of an invoked
function) that is to be inserted into the field.
\ " upsync\ " : \ " yes\ " defines whether the inserted record is written to Oracle CRM On Demand
(Yes) or only stored on the mobile device (No).
If using an Insert action to configure custom action buttons, then the Insert action also supports the
showui flag. The showui flag defines whether to display the record after insert (Yes) or not (No). The
format of an Insert action with showui is as follows:
[ {\ " act i on\ " : \ " i nser t \ " , \ " modul e\ " : \ " 7\ " , \ " par ent modul e\ " : \ " 1\ " , \ " par ent ui d\ " : \ " " +
account Det ai l s[ 0] . _1. ui d+" \ " , \ " f i el ds\ " : [ {\ " f i el d\ " : \ " CLOGKW03\ " , \ " val ue\ " : \ " Accou
nt Cal l \ " }, {\ " f i el d\ " : \ " CLOGTXT05\ " , \ " val ue\ " : \ " " +obj ect i ve+" \ "
}] , \ " upsync\ " : \ " YES\ " , \ " showui \ " : \ " YES\ " }]
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON Validate
Action
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
107
DRAFT - Modified May 27, 2014 4:45 pm
JSON Validate Action
The Validate action defines whether a user is able to perform the current action or not. For example,
if a user is trying to update or insert a new record, then the Validate action determines whether the
user can create or update the record (True), or whether to return the user to the record without
making any changes (False).
The Validate action is usually performed from within an invoked function which specifies a set of
conditions. If the conditions are not met, then a message is displayed informing users why the
change cannot be made and a False value is set. The Validate action then returns the users to the
record they were viewing. If the conditions are met, then the invoked function sets a True value, and
the Validate action allows users to make the change.
The typical format of a Validate action is as follows:
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ueor f al se\ " } ] " ;
where t r ueor f al se can contain one of the following:
True indicates that the user is able to complete the action.
False returns the user to the record that the user was viewing, and no changes are made.
JSON goToURL Action
The goToURL action is not included in onSave events. However, it is considered an alternative action.
You use the goToURL action when defining a link to an external application, and you enter the
goToURL code as part of the configuration process when setting up the external application.
The purpose of the goToURL action is to start the external application URL, which contains the defined
fields and values to be passed to the external application.
You can encode the URL, using the noescape parameter of the goToURL action. If the noescape
parameter is set to True, then the URL is encoded. However, if the noescape parameter is set to
False, then the URL is not encoded. If the noescape parameter is included but not set in the goToURL
action, then the noescape parameter defaults to False, and the URL is not encoded.
The typical format for a goToURL action is as follows:
r et ur n " [ {\ " act i on\ " : \ " goToURL\ " , \ " noescape\ " : \ " t r ueor f al se\ " , \ " ur l \ " : \ " " +
ext er nal AppURL + " \ " } ] " ;
As with all JavaScript code, goToURL must be enclosed within HTML header and footer tags. For more
information, see About Actions on page 97.
To enter goToURL code in the Admin Application
1 Start and log in to the Admin application.
2 Click Map Settings, and then Module Settings on the vertical navigation bar.
3 Click More next to a module, and then select Quick Actions.
4 In the External App Configuration section, click Add to configure a new action.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON
getCondition Action
108
DRAFT - Modified May 27, 2014 4:45 pm
5 Complete the fields for the external application as required.
6 The JSON code is entered into the Value.
JSON getCondition Action
The getCondition action is a JSON action that you can use in one of the following places:
In a Field Condition input box. For example, you can use getCondition when using Reference
fields. The user must choose a record from a list of parents, such as, choose an address to create
a call.
When configuring a Quick Selector filter of type Toggle.
In both cases, you use getCondition to select which records to display to the user. getCondition is
essentially the JSON equivalent of the fieldsOnConditionQuery or conditionQuery JavaScript
statements.
Because getCondition displays a list to the user, it must have a filter key defined. You can define
static filters or use IF statements to create conditional filters. Note that the following:
\ " act i on\ " : \ " get condi t i on\ " ,
is always followed by the following:
\ " f i l t er \ " : \
In the following example code, getCondition is invoked when the CUSTREF1 field (Account) from the
call is selected. If the CUSTREF1 field contains data, then Addresses related to that account are
displayed. If no Account is selected, then the ELSE statement returns all records using the following:
\ " act i on\ " : \ " get condi t i on\ " , \ " f i l t er \ " : \ " \ " .
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " >
f unct i on condi t i onQuer yJ SON( ) {
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " get Condi t i onQuer r y\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 7\ " , \ " f i el ds\ " : \ " CLOGKW03, CLOGREF1, CLOGREF2\ "
} ] , \ " f i l t er \ " : \ " \ " , \ " i sf r omscr een\ " : \ " yes\ " } ] } ] " ; }
f unct i on get Condi t i onQuer r y( r ow) {
i f ( r ow[ 0] . _7. CLOGREF1) {
r et ur n " [ {\ " act i on\ " : \ "get condi t i on\ " ,
\ " f i l t er \ " : \ " 2. ui d i n ( sel ect par ent i d f r omme_dat ar el at i on wher e par ent t ype=2 and
chi l dt ype=28 and chi l di d i n ( sel ect chi l di d f r omme_dat ar el at i on wher e par ent t ype=1
and chi l dt ype=28 and ( par ent i d=" +r ow[ 0] . _7. CLOGREF1+" or
devi cer owi dpar ent =" +r ow[ 0] . _7. CLOGREF1+" ) ) ) \ " } ] " ;
}el se{r et ur n " [ {\ " act i on\ " : \ " get condi t i on\ " ,
\ " f i l t er \ " : \ " \ " } ] " ; }}
f unct i on onEr r or I nvoke( r ows) { i f ( r ows. l engt h > 0) {
wi ndow. l ocat i on=" mel t : / / showAl er t : " + r ows[ 0] . message;
}}</ scr i pt ></ head><body></ body></ ht ml >
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales JSON
Showprompt Action
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
109
DRAFT - Modified May 27, 2014 4:45 pm
JSON Showprompt Action
The Showprompt action is a JSON action that allows you to present a dialog box with a message to
the user, and wait for a response from the user. With Showprompt, you can perform soft validation
in an onSave script so that a warning message is displayed before asking if you want to save the
record or return to the record to fix the warnings. When defining the Showprompt message, you must
insert a dollar symbol ($) before the device message. The message that a Showprompt action
displays is also used in button names (to allow for translation). Table 17 describes the request
attributes in the Showprompt action.
An example Showprompt action is as follows:
r et ur n " [ {\ " act i on\ " : \ " showpr ompt \ " , \ " i nvoke\ " : \ " pr ompt Funct i on\ " , \ " t i t l e\ " : \ " You
Ar e Cr eat i ng Addr ess Under An Account , Do You Want To
Pr oceed?\ " , \ " cancel but t ont i t l e\ " : \ " cancel \ " , \ " ot her but t ont i t l es\ " : [ \ " yes\ " ,
\ " no\ " ] }] " ;
When you apply the request attributes from Table 17, the example Showprompt action translates to
the following:
[ {
act i on: showpr ompt
i nvoke: pr ompt Funct i on
t i t l e: You Ar e Cr eat i ng Addr ess Under An Account , Do You Want To Pr oceed?
cancel but t ont i t l e: Cancel
ot her but t ont i t l es: ( yes, no)
}]
Table 17. Showprompt JSON Action: Request Attributes
Name Description Required Default
action This shows the alert prompt. The value for this
attribute is showprompt. For example:
act i on: showpr ompt
Yes No
invoke The function to invoke when the user selects a button
in the prompt. The title corresponding to the selected
button is the parameter for this function.
Yes No
title The message to show in the prompt. It must start with
a dollar ($) sign so that the title can be localized.
(showAlert is localized in a similar way).
No No
cancelbuttontitle The title of the Cancel button. The Cancel button
closes the alert box. The button title is localized.
No No
otherbuttontitle The titles of any other buttons that are shown in the
alert prompt. The titles of these buttons are passed as
parameters to the invoke function. The button titles
are localized.
Yes No
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales Example of
Invoked Function
110
DRAFT - Modified May 27, 2014 4:45 pm
The result of this Showprompt example is that an alert box with buttons is displayed to the user.
When the user selects a button, the invoke function is called with the clicked button title as a
parameter. For example:
f unct i on pr ompt Funct i on( val ue) {
i f ( val ue == " yes" ) {
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " } ] " ;
}el se i f ( val ue == " no" ) {
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " f al se\ " } ] " ;
}
}
Example of Invoked Function
JSON code usually begins with a Select action, which invokes a subfunction and defines the fields
used in that query. Within the subfunction, a secondary action is called (an Update, Insert or Validate
action).
The invoked function example in this topic defines what should occur when the doneSignature
function is called. The doneSignature function refers to the Done button on the Signature page. It is
invoked when a user selects the Done button. The purpose of this example is to identify how many
sample products are dropped, and to update the number of products in the sample inventory by
subtracting the number of samples disbursed from the total sample inventory. The inventory on the
device is updated to maintain a local record of how many sample product items remain.
The JavaScript code in the example is invoked by the Oracle CRM On Demand Disconnected Mobile
Sales client application when the user selects Done on the Signature page. The high-level steps in
the overall flow are:
NOTE: Each step applies to one of the following: User, Client application, JavaScript code.
1 User: The user selects Done on the Signature page.
2 Client application: The full JavaScript is loaded.
3 Client application: The doneSignature() is called.
4 JavaScript Code: The JSON string for the Select action is returned.
5 Client application: The string is interpreted.
6 Client application: The Select action is invoked.
7 Client application: updateSampleInventory is called with the selected array of rows
8 JavaScript Code: The JSON string for the Update action is returned.
9 Client application: The string is interpreted.
10 Client application: The Update action is invoked.
11 User: Processing completes, and the user continues with the rest of the flow.
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales Example of
Invoked Function
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
111
DRAFT - Modified May 27, 2014 4:45 pm
The invoked function example follows. Like all actions related to a button, this action is saved as an
onSave JavaScript event. In the example, the following MODULEIDs and FIELDNAMES are read as
part of this query:
Module 15 is equal to Sample Drop, which contains the number of samples being dropped off.
15.CUSTQUANTITY is the Number being dropped
15.CUSTPRODUCT is the Product (reference to Allocation)
15.CUSTLOTNUMBER is the Lot number (reference to Sample Lot)
Module 16 is equal to Allocation (parent of 15)
16.CUSTSAMPLE is the Product (reference to Products)
Module 27 is equal to Sample Inventory, which contains the total number of sample products in
the inventory.
27.CUSTTXT03 is the Physical Count (number of products in inventory)
27.CUSTREF1 is the ProductID (reference to Products)
27.CUSTREF2 is the Lot # (reference to Sample Lot)
Module 7 is the Appointment (Call) Module
f unct i on doneSi gnat ur e( )
{
r et ur n " [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " updat eSampl eI nvent or y\ " ,
\ " par amet er s\ " : [ {\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 15\ " ,
\ " f i el ds\ " : \ " CUSTQUANTI TY\ " } , { \ " modul e\ " : \ " 27\ " , \ " f i el ds\ " : \ " ui d, CUSTTXT03\ "
}, { \ " modul e\ " : \ " 16\ " } ] , \ " f i l t er \ " : \ " 27. CUSTREF1 =16. CUSTSAMPLE and 27. CUSTREF2
= 15. CUSTLOTNUMBER and 15. CUSTPRODUCT = 16. ui d and 15. ui d i n ( sel ect chi l di d f r om
me_dat ar el at i on wher e par ent t ype=7 and chi l dt ype=15 and ( par ent i d=$7. ui d or
devi cer owi dpar ent =$7. ui d ) ) \ " } ] } ] " ;
}
f unct i on updat eSampl eI nvent or y( r ows) {
i f ( r ows. l engt h > 0) {
var quot e = " [ " ;
var i = 0;
f or ( ; i < r ows. l engt h; i ++) {
var c = par seI nt ( r ows[ i ] . _27. CUSTTXT03) -
par seI nt ( r ows[ i ] . _15. CUSTQUANTI TY) ;
i f ( i ! =0) {
quot e += " , " ;
}
quot e += " {\ " modul e\ " : \ " 27\ " , \ " ui d\ " : " + " \ " " + r ows[ i ] . _27. ui d + " \ " "
+ " , \ " f i el ds\ " : [ { \ " f i el d\ " : \ " CUSTTXT03\ " , \ " val ue\ " : " + " \ " " + c + " \ " } ] " + " ,
\ " act i on\ " : \ " updat e\ " " + " , \ " upsync\ " : \ " no\ " , \ " f i l t er \ " : \ " 27. ui d =" +
r ows[ i ] . _27. ui d + " \ " " + " }" ;
}
quot e +=" ] " ;
r et ur n quot e;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales Example of
Invoked Function
112
DRAFT - Modified May 27, 2014 4:45 pm
}
}
f unct i on onEr r or I nvoke( r ows) {
i f ( r ows. l engt h > 0) {
wi ndow. l ocat i on=" mel t : / / showAl er t : " + r ows[ 0] . message;
}
}
Table 18 describes the invoked function example for the doneSignature() function.
Table 18. Invoked Function Example
Code Segment Description
f unct i on doneSi gnat ur e( ) Performs this action when the doneSignature button is
selected.
{ Begins the action.
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " ,
Performs the Select action to read the fields used in the
query.
\ " i nvoke\ " : \ " updat eSampl eI nvent
or y\ " ,
Invokes the updateSampleInventory function, when the
fields are read.
\ " par amet er s\ " : [
{\ " modul ef i el ds\ " :
Reads the following fields from the modules specified. Each
modulefields parameter reads a set of data.
[ { \ " modul e\ " : \ " 15\ " ,
\ " f i el ds\ " : \ " CUSTQUANTI TY\ " } ,
Reads the CUSTQUANTITY (the number samples being
dropped off) from Sample Drop.
{ \ " modul e\ " : \ " 27\ " ,
\ " f i el ds\ " : \ " ui d, CUSTTXT03\ " },
Reads the uid (rowid) and CUSTTXT03 (the number of
products in the inventory) from Sample Inventory.
{ \ " modul e\ " : \ " 16\ " } ] , Reads the Allocation. Only the uid (rowid) must be retrieved
for this item because individual fields are not being read
from the object (and no fields are defined).
\ " f i l t er \ " : \ " 27. CUSTREF1 =
16. CUSTSAMPLE and
Filters the rows from the database in which the product ID
in Sample Inventory is equal to the product id in Allocation.
27. CUSTREF2 = 15. CUSTLOTNUMBER
and
Lot number in Sample Inventory is equal to Lot number in
Sample Drop.
15. CUSTPRODUCT = 16. ui d and Allocation rowid in Sample Drop is equal to the allocation
records to select.
15. ui d i n ( sel ect chi l di d f r om
me_dat ar el at i on wher e
par ent t ype=7 and chi l dt ype=15
and
Row ID of Sample drop is stored in the me_datarelation
table, as a child object of Activity.
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales Example of
Invoked Function
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
113
DRAFT - Modified May 27, 2014 4:45 pm
Table 19 describes the invoked function example subfunction.
par ent i d=$7. ui d or
devi cer owi dpar ent =$7. ui d ) ) \ " }
] } ] " ;
Checks parentid row ID in Oracle CRM On Demand and also
the temporary row ID on the device (devicerowidparent).
} End the action.
Table 19. Invoked Function Example: Function updateSampleInventory
Code Description
f unct i on
updat eSampl eI nvent or y( r ows) {
The subfunction, named updateSampleInventory, states to
retrieve a number of rows, rather than a single record.
i f ( r ows. l engt h > 0) { If the number of rows returned that meets the filter in the
select function is greater than zero, then perform the
following action (which is defined in the remaining rows in
this table).
var quot e = " [ " ; Inserts a left bracket [ in a quote variable.
var i = 0; Resets the i variable to zero.
f or ( ; i < r ows. l engt h; i ++) { Continues to run the following code until i equals the
number of rows returned in the select function. The i++
variable increments i by 1 each time the code is run. As a
result, the query is only run for each row returned, after
which the query exits.
var c =
par seI nt ( r ows[ i ] . _27. CUSTTXT03) -
par seI nt ( r ows[ i ] . _15. CUSTQUANTI T
Y) ;
Sets the c variable to number of rows (i) in the Sample
Inventory minus the number of rows (i) in Sample Drop.
The pareseInt declaration indicates to remove any leading
or trailing zeros from the input. The number of items in the
Sample Inventory is stored in variable c.
i f ( i ! =0) {
quot e += " , " ; I
Inserts a comma into the quote variable if the number of
rows does not equal zero. No comma is inserted the first
time that the code runs. However, because multiple rows
and multiple records are typically updated, a comma is
inserted between each row (record).
} None.
quot e += " {\ " modul e\ " : \ " 27\ " , Adds {\ " modul e\ " : \ " 27\ " , to the quote variable.
\ " ui d\ " : " + " \ " " +
r ows[ i ] . _27. ui d + " \ " " + " ,
Adds uid code to the quote, inserting the uid (row ID)
stored in the sample inventory. Inserts the rowid related to
module 27 stored in the current row.
\ " f i el ds\ " : [ {
\ " f i el d\ " : \ " CUSTTXT03\ " ,
Adds this item to the quote variable. The field planned for
update is CUSTTXT03.
Table 18. Invoked Function Example
Code Segment Description
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using Actions in Oracle CRM On Demand Disconnected Mobile Sales Example of
Invoked Function
114
DRAFT - Modified May 27, 2014 4:45 pm
\ " val ue\ " : " +" \ " " +c +" \ " } ] "
+ " ,
The updated quote variable includes the value parameter,
and inserts the value stored in variable c (which is the
number of items currently in the sample inventory).
\ " act i on\ " : \ " updat e\ " " + " , Inserts the Update action command into the quote
variable.
\ " upsync\ " : \ " no\ " , Inserts the upsync flag into the quote variable, which
indicates to update the device only and not to submit the
change to Oracle CRM On Demand.
\ " f i l t er \ " : \ " 27. ui d =" +
r ows[ i ] . _27. ui d + " \ " " + " }" ;
Adds the filter command to the quote variable, which
checks that only the record with the same row ID as the
current row being queried is being updated.
} Returns to the FOR command listed earlier, and checks to
see whether there are any additional rows to be processed.
If there are additional rows, then the function inserts a
comma and adds the update command for the second row.
The function repeats this behavior until all rows have been
processed.
quot e +=" ] " ; Adds a right bracket ] to the quote variable to close the
command.
r et ur n quot e; Submits the quote variable to the database. An Update
action is submitted for every row that was processed,
updating multiple records at a time.
} } None.
f unct i on onEr r or I nvoke( r ows) { Indicates what to do if there is an error in (rows).
i f ( r ows. l engt h > 0) { If the error is not as a result of a blank row, then indicates
to perform the following action (which is described in the
following row).
wi ndow. l ocat i on=" mel t : / /
showAl er t : " + r ows[ 0] . message;
Displays an error message to the user for the current row.
} None.
} None.
} None.
Table 19. Invoked Function Example: Function updateSampleInventory
Code Description
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
115
DRAFT - Modified May 27, 2014 4:45 pm
9 Using the DMS.js JavaScript
Library in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter introduces how to use the DMS.js JavaScript library in Oracle CRM On Demand
Disconnected Mobile Sales for Tablets. It includes the following topics:
Using the DMS.js JavaScript Library on page 115
Defining JSON Actions for DMS.js on page 120
Using JavaScript Code in DMS.js on page 123
API Call Logic for Appointment and Attendee Call on page 129
Callback Functions on page 133
Call and Record Locking API on page 136
Quick Selector API and Quick Selector Validate API on page 137
Controlled Substance Validation API on page 140
Using JavaScript Localization Code in DMS.js on page 141
Client Inbound WritebacK API on page 144
Using the DMS.js JavaScript Library
Oracle ships a library of JavaScript functions called DMS.js with Oracle CRM On Demand
Disconnected Mobile Sales. DMS.js is essentially an abstraction of the existing JavaScript
functionality. Do not modify or change the DMS.js file in any way because it is patched and upgraded
on a regular basis.
You can include new JavaScript functionality in the DMS.js file by referencing the JavaScript file in
the <scr i pt >header. Use your own organization name as the directory location for your script files
(and store your files there).
DMS.js abstracts the existing JavaScript functionality, which is provided inline.
NOTE: It is assumed that readers of this guide have coding experience and are familiar with writing
inline scripts (like DMS.js) without any abstractions.
To use the DMS.js file, you must include it inline in the HTML script using the <scr i pt >tag, for
example, as follows:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c="Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
. . . .
</ scr i pt ></ head><body></ body></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using the DMS.js JavaScript Library
116
DRAFT - Modified May 27, 2014 4:45 pm
You can use both module and field objects to write code without hard-coding the ME Field Name. If
there is a need to change an ME Field Name, then the field name can be changed effectively. You can
add module and field objects to the DMS.js file only if they are required. See Table 23 on page 118
for a list of the module and field variables that are already defined in DMS.js. Note that the toString
method for modules and fields is overloaded.
The following shows an example of module and field definitions in a script:
APPOI NTMENT + " " => " 7"
APPOI NTMENT. i d => " 7"
APPOI NTMENT. ui d + " " => " ui d"
APPOI NTMENT. ui d. f ul l => " 7. ui d"
APPOI NTMENT. count + " " => " count "
APPOI NTMENT. STATUS + " " => " CLOGSTATUS"
APPOI NTMENT. STATUS. par ent => " par ent . CLOGSTATUS"
APPOI NTMENT. STATUS. t hi s => " t hi s. CLOGSTATUS"
APPOI NTMENT. STATUS. f ul l => " 7. CLOGSTATUS"
APPOI NTMENT. STATUS. $ => " $7. CLOGSTATUS"
If you want to use a module that is not included in DMS.js, then you must define it in the inline script,
for example, as follows:
var LOG = new Modul e( {
LOGTI ME : " CUSTDT01" ,
LOGI NFORMATI ON : " CUSTTXT01"
}, " 29" ) ;
This example creates a log of module ID 29 and its fields.
You can add a new field to the existing modules as follows:
LOG. STATUS = new Fi el d( LOG, " STATUS" , " CLOGSTATUS" ) ;
The following general purpose functions are included in the DMS.js library:
DMS.showAlert Function on page 117
DMS.get Function on page 117
DMS.checkIfModuleExist function on page 117
For a complete list of the modules and fields that are present in the DMS.js file, see Table 23 on
page 118.
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using the DMS.js JavaScript Library
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
117
DRAFT - Modified May 27, 2014 4:45 pm
DMS.showAlert Function
The DMS.showAlert function displays a message that is passed as an argument. Table 20 describes
the DMS.showAlert function.
DMS.get Function
The DMS.get function retrieves a value from arguments, which are obtained using the Select action.
Table 21 describes the DMS.get function.
DMS.checkIfModuleExist function
The DMS.checkIfModuleExist function creates a JavaScript Object Notation (JSON) request with one
Select action. This function checks if a module is enabled or not. Table 22 describes the
DMS.checkIfModuleExist function.
Table 20. DMS.showAlert Function
Item Description
Parameters message (String), which is the string value that is displayed as the message.
Returns The return value is None.
Example DMS. showAl er t ( " $. cust om. not hi ng. t o. si gn" )
Table 21. DMS.get Function
Item Description
Parameters dataRow, which is an object. Typically, this is an element in an array.
field, which is a field object in the format MODULE.FIELD.
Returns The return value is a String.
Example i f ( DMS. get ( appt ms[ 0] , APPOI NTMENT. CALLTYPE) === " Account Cal l " ) {
. . .
}
Table 22. DMS.checkIfModuleExits Function
Item Description
Parameters module, which is a module object.
next (String), which is the name of the function to be invoked.
Returns The return value is a JSON String.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using the DMS.js JavaScript Library
118
DRAFT - Modified May 27, 2014 4:45 pm
List of Modules and Fields Present in DMS.js
Table 23 lists the modules and fields that are present in the DMS.js library file.
Table 23. Modules and Fields
Module Module ID Field ME Field Name
ACCOUNT 1 SHIPADDRESSID ACCTTXT02
CONTACT 2 ACCOUNTID CONTREF1
PRIMARYADDRESS CONTTXT03
MSGRSP 19 None None
APPOINTMENT 7 CONTACT CLOGREF2
ADDRESS CLOGADDRESS None
DUEDATE CLOGDT01
STARTTIME CLOGSTARTTIME
ENDTIME CLOGENDTIME
STATUS CLOGSTATUS
PAPERSIGN CLOGKW04
REFNUM CLOGTXT04
MULTIPLE_CONTACT_ID CLOGTXT03
CALLTYPE CLOGKW03
ACCOUNTID CLOGREF1
ATTENDEE_CALL 64 ADDRESS CLOGADDRESS
DUEDATE CUSTDT01
STARTTIME CLOGSTARTTIME
ENDTIME CLOGENDTIME
STATUS CLOGSTATUS
ATTENDEECALLDATE CUSTDT02
ACCOUNTID CUSTREF3
PAPERSIGN CLOGKW04
REFNUM CLOGTXT03
CALLTYPE CLOGKW03
CONTACTLICENSES 22 LICENSE_NUMBER CUSTLICENSENUMBER
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using the DMS.js JavaScript Library
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
119
DRAFT - Modified May 27, 2014 4:45 pm
PRODDETAILED 25 PRIORITY CUSTTXT01
ACTIVITYID CUSTREF1
APPOINTMENTID CUSTREF2
PRODUCT 14 CONTROLLED CONTROLLED
NAME CUSTDESCRIPTION
SAMPLEDROP 15 QUANTITY CUSTQUANTITY
APPOINTMENTID CUSTCALL
ACTIVITYID CUSTREF1
ALLOCATIONID CUSTPRODUCT
SAMPLELOTID CUSTLOTNUMBER
CREATEDBYFULLNAME CUSTOWNER
ALLOCATION 16 MAXQTYCALL ALLOCATION
ENDDATE CUSTDT02
SAMPLE_INVENTORY 27 LOTNUMCUTOFFDATE CUSTTXT06
LOTEXPIRATIONDATE CUSTTXT05
SAMPLE_REQUEST 62 APPOINTMENTID CUSTREF2
ACCOUNTID CUSTREF3
CONTACTID CUSTREF4
ACTIVITYID CUSTREF5
ORDERCREATIONSTATUS CUSTKW01
ORDERCREATIONDATE CUSTDT01
SHIPADDRESS CUSTREF1
SAMPLE_REQUEST_IT
EM
63 QUANTITY CUSTTXT02
ORDERITEMNUM CUSTTXT01
ORDERCREATIONSTATUS ORDERCREATIONSTATUS
ORDERCREATIONDATE CUSTDT01
PROMODROP 17 QUANTITY CUSTQUANTITY
APPOINTMENTID CUSTCALL
ACTIVITYID CUSTREF1
SIGNATURE 24 DENORMCONTACTFIRSTNAME CUSTTXT02
DENORMCONTACTLASTNAME CUSTTXT03
Table 23. Modules and Fields
Module Module ID Field ME Field Name
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Defining JSON Actions for DMS.js
120
DRAFT - Modified May 27, 2014 4:45 pm
Defining JSON Actions for DMS.js
All communication with the Oracle CRM On Demand Disconnected Mobile Sales Server is carried out
using JSON. You can use JSON code corresponding to the Select, Update, Insert, and Validate actions
in the DMS.action function. For more information, see the following:
DMS.action Function on page 121
DMS.validateAction Function on page 121
Select Action on page 121
Update Action on page 122
Insert Action on page 122
Delete Action on page 123
Validate Action on page 123
HCP 71 ALLOCATIONQTY CUSTTXT02
QTYREMAINING CUTTXT04
CONTACTID CUSTREF1
ENDDATE CUSTDT02
SHAREDADDRESS 67 ADDRESSNAME CUSTTXT04
ACCOUNTADDRESS 65 ADDRESSNAME CUSTTXT03
CONTACTADDRESS 66 ADDRESSNAME CUSTTXT05
DEAACTIVEFLAG CUSTTXT02
DEAEXPIRYDATE CUSTDT01
CONTACTID CUSTREF1
ADDRESSID CUSTREF2
DEANUMBER CUSTTXT01
DEAISSUEDATE CUSTDT02
ADDRESSTYPE CUSTTXT03
PRIMARYCONTACTADDRESSFLAG CUSTTXT04
BLOCKEDPRODUCTS 72 CONTACTID CUSTREF1
CONTACTBESTTIME 21 CONTACTID CUSTREF2
ACCOUNTCONTACT 28 None None
Table 23. Modules and Fields
Module Module ID Field ME Field Name
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Defining JSON Actions for DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
121
DRAFT - Modified May 27, 2014 4:45 pm
For more information about the structure of JSON code, see JavaScript Object Notation Actions on
page 98.
DMS.action Function
The DMS.action function creates a JSON array of actions. Table 24 describes the DMS.action function.
DMS.validateAction Function
The DMS.validateAction function validates an action. It takes a string value (" t r ue" or " f al se") as
input. Table 25 describes the DMS.action function.
Select Action
An example of what a Select action looks like in the DMS.js library file is as follows:
var sampl eAct i on = {};
sampl eAct i on. act i on = " sel ect " ;
sampl eAct i on. i nvoke = " updat eSRSt at us" ;
sampl eAct i on. par amet er s = [ ] ;
sampl eAct i on. par amet er s[ 0] = {
modul ef i el ds : [ {
modul e : SAMPLE_REQUEST,
f i el ds : [ SAMPLE_REQUEST. ui d]
}] ,
f i l t er : " 62. CUSTREF2 = $7. ui d"
};
r et ur n DMS. act i on( [ sampl eAct i on] ) ;
The equivalent generated JSON code is as follows:
Table 24. DMS.action Function
Item Description
Parameters actions, or an array of objects. The array of objects can contain any number of
homogeneous actions.
Returns A JSON string.
Table 25. DMS.validateAaction Function
Item Description
Parameters result (String), which can be a value of True or False.
Returns The JSON string containing the Validate action.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Defining JSON Actions for DMS.js
122
DRAFT - Modified May 27, 2014 4:45 pm
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " updat eSRSt at us\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 62\ " , \ " f i el ds\ " : \ " ui d\ " } ] ,
\ " f i l t er \ " : \ " 62. CUSTREF2 = $7. ui d\ " } ] } ] "
More than one action can be returned as an array in the DMS.action function, for example, as follows:
r et ur n DMS. act i on( [ sampl eAct i on1, sampl eAct i on2] ) ;
Update Action
An example of what an Update action looks like in the DMS.js library is as follows:
var opt i on0 = {
act i on : " updat e" ,
modul e : SAMPLE_REQUEST,
ui d : " 1QS- 1234" ,
f i el ds : [ {f i el d : SAMPLE_REQUEST. ORDERCREATI ONSTATUS, val ue : " Submi t t ed" }] ,
upsync : " yes" ,
f i l t er : " 62. ui d = 1QS- 1234"
};
r et ur n DMS. act i on( [ opt i on0] ) ;
The equivalent generated JSON code is as follows:
" [ {\ " act i on\ " : \ " updat e\ " , \ " modul e\ " : \ " 62\ " , \ " ui d\ " : \ " 1QS-
1234\ " , \ " f i el ds\ " : [ {\ " f i el d\ " : \ " CUSTKW01\ " , \ " val ue\ " : \ " Submi t t ed\ " }] , \ " upsync\ " : \ "
yes\ " , \ " f i l t er \ " : \ " 62. ui d = 1QS- 1234\ " }] "
Insert Action
An example of what an Insert action looks like in the DMS.js library is as follows:
var act 0 = {
act i on : " i nser t " ,
modul e : APPOI NTMENT,
par ent modul e : ACCOUNT,
par ent ui d : DMS. get ( account Det ai l s[ 0] , ACCOUNT. ui d) ,
f i el ds : [ {f i el d : APPOI NTMENT. CALLTYPE, val ue : " Account Cal l " }, {f i el d :
APPOI NTMENT. STATUS, val ue : " Pl anned" }] ,
upsync : " YES" ,
showui : " YES"
}
r et ur n DMS. act i on( [ act 0] ) ;
The equivalent generated JSON code is as follows:
[ {\ " act i on\ " : \ " i nser t \ " , \ " modul e\ " : \ " 7\ " , \ " par ent modul e\ " : \ " 1\ " , \ " par ent ui d\ " : \ " " +
account Det ai l s[ 0] . _1. ui d+" \ " , \ " f i el ds\ " : \ " CLOGKW03\ " , \ " val ue\ " : \ : " Account
Cal l \ " }, {\ " f i el d\ " : \ " CLOGSTATUS\ " , \ " val ue\ " : \ " Pl anned\ " }] , \ " upsync\ " : \ " YES\ " , \ " sho
wui \ " : \ " YES\ " }]
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
123
DRAFT - Modified May 27, 2014 4:45 pm
Delete Action
An example of what Delete action looks like in the DMS.js library is as follows:
var act 0 = {
act i on : " del et e" ,
modul e : PRODUCT,
ui d: DMS. get ( pr ods[ 0] , PRODUCT. ui d) ,
upsync : " yes" ,
del et ef r omcr m: " yes" ,
r emovef r omdevi ce : " yes"
}
r et ur n DMS. act i on( [ act 0] ) ;
The equivalent generated JSON code is as follows:
[ {\ " act i on\ " : \ " del et e\ " , \ " modul e\ " : \ " 25\ " , \ " ui d\ " : \ " " +pr ods[ 0] . _25. ui d+" \ " , \ " upsyn
c\ " : \ " yes\ " , \ " del et ef r omcr m\ " : \ " yes\ " , \ " r emovef r omdevi ce\ " : \ " yes\ " }]
Validate Action
An example of what Validate action looks like in the DMS.js library is as follows:
var act 0 = {
act i on : " val i dat e" ,
r esul t : " t r ue"
}
r et ur n DMS. act i on( [ act 0] ) ;
The equivalent generated JSON code is as follows:
" [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " }] "
Because Validate actions are frequently called in inline scripts, you can use DMS.validateAction
instead. The Validate action takes a string (" t r ue" or " f al se") as input.
Using JavaScript Code in DMS.js
You can use JavaScript code corresponding to onCancel, onSave, quick selector filters, quick action
detailers, and onValidate respectively in the following DMS.js functions:
DMS.fieldsOnCancel Function on page 124
DMS.fieldsOnDefault Function on page 124
DMS.fieldsOnPreSave Function on page 125
DMS.fieldsOnConditionQuery Function on page 125
DMS.quickActionDetailer Function on page 126
Field Condition conditionQuery Function on page 127
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
124
DRAFT - Modified May 27, 2014 4:45 pm
DMS.conditionQuery Function on page 128
DMS.fieldsOnFilter Function on page 128
DMS.onValidateJSON Function on page 129
DMS.fieldsOnCancel Function
DMS.js implements onCancel functionality using the DMS.fieldsOnCancel function.Table 26 describes
the DMS.fieldsOnCancel function. For more information about the structure of JSON code, see
JavaScript Object Notation Actions on page 98.
DMS.fieldsOnDefault Function
DMS.js implements onDefault functionality using the DMS.fieldsOnDefault function.Table 27
describes the DMS.fieldsOnDefault function. For more information about the structure of JSON code,
see JavaScript Object Notation Actions on page 98.
Table 26. DMS.fieldsOnCancel Function
Item Description
Parameters fieldsArray, which is an array of fields.
Returns Returns strings in the following form:
" modul ei d. f i el d1, modul ei d. f i el d2"
Example f unct i on f i el dsOnCancel ( ) {
r et ur n DMS. f i el dsOnCancel ( [ APPOI NTMENT. STARTTI ME. f ul l ,
APPOI NTMENT. ENDTI ME. f ul l ] ) ;
}
Table 27. DMS.fieldsOnDefault Function
Item Description
Parameters There are a number of arguments, each of which is an array of fields.
Example f unct i on f i el dsOnDef aul t ( ) {
r et ur n DMS. f i el dsOnDef aul t (
[ ATTENDEE_CALL. STARTTI ME, [ ATTENDEE_CALL. STARTTI ME,
APPOI NTMENT. STARTTI ME. f ul l ] ] ,
[ ATTENDEE_CALL. ENDTI ME, [ ATTENDEE_CALL. ENDTI ME,
APPOI NTMENT. ENDTI ME. f ul l ] ] ) ;
}
Outputs to " CLOGSTARTTI ME- CLOGSTARTTI ME, 7. CLOGSTARTTI ME| CLOGENDTI ME-
CLOGENDTI ME, 7. CLOGENDTI ME"
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
125
DRAFT - Modified May 27, 2014 4:45 pm
DMS.fieldsOnPreSave Function
DMS.js implements onSave functionality using the DMS.fieldsOnPreSave function. Table 28 describes
the DMS.fieldsOnPreSave function. For more information about the structure of JSON code, see
JavaScript Object Notation Actions on page 98.
DMS.fieldsOnConditionQuery Function
DMS.js implements quick selector filters using the DMS.fieldsOnConditionQuery function. Table 29
describes the DMS.fieldsOnConditionQuery function. For more information about using quick selector
filters, see Chapter 6, Using JavaScript Code to Filter Information in Oracle CRM On Demand
Disconnected Mobile Sales.
Table 28. DMS.fieldsOnPreSave Function
Item Description
Parameters There are an array of fields.
Returns Returns a string in one of the following formats as required:
" modul ei d. f i el d1, modul ei d. f i el d2"
" f i el d1, f i el d2" as r equi r ed
Example f unct i on f i el dsOnPr eSave( ) {
r et ur n DMS. f i el dsOnPr eSave( [ ATTENDEE_CALL. STATUS. f ul l ] ) ;
}
Table 29. DMS.fieldsOnConditionQuery Function
Item Description
Parameters There are an array of fields.
Returns Returns a string in the following format:
" modul ei d. f i el d1, modul ei d. f i el d2"
Example f unct i on f i el dsOnCondi t i onQuer y( ) {
r et ur n DMS. f i el dsOnCondi t i onQuer y( [ APPOI NTMENT. STATUS. f ul l ] ) ;
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
126
DRAFT - Modified May 27, 2014 4:45 pm
DMS.quickActionDetailer Function
DMS.js implements quick action detailers using the DMS.quickActionDetailer function for
Appointment Detailer and Contact Detailer. Table 30 describes the DMS.quickActionDetailer function.
The DMS.quickActionDetailer function must call the DMS.js file. Use the following code as an
example:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c="Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on condi t i onQuer yJ SON( ) {
r et ur n DMS. qui ckAct i onDet ai l er ( APPOI NTMENT, [ ] ) ; }
</ scr i pt ></ head><body></ body></ ht ml >
Table 30. DMS.quickActionDetailer Function
Item Description
Parameters module, which is an object.
Array of filters, which is optional and currently supports only Blocked
Products. Typically, this is an empty array with no filters to apply.
Returns A JSON string with the getcondition action.
Examples An Appointment detailer example is as follows:
f unct i on condi t i onQuer yJ SON( ) {
r et ur n DMS. qui ckAct i onDet ai l er ( APPOI NTMENT, [ BLOCKEDPRODUCTS] ) ;
}
A Contact detailer example is as follows:
f unct i on condi t i onQuer yJ SON( ) {
r et ur n DMS. qui ckAct i onDet ai l er ( CONTACT, [ ] ) ;
}
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
127
DRAFT - Modified May 27, 2014 4:45 pm
Field Condition conditionQuery Function
DMS.js implements field condition queries using the conditionQuery function. The conditionQuery
functions are used in the Field Condition input box of the corresponding ME field. The conditionQuery
returns a Select action, which causes all objects (for example, contact, address, and shared address)
that are related to the call to be displayed. Table 31 describes the DMSxxx.conditionQueryJSON
function.
a
Table 31. DMSxxx.conditionQueryJSON Function
Item Description
Parameters module, which can be CONTACT, ACCOUNT, or SHAREDADDRESS for
Appointment, SHAREDADDRSS for Attendee Call, and SHAREDADDRSS for
ContactBestTime.
Array of filters, which is optional and currently supports only Blocked
Products. Typically, this is an empty array with no filters to apply.
Returns Returns a Select action JSON string. The function which is invoked using the
Select query is dynamically registered by DMS.js.
Examples An Appointment - Contact field conditionQuery is as follows:
f unct i on condi t i onQuer yJ SON( ) {
r et ur n DMSAppoi nt ment . condi t i onQuer yJ SON( CONTACT) ;
}
An Appointment - Account field conditionQuery is as follows:
r et ur n DMSAppoi nt ment . condi t i onQuer yJ SON( ACCOUNT) ;
An Appointment - Shared Address conditionQuery is as follows:
r et ur n DMSAppoi nt ment . condi t i onQuer yJ SON( SHAREDADDRESS) ;
Attendee Call - Shared Address conditionQuery is as follows:
r et ur n DMSAt t endeeCal l . condi t i onQuer yJ SON( SHAREDADDRESS) ;
A Contact Best Time - Shared Address conditionQuery is as follows:
r et ur n DMSCont act Best Ti me. condi t i onQuer yJ SON( SHAREDADDRESS) ;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Code in DMS.js
128
DRAFT - Modified May 27, 2014 4:45 pm
DMS.conditionQuery Function
DMS.js implements quick selector condition queries using the DMS.conditionQuery function. Table 32
describes the DMS.conditionQuery function, which is used inside the conditionquery function in quick
selector scripts.
DMS.fieldsOnFilter Function
DMS.js implements field filters using the DMS.fieldsOnFilter function. Table 33 describes the
DMS.fieldsOnFilter function.
Table 32. DMS.conditionQuery Function
Item Description
Parameters module, which is an object and can be one of the following: SAMPLEDROP,
PROMODROP, PRODDETAILED, or SAMPLE_REQUEST.
Array of filters, which is optional and currently supports only Blocked
Products and HCP.
Returns A JSON string with the getcondition action.
Examples f unct i on condi t i onQuer y( ) {
r et ur n DMS. condi t i onQuer y( SAMPLEDROP) ;
}
For the ATTENDEE_CALL module, DMS.conditionQueryJSON is used for example
as follows:
f unct i on condi t i onQuer yJ SON( ) {
r et ur n DMS. condi t i onQuer yJ SON( ATTENDEE_CALL) ;
}
Table 33. DMS.fieldsOnFilter Function
Item Description
Parameters An array of field objects is taken in by DMS.fieldsOnFilter.
Returns A concatenated string list of ME Field names separated by comma.
Example f unct i on f i el dsOnFi l t er ( ) {
r et ur n DMS. f i el dsOnFi l t er ( [ APPOI NTMENT. STARTTI ME. par ent ,
SAMPLE_I NVENTORY. LOTEXPI RATI ONDATE. f ul l , ALLOCATI ON. ENDDATE. f ul l ] ) ;
}
Example Returns " par ent . CLOGSTARTTI ME, 27. CUSTTXT05, 16. CUSTDT02"
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales API Call Logic for Appointment and Attendee Call
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
129
DRAFT - Modified May 27, 2014 4:45 pm
DMS.onValidateJSON Function
DMS.js implements onValidate functionality using the DMS.onValidateJSON function. Table 34
describes the DMS.onValidateJSON function.
API Call Logic for Appointment and
Attendee Call
The DMS.js JavaScript library provides an application programming interface (API) that you can
modify to configure the call logic for Appointments and Attendee calls in Oracle CRM On Demand
Disconnected Mobile Sales for Tablets. For more information, see the following:
DMSCall.onSaveJSONCall(options) on page 129
DMSCall.onAcceptAndSign(options) on page 130
DMSCall.onSubmitCall(options) on page 131
Callback Functions on page 133
DMSCall.onSaveJSONCall(options)
You use DMS.onSaveJSONCall under the onSaveJSON function in the Appointment onSave script. An
example of DMSCall.onSaveJSON follows:
f unct i on onSaveJ SON( ) {
var opt i ons = {
modul eRequi r eSi gnat ur e : [ SAMPLE_REQUEST] ,
modul eDoesNot Requi r eSi gnat ur e : [ PROMODROP] ,
Table 34. DMS.onValidateJSON Function
Item Description
Parameters An object that has the following key values: module and filters.
The value of the module key is an object of Module.
The value of the filters key is an array of the filter modules.
Currently the HCP module is supported.
For the module key, you can assign SAMPLEDROP, PROMODROP,
SAMPLE_REQUEST, or PRODDETAILED. For filters, only HCP can currently be
assigned.
Returns A JSON string. A Select action fetches the value and validates HCP.
Example f unct i on onVal i dat eJ SON( ) {
r et ur n DMS. onVal i dat eJ SON( {modul e : SAMPLEDROP, f i l t er s : [ HCP] }) ;
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales API Call Logic for Appointment and Attendee Call
130
DRAFT - Modified May 27, 2014 4:45 pm
};
r et ur n DMSCal l . onSaveJ SON( ) ;
}
Table 35 describes the options that DMS.onSaveJSONCall uses.
DMSCall.onAcceptAndSign(options)
You use DMS.onAcceptAndSign under the onAcceptandSign function in the Appointment and
Attendee Call onSave script. An example of DMSCall.onAcceptAndSign follows.
f unct i on onAccept AndSi gn( ) {
var opt i ons = {
modul e : APPOI NTMENT,
sampl eEnabl ed : " t r ue" ,
pr omoEnabl ed : " t r ue" ,
cont act St at eLi censeEnabl ed : " t r ue" ,
DEANumber Enabl ed : " t r ue"
};
r et ur n DMSCal l . onAccept AndSi gn( opt i ons) ;
}
In this example, DMSCall.onAcceptAndSign(options) fetches the call details (samplecount,
contactcount, promocount, statelicense, papersign, srcount, sricount) and passes the data as
arguments to the launchValidateAcceptSign function. Table 36 describes the options that
DMS.onAcceptAndSign uses.
Table 35. DMS.onSaveJSONCall(options)
Key Default Value Description
copyAccount Cal l Fi e
l dsToAt t endeeCal l
[ [ APPOI NTMENT. ADDRESS ,
ATTENDEE_CALL. ADDRESS] ,
[ APPOI NTMENT. DUEDATE ,
ATTENDEE_CALL. DUEDATE] ]
The default row mappings used, which specify
the Appointment-to-Attendee Call field
mappings used. Copies Appointment values to
Attendee Calls when an appointment is
modified or when an appointment is
submitted. The mappings provided by the
user do not replace the default value, but are
added to the default mappings.
doNot CopyAccount Ca
l l Fi el dsToAt t endee
Cal l
[ ] Used to specify that a default field mapping is
not required.
modul eRequi r eSi gna
t ur e
[ SAMPLEDROP, PROMODROP] Specifies the call items that require a
signature before a call can be submitted. User
values are appended to the default values,
rather than replacing the default values.
modul eDoesNot Requi
r eSi gnat ur e
[ ] Specifies an item that does not require a
signature.
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales API Call Logic for Appointment and Attendee Call
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
131
DRAFT - Modified May 27, 2014 4:45 pm
OnAcceptAndSign Considerations
When canceling the signature on the Signature Detail screen, the client application set the Sample
Request record to Signed status and does not allow further additions to the Sample Request Items.
This is because the OnAcceptAndSign script relies on the client to set the call status. As a
consequence, the client locks the Sample Request record before finding out if the user is
acknowledging the signature or cancelling. To correct the problem, you must add an optional
JavaScript call back function for the case where the user accepts the signature.
DMSCall.onSubmitCall(options)
You use DMS.onSubmitCall under the onSubmitCall function in the Appointment and Attendee Call
onSave script. An example of DMSCall.onSubmitCall follows.
f unct i on onSubmi t Cal l ( ) {
var opt i ons = {
modul e : APPOI NTMENT,
Table 36. DMS.onAcceptAndSign(options)
Key Default Value Description
sampl eEnabl ed " f al se" If sampleEnabled is set to True, then sample
drops on calls require a signature.
pr omoEnabl ed " f al se" If promoEnabled is set to True, then
promotional item drops on calls require a
signature.
sampl eReqEnabl ed " f al se" If set to True, then sample requests on calls
require a signature.
cont act St at eLi censeEnab
l ed
" t r ue" If set to True, then the contact state license is
checked when the user selects the Accept and
Sign button on the Signature page (in the
Oracle CRM On Demand Disconnected Mobile
Sales application).
DEANumber Enabl ed " f al se" If set to True, then the DEA number is checked
when the user selects the Accept and Sign
button on the Signature page.
modul e Undef i ned This mandatory field is assigned one of the
following values: APPOINTMENT or
ATTENDEE_CALL.
val i dat i onFn Undef i ned This is a callback function for accept and sign
validation.
cont r ol l edSubst anceVal i
dFn
Undef i ned This is a callback function for DEA validation.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales API Call Logic for Appointment and Attendee Call
132
DRAFT - Modified May 27, 2014 4:45 pm
modul eRequi r eSi gnat ur e : [ SAMPLE_REQUEST] ,
cont act St at eLi censeEnabl ed : " t r ue" ,
DEANumber Enabl ed : " t r ue" ,
submi ssi onSt at us : " Submi t t ed" ,
enf or ceCheckSeconds : " t r ue" ,
enf or ceCool i ngOf f Per i od : 5
};
r et ur n DMSCal l . onSubmi t Cal l ( opt i ons) ;
}
In this example, DMSCall.onSubmitCall(options) fetches call details (Sample drops, PromoItems,
Signatures, Message Response, Contact Licenses, Sample Requests, sample Request Items, Product
Details) and passes the data to arguments in the launchValidateSubmit function. Table 37 describes
the options that DMS.onSubmitCall uses.
Table 37. DMS.onSubmitCall(options)
Key Default Value Description
i sSi gnat ur eRequi r ed " t r ue" Specifies whether a signature is
mandatory to submit calls.
modul eRequi r eSi gnat ur e [ SAMPLEDROP, PROMODROP] Specifies the call items that require a
signature before the call can be
submitted. User values are appended
to the default values, rather than
replacing the default values.
modul eDoesNot Requi r eSi gn
at ur e
[ ] Specifies an item that does not require
a signature.
cont act St at eLi censeEnabl
ed
" t r ue" If set to True, then the contact state
license is checked when the user
selects the Submit button on the
Signature page.
DEANumber Enabl ed " f al se" If set to True, then the DEA number is
checked when the user selects the
Submit button on the Signature page.
modul e Undef i ned As a mandatory field, module is
assigned one of the following values:
APPOINTMENT or ATTENDEE_CALL.
submi ssi onSt at us " Submi t t ed" The value in this field is one of the
following: Submitted or Submitting.
enf or ceCheckSeconds " t r ue" Checks to see whether the Submit
button is selected after the specified
end time. If Submit is not selected,
then an error is displayed.
enf or ceCool i ngOf f Per i od 0 Used to enforce a cooling period after
end time.
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Callback Functions
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
133
DRAFT - Modified May 27, 2014 4:45 pm
Callback Functions
The DMS.js JavaScript library provides an application programming interface (API) that you can use
to write validation functions for the Accept and Sign, and Submit buttons which appear on the
Signature page in the Oracle CRM On Demand Disconnected Mobile Sales application. In the
validation function, you specify whether or not to run the default validation using the
launchValidateAcceptSign and the launchValidateSubmit functions. A predefined set of data is passed
to launchValidateAcceptSign and launchValidateSubmit, which is used by the callback validation
functions written to suit your own business needs. You can use the predefined dataset, or write your
own Select actions and JSON queries to obtain the data.
For more information about the callback functions, see the following:
onAcceptAndSign and acceptSignData on page 133
onSubmitCall and validateSubmitData on page 134
Callback Function Example on page 135
onAcceptAndSign and acceptSignData
A typical example of the onAcceptAnd Sign and customValidateAcceptSign functions is as follows:
f unct i on onAccept AndSi gn( ) {
var opt i ons = {
modul e : APPOI NTMENT,
val i dat i onFn : cust omVal i dat eAccept Si gn
};
r et ur n DMSCal l . onAccept AndSi gn( opt i ons) ;
}
f unct i on cust omVal i dat eAccept Si gn( opt i ons, accept Si gnDat a) {
. . cust omer val i dat i on code t o be ent er ed her e. . .
r et ur n val i dat eAccept Si gn( opt i ons, accept Si gnDat a) ; / / used i f cust omer want s t o r un
def aul t val i dat i on.
}
cont r ol l edSubst anceVal i d
Fn
Undef i ned This is a callback function for submit
validation.
copyAccount Cal l Fi el dsToA
t t endeeCal l
[ [ APPOI NTMENT. ADDRESS ,
ATTENDEE_CALL. ADDRESS] ,
[ APPOI NTMENT. DUEDATE ,
ATTENDEE_CALL. DUEDATE] ]
When the Submit or Save button for
an appointment is selected and the
appointment has calls as children,
then these are the fields that must be
copied from the Appointment to
Attendee Calls.
Table 37. DMS.onSubmitCall(options)
Key Default Value Description
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Callback Functions
134
DRAFT - Modified May 27, 2014 4:45 pm
Table 38 describes the data that is available in acceptSignData.
onSubmitCall and validateSubmitData
A typical example of validation for the Submit button is as follows:
f unct i on onSubmi t Cal l ( ) {
var opt i ons = {
modul e : APPOI NTMENT,
val i dat i onFn : cust omVal i dat eSubmi t
};
r et ur n DMSCal l . onSubmi t Cal l ( opt i ons) ;
}
f unct i on cust omVal i dat eSubmi t ( opt i ons, val i dat eSubmi t Dat a) {
. . . user val i dat i on
r et ur n val i dat eSubmi t ( opt i ons, val i dat eSubmi t Dat a) ;
}
Table 39 describes the data that is available in validateSubmitData.
Table 38. Data Available in acceptSignData
Key Description How to access
cont act count Result to count query performed.
Value is "1" or "0"
DMS. get ( cont act count [ 0] ,
CONTACT. count )
sampl ecount The number of sample drops on a call. DMS. get ( sampl ecount [ 0] ,
SAMPLEDROP. count )
pr omocount The number of promotional items on a
call.
DMS. get ( pr omocount [ 0] ,
PROMODROP. count )
st at el i cense The state license number for a call. DMS. get ( st at el i cense[ 0] ,
CONTACTLI CENSES. LI CENSE_NUMBER)
paper si gn The paper sign value for a call. DMS. get ( paper si gn[ 0] ,
APPOI NTMENT. PAPERSI GN)
sr count The number of sample requests on a
call.
DMS. get ( sr count [ 0] ,
SAMPLE_REQUEST. count )
sr i count The number of sample request items
on a call.
DMS. get ( sr i count [ 0] ,
SAMPLE_REQUEST_I TEM. count ) ;
Table 39. Data Available in validateSubmitData
Key Description How to access
pr odDet ai l s Product Details count,uid DMS. get ( pr odDet ai l s[ i ] ,
PRODDETAI LS. count )
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Callback Functions
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
135
DRAFT - Modified May 27, 2014 4:45 pm
Callback Function Example
A typical example of using Select action queries to obtain data is as follows. Note that the following
validation code is for the Accept and Sign button, but similar validation code is used for the Submit
button.
f unct i on onAccept AndSi gn( ) {
var sampl eDr opAct i on = {
act i on : " sel ect " ,
i nvoke : " get Sampl eDr opDat a" ,
par amet er s : [ {modul ef i el ds : [ {modul e : SAMPLEDROP, f i el ds : SAMPLEDROP. ui d}] ,
f i l t er : " 15. CUSTCALL = $7. ui d" }]
};
r et ur n DMS. act i on( [ sampl eDr opAct i on] ) ;
}
f unct i on get Sampl eDr opDat a( sampl eDr ops) {
. . . user val i dat i on based on sampl eDr ops dat a. . .
. . . r et ur n DMS. val i dat eAct i on( " t r ue" ) ; or r et ur n DMS. val i dat eAct i on( " f al se" ) i f
def aul t val i dat i on i sn' t r equi r ed.
nonPr odDet ai l s The uid, PAPERSIGN, and REFNUM
for non-product details.
DMS. get ( nonPr odDet ai l s[ i ] ,
APPOI NTMENT. ui d) ;
sampl eDr ops The uid, PAPERSIGN, and REFNUM
for sample drops.
DMS. get ( sampl eDr ops[ i ] ,
APPOI NTMENT. ui d)
pr omoI t ems The uid, PAPERSIGN, and REFNUM
for promotional items.
DMS. get ( pr omoI t ems[ i ] ,
APPOI NTMENT. ui d) ;
si gnat ur es The number of signatures. DMS. get ( si gnat ur es[ 0] ,
SI GNATURE. count )
msgResponses The number of message
responses.
DMS. get ( msgResponses[ 0] ,
MSGRSP. count )
cont act Li censes The license number of the contact
license.
DMS. get ( cont act Li censes[ 0] ,
CONTACTLI CENSES. LI CENSE_NUMBER) ;
cal l The uid, CALLTYPE, PAPERSIGN,
REFNUM, STARTTIME, and
ENDTIME of the current call.
DMS. get ( cal l [ i ] ,
APPOI NTMENT. STARTTI ME)
sampl eRequest s The uid, and
ORDERCREATIONSTATUS for
sample requests.
DMS. get ( sampl eRequest s[ i ] ,
SAMPLE_REQUEST. ORDERCREATI ONSTAT
US)
sampl eRequest I t ems The uid and
ORDERCREATIONSTATUS for
sample request items.
DMS. get ( sampl eRequest I t ems[ i ] ,
SAMPLE_REQUEST_I TEMS. ORDERCREATI
ONSTATUS)
Table 39. Data Available in validateSubmitData
Key Description How to access
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Call and Record Locking API
136
DRAFT - Modified May 27, 2014 4:45 pm
. . . ot her wi se. . .
var opt i ons = {
modul e : APPOI NTMENT,
DEANumber Enabl ed : " t r ue"
};
r et ur n DMSCal l . onAccept AndSi gn( opt i ons) ;
}
Call and Record Locking API
The DMS.js JavaScript library provides an application programming interface (API) that you can
modify to configure record locking for calls in Oracle CRM On Demand Disconnected Mobile Sales for
Tablets. For more information, see the following functions:
DMS.fieldsOnDelete Function on page 136
DMSCall.onDelete Function on page 137
DMS.fieldsOnDelete Function
You use the DMS.fieldsOnDelete function in the onDelete script for Sample Drop, Promo Items,
Sample Requests, and Product Detailed. Table 40 describes the DMS.showAlert function.
Table 40. DMS.fieldsOnDelete Function
Item Description
Parameters An array of fields. The field values are passed as arguments to the onDelete
function.
Example f unct i on f i el dsOnDel et e( ) {
r et ur n
DMS. f i el dsOnDel et e( [ APPOI NTMENT. STATUS. f ul l , ATTENDEE_CALL. STATUS. f ul
l ] ) ;
}
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Quick Selector API and Quick Selector Validate API
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
137
DRAFT - Modified May 27, 2014 4:45 pm
DMSCall.onDelete Function
You use the DMSCall.onDelete function in the onDelete script for Sample Drop, Promo Items, Sample
Requests, and Product Detailed. Table 41 describes the DMSCall.onDelete function.
Quick Selector API and Quick Selector
Validate API
The DMS.js JavaScript library abstracts the conditionQuery using the DMS.conditionQuery function,
which is described in Field Condition conditionQuery Function on page 127 and DMS.conditionQuery
Function on page 128. The DMS.js JavaScript library also provides an application programming
interface (API) that you can modify to configure quick selector lists and quick selector validation for
calls in Oracle CRM On Demand Disconnected Mobile Sales for Tablets.
For information about how the quick selector API uses the DMS.conditionQuery function for quick
selector lists and quick selector validation, see the following:
Quick Selector for Samples, Promotional Items, and Product Detailed on page 138
Quick Selectors for HCP Contact Allocation on page 139
Quick Selectors for Blocked Products on page 139
NOTE: You can create a similar function and options for other modules such as Promo Item Drop,
Product Detail, and Sample Request.
Table 41. DMSCall.onDelete Function
Item Description
Parameters An array of locks, prepared by the user. The lock is a JavaScript object
containing the following fields:
lockStatus, which is an array of values to be checked for enabling the lock.
status, which is the status against which lockStatus is checked.
lockEnable, which enables the lock.
Example f unct i on onDel et e( cal l st at us, at t endeest at us) {
var l ock1 = {
l ockSt at us : [ " Si gned" , " Submi t t ed" , " Submi t t i ng" ] ,
st at us : cal l st at us,
l ockEnabl e : t r ue
};
var l ock2 = {
l ockSt at us : [ " Si gned" , " Submi t t ed" , " Submi t t i ng" ] ,
st at us : at t endeest at us,
l ockEnabl e : t r ue
};
r et ur n DMSCal l . onDel et e( [ l ock1, l ock2] ) ;
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Quick Selector API and Quick Selector Validate API
138
DRAFT - Modified May 27, 2014 4:45 pm
Quick Selector for Samples, Promotional Items, and
Product Detailed
The quick selector template for Sample Drop, Promo Items, Product Detailed, and Sample Request
is as follows:
ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on condi t i onQuer y( ) {
r et ur n DMS. condi t i onQuer y( modul e) ;
}
f unct i on f i el dsOnFi l t er ( ) {
r et ur n DMS. f i el dsOnFi l t er ( [ f i el d1, f i el d2] ) ;
}
f unct i on onFi l t er ( f i el d1Val ue, f i el d2Val ue) {
. . . f unct i on shoul d r et ur n t r ue or f al se . . .
}
</ scr i pt ></ head><body></ Body></ ht ml >
where:
The value of (module) can be SAMPLEDROP, PROMODROP, PRODDETAILED, or SAMPLE_REQUEST
as required.
For field1 and field2, the MODULE.FIELD convention is used. For example,
DMS. f i el dsOnFi l t er ( [ APPOI NTMENT. STARTTI ME. par ent , ALLOCATI ON. ENDDATE. f ul l ] ) returns
" par ent . CLOGSTARTTI ME, par ent . CLOGENDTI ME".
For cases like par ent . 7. CLOGSTARTTI ME which are not yet supported by the DMS.js API, you
can use the string in the script. For example DMS. f i el dsOnFi l t er ( [ " par ent . 7. CLOGSTARTTI ME" ,
ALLOCATI ON. ENDDATE. f ul l ] ) returns " par ent . 7. CLOGSTARTTI ME, 16. CUSTDT02".
Note that APPOINTMENT.STARTTIME is CLOGSTARTTI ME, APPOINTMENT.STARTTIME.parent is
par ent . CLOGSTARTTI ME and APPOINTMENT.STARTTIME.full is 7. CLOGSTARTTI ME.
For an example of the quick selector code for Sample Drop, Promo Items, Product Detailed, and
Sample Request, see the following files which are located in the Scr i pt s/ Qui ckSel ect or J S folder of
your Oracle CRM On Demand Disconnected Mobile Sales installation:
QS_for_Sample_Drop.html
QS_PromoItems.html
QS for Product Detail.html
QS for Sample Requests.html
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Quick Selector API and Quick Selector Validate API
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
139
DRAFT - Modified May 27, 2014 4:45 pm
Quick Selectors for HCP Contact Allocation
For HCP Contact Allocation quick selectors, add [HCP] as the second argument in the
DMS.conditionQuery function as follows:
r et ur n DMS. condi t i onQuer y( SAMPLEDROP, [ HCP] ) ;
And change the fieldsOnFilter and onFilter functions, for example, as follows:
f unct i on f i el dsOnFi l t er ( ) {
r et ur n DMS. f i el dsOnFi l t er ( [ f i el d1, HCPEndDat e, f i el d2] ) ;
}
f unct i on onFi l t er ( f i el d1Val ue, HCPEndDat e, f i el d2Val ue) {
. . . f unct i on shoul d r et ur n t r ue or f al se . . .
}
For an example of the quick selector code for HCP Contact Allocation (for Sample Drop, Promo Items,
Product Detailed, and Sample Request), see the following files which are located in the Scr i pt s/
Qui ckSel ect or J S folder of your Oracle CRM On Demand Disconnected Mobile Sales installation:
QS_for_Sample_Drop HCP.html
QS_PromoItems HCP.html
QS for Product Detail HCP.html
QS for Sample Requests HCP.html
Quick Selectors for Blocked Products
If the blocked products feature is enabled, then add [BLOCKEDPRODUCTS] as the second argument
in the DMS.conditionQuery function as follows
r et ur n DMS. condi t i onQuer y( SAMPLEDROP, [ BLOCKEDPRODUCTS] ) ;
For an example of the quick selector code for Blocked Products (for Sample Drop, Promo Items,
Product Detailed, and Sample Request), see the following files which are located in the Scr i pt s/
Qui ckSel ect or J S folder of your Oracle CRM On Demand Disconnected Mobile Sales installation:
QS_for_Sample_Drop Blocked Products.html
QS_PromoItems Blocked Products.html
QS for Product Detail Blocked Products.html
QS for Sample Requests Blocked Products.html
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Controlled Substance Validation API
140
DRAFT - Modified May 27, 2014 4:45 pm
Controlled Substance Validation API
If shared address support is enabled for Oracle CRM On Demand Disconnected Mobile Sales, then
you must configure DEA number validation for samples so that validation is carried out when calls
are submitted for processing. Validation is carried out to see whether there are controlled substances
being requested or disbursed, and whether the physician has a valid DEA number for the address
location.
The DMS.js JavaScript library provides an application programming interface (API) that you can
modify to configure validation for controlled substances (DEA number). DEA number validation can
be enabled for the Appointment or the Attendee_Call modules. Enabling DEA number validation for
samples involves editing the onAcceptAndSign and onSubmitCall functions in the onSave JavaScript
code for the Appointment or the Attendee_Call module as required. A typical example of the code
that you modify is as follows:
f unct i on onAccept AndSi gn( ) {
var opt i ons = {
modul e : APPOI NTMENT,
DEANumber Enabl ed : " t r ue", / **enabl e DEA val i dat i on **/
cont r ol l edSubst anceVal i dFn : cust omCont r ol l edSubst anceVal i dat e
};
r et ur n DMSCal l . onAccept AndSi gn( opt i ons) ;
}
f unct i on onSubmi t Cal l ( ) {
var opt i ons = {
modul e : APPOI NTMENT,
DEANumber Enabl ed : " t r ue", / **enabl e DEA val i dat i on **/
cont r ol l edSubst anceVal i dFn : cust omCont r ol l edSubst anceVal i dat e
};
r et ur n DMSCal l . onSubmi t Cal l ( opt i ons) ;
}
f unct i on cust omCont r ol l edSubst anceVal i dat e( opt i ons, cont r ol l edSubst anceDat a) {
. . . user val i dat i on. . .
}
where:
modul e can be set to APPOINTMENT or ATTENDEE_CALL
DEANumber Enabl ed must be set to true
You can write custom DEA number validation functions inline, where the callback function is
assigned to the controlledSubstanceValidFn key in the onAcceptAndSign and onSubmitCall
functions. The callback method is similar to the Accept and Sign and Submit validation callback
methods described in Callback Functions on page 133.
The customControlledSubstanceValidate function is the (custom) callback function, which
implements the validation. You must decide whether you want default validation to be performed,
or to return either True or False.
val i at eDEA( opt i ons, cont r ol l edSubst anceDat a) indicates to perform default validation.
Table 42 describes the data that is available in controlledSubstanceData.
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Localization Code in DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
141
DRAFT - Modified May 27, 2014 4:45 pm
DMS. val i dat eAct i on( " t r ue" ) indicates that validation was a success.
DMS. val i at eAct i on( " f al se" ) indicates that validation failed.
For an example of the complete code for controlled substance (DEA number) validation in the
Appointment or Attendee Call onSave JavaScript functions, see the following files which are located
in the Scr i pt s/ Modul eJ S folder of your Oracle CRM On Demand Disconnected Mobile Sales
installation:
Appointment_onSave.html
AttendeeCall_onSave.html
For more information about the API call logic for Appointment and Attendee Call, see API Call Logic
for Appointment and Attendee Call on page 129.
Using JavaScript Localization Code in
DMS.js
Use the following localization APIs:
DMSUtil.fieldInfo on page 141
DMSUtil.moduleInfo on page 142
DMSUtil.keywordInfo on page 142
DMSUtil.deviceMessageInfo on page 143
DMSUtil.lovValue on page 143
DMSUtil.systemKeyInfo on page 144
DMSUtil.fieldInfo
This API helps to keep the fields in a global map variable with a Key: field_<moduleid>_<fieldlabel>
which can be fetched in the course of the execution of the code.
Table 42. Data Available in controlledSubstanceData
Key Example Usage Description
contactAddress DMS. get ( cont act Addr ess[ 0] ,
CONTACTADDRESS. DEAACTI VEFLAG)
Get the DEAACTIVEFLAG and
DEAEXPIRYDATEfor the Contact Address.
sampleDrops DMS. get ( sampl eDr ops[ i ] ,
PRODUCT. CONTROLLED)
Get the sample drop products with the
controlled flag.
sampleRequests DMS. get ( sampl eRequest s[ i ] ,
PRODUCT. CONTROLLED)
Get the sample request products with the
controlled flag.
call DMS. get ( cal l [ i ] ,
APPOI NTMENT. ENDTI ME)
Get the starttime and endtime of the
current call.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Localization Code in DMS.js
142
DRAFT - Modified May 27, 2014 4:45 pm
The usage of this API is in two steps:
Call this API for all the fields that you require in the onLoadJSON.
Retrieve the values from the keywords on demand.
The following example shows usage population:
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . f i el dI nf o( PRODDETAI LED, PRODDETAI LED. I NDI CATI ON) ) ;
opt i ons. push( DMSUt i l . f i el dI nf o( PRODDETAI LED, PRODDETAI LED. I SSUE) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ;
}
The following example shows usage retrieval:
var l abel =DMSUt i l . get Fi el dName( PRODDETAI LED, PRODDETAI LED. I NDI CATI ON)
DMSUtil.moduleInfo
This API helps to keep the fields in a global map variable with a Key: module_<moduleid> which can
be fetched in the course of the execution of the code.
The usage of this API is in two steps:
Call this API for all the fields that you require in the onLoadJSON.
Retrieve the values from the keywords on demand.
The following example shows usage population:
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . modul eI nf o( PRODDETAI LED) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ; }
The following example shows usage retrieval:
var l abel =DMSUt i l . get Modul eName( PRODDETAI LED)
DMSUtil.keywordInfo
This API helps to keep the fields in a global map variable with a Key: keyword_<moduleid>_fieldlabel
which can be fetched in the course of the execution of the code.
The usage of this API is in two steps:
Call this API for all the fields that you require in the onLoadJSON
Retrieve the values from the keywords on demand. This is a list.
The following example shows usage population:
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Using JavaScript Localization Code in DMS.js
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
143
DRAFT - Modified May 27, 2014 4:45 pm
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . keywor dI nf o( PRODDETAI LED, PRODDETAI LED. I NDI CATI ON) ) ;
opt i ons. push( DMSUt i l . keywor dI nf o( PRODDETAI LED, PRODDETAI LED. I SSUE) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ; }
The following example shows usage retrieval:
var l abel =DMSUt i l . get Keywor d( PRODDETAI LED, PRODDETAI LED. I NDI CATI ON)
DMSUtil.deviceMessageInfo
This API helps to keep the fields in a global map variable with a Key: the name of the device message
which can be fetched in the course of the execution of the code.
The usage of this API is in two steps:
Call this API for all the fields that you require in the onLoadJSON.
Retrieve the values from the messages on demand. This is a list.
The following example shows usage population:
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . devi ceMessageI nf o( [ " can' t . del et e. r ecor d" ] ) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ; }
The following example shows usage retrieval:
var l abel =DMSUt i l . get Devi ceMessage( [ " cant . del et e. r ecor d" ] )
DMSUtil.lovValue
This function helps to retrieve the translation for a keyword.
The usage of this API:
Call this API for all the fields that you require in the onLoadJSON.
Retrieve the values from the messages on demand.
The following example shows usage population:
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . l ovVal ue( " Det ai l Al l ocat i on" ) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ; }
The following example shows usage retrieval:
var l abel = DMSUt i l . get LovVal ue( " Det ai l Al l ocat i on" ) ;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
144
DRAFT - Modified May 27, 2014 4:45 pm
DMSUtil.systemKeyInfo
Use this function to retrieve value of system keys from the sqlite file or the database.
The usage of this API is in two steps:
Call this API for all the fields that you require in the onLoadJSON.
Retrieve the values from the messages on demand. This is a list.
The following example shows usage population:
f unct i on onLoadJ SON( ) {
var opt i ons = [ ] ;
opt i ons. push( DMSUt i l . syst emKeyI nf o( " Fi l t er SpmBl ockedPr oduct " ) ) ;
. . . .
r et ur n DMS. act i on( opt i ons) ; }
The following example shows usage retrieval:
var val ue = DMSUt i l . get Syst emKey( " Fi l t er SpmBl ockedPr oduct " ) ;
Client Inbound WritebacK API
The client inbound writeback API provides the ability for an external application to launch Oracle CRM
On Demand Disconnected Mobile Sales and update and create data in the client database which then
synchronizes correctly to Oracle CRM On Demand.
Example: A sales representative uses Oracle CRM On Demand Disconnected Mobile Sales to plan a
sales visit to a contact. The Rep taps a button in Oracle CRM On Demand Disconnected Mobile Sales
to launch an external eDetailing application and contact profile attribute information is sent to the
external application. The Sales Rep completes a detailing session in the external application and taps
a button in the external application to return to Oracle CRM On Demand Disconnected Mobile Sales.
A Message Response record is created under the Activity, based on the data sent from the external
application.
This API has the following features:
It calls an inbound Client API which launches the application and allows secure data write back
and update.
It creates multiple child object records under an existing parent record (such as Message
Responses).
It creates a single top-level object record (such as an Activity for a Contact).
It creates multiple top-level object records (such as Multiple Activities).
It updates a single top-level object record (such as update an Activity).
it sends in a custom URL request consisting of type of operation, target module, Parent Row
Identifiers, array of field values pairs for a given target module.
It configures a list of external applications that are legitimate clients to launch Oracle CRM On
Demand Disconnected Mobile Sales for write back.
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
145
DRAFT - Modified May 27, 2014 4:45 pm
It can prompt or not prompt a user in Oracle CRM On Demand Disconnected Mobile Sales prior
to insert or update by the inbound API from the external application.
It confirms successful create or update.
It notifies of failure to create or update.
Upon successful creation or update, it can display the appropriate page, depending on the
module involved, such as:
The detail page for the corresponding records is created or updated.
The call list page for a given date
External applications can start Oracle CRM On Demand Disconnected Mobile Sales to create or update
records by an inbound URL. The following actions are supported:
Creating multiple child object records under an existing parent record (such as Message
Responses) (Priority 1).
Creating a single top-level object record (such as an Activity for a Contact) (Priority 2).
Creating multiple top-level object records (such as Multiple Activities) (Priority 3).
Updating a single top-level object record (such as update an Activity) (Priority 4).
Each inbound URL for write back can only create or update records for a specific top-level or child
module. The inbound URL does not support cross-object create or update, such as creating account
records as well as contact records in one inbound URL.
Records created or updated are synchronized to Oracle CRM On Demand when Oracle CRM On
Demand Disconnected Mobile Sales connects to Oracle CRM On Demand. Prior to synchronizing to
Oracle CRM On Demand, new records have the row ID set to the device temp row ID. When
synchronized, the row ID is replaced with the Oracle CRM On Demand row ID.
The custom URL external applications can launch Oracle CRM On Demand Disconnected Mobile Sales
using the following the standard iOS Custom URL format:
appur l : / / command?par amet er 1=val ue1&par amet er 2=val ue2&
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
146
DRAFT - Modified May 27, 2014 4:45 pm
Table 43 describes the parameters available:
Table 43. Inbound URL Parameters
Component Details Example Comment
Registered
Application URL
(appurl)
This is the basis of the API registered by
the application in iOS. It calls Oracle CRM
On Demand Disconnected Mobile Sales.
Value = OracleCRMODDMS://
Or acl eCRMODD
MS: / /
None
Operation/
Command End
Point
Separate end points for each distinct type
of operation request, currently available:
The operation request NewRecord is the
command to create one or more new
records (either top-level or child) in
Oracle CRM On Demand Disconnected
Mobile Sales from an external application.
To create a child object, the top-level
record must exist and have the following
required parameters:
ModuleId
ChildModuleId
Record Context Key Value Pair (if
creating child records)
Array of Field Value Pairs
The operation request UpdateRecord is
the command to update an existing top-
level record in DMS from an external
application. It cannot update child-level
records. The following parameters are
required:
ModuleId
Record Context Key Value Pair
Field Value Pairs
Or acl eCRMODD
MS: / /
NewRecor d
or
Or acl eCRMODD
MS: / /
Updat eRecor d
Naming should be
understandable.
Name length
should be
optimized for
Custom URL
length
constraints.
Command
parameter
starting flag/
attribute
The ? symbol indicates the start of
command parameter values
? None
Command
Parameter
separators
The & symbol must be included between
each key value pair attribute
& None
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
147
DRAFT - Modified May 27, 2014 4:45 pm
Top-level Module
Target Key value
pairs
Specifies the top-level module related to
update and create:
Key = ModuleId
Value = the Id of the module to update/
create record
Modul eI d =1 None
Child-level
Module Target
Key value pairs
Specifies the child module related to the
create:
Key = ChildModuleId
Value = the Id of the module to create
record
Chi l dModul eI
d=2
None
Table 43. Inbound URL Parameters
Component Details Example Comment
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
148
DRAFT - Modified May 27, 2014 4:45 pm
Inbound URL examples
Create a new top-level Account record:
Or acl eCRMODDMS: / / NewRecor d?Modul eI d=1&ACCTNAME=NewAcct &ACCTXT01=Canada
Record Context
Key Value Pair
The set of user keys to update or create a
record. One set of user keys are required.
Key = Id
Value = The Oracle CRM On Demand row
ID or the device temp ID of the record to
update or the Oracle CRM On Demand row
ID.
The device temp ID of the parent record
associated with the to-be created child
records.
I d=Act i vi t y1
234
None
Field Value Pairs
Array
The set of field value pairs to be used
when creating or updating records The
parameters are:
Key. The name of the keys or the ME
Field Name of the field.
Value. The value of the field to be
used in the creating or updating of the
record
Each Key=Value set should be separated
by an ampersand (&).
Key value pairs are to be in the same
order for each of the child records to be
created or updated. The set of fields must
be completed for a record before the next
set of fields is appended to the URL for the
next record.
Because child fields in a sequence cannot
be skipped, if the value of one fields of the
child record is empty or null, the key still
appears in the inbound URL, however,
with no value (such as ContactCity=).
Any fields specified that are defined as
read-only are ignored.
ACCTNAME=New
Acct &ACCTXT0
1=Canada
None
Table 43. Inbound URL Parameters
Component Details Example Comment
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
149
DRAFT - Modified May 27, 2014 4:45 pm
Create a new child object Message Response records:
Or acl eCRMODDMS: / /
NewRecor d?Modul eI d=7&Chi l dModul eI d=19&CUSTSEQUENCENO=12A&CUSTCALLI D=12345&CUSTSEQU
ENCENO=BC3&CUSTCALLI D=12345
Update an existing top-level Account record:
Or acl eCRMODDMS: / / Updat eRecor d?Modul eI d=1&I d=123AB&ACCTXT01=US
Results of a Successful Insert or Update
Upon successfully creating or updating records in Oracle CRM On Demand Disconnected Mobile Sales
by an inbound URL from an external application, a prompt notifies the user that the operation has
been successful. The Oracle CRM On Demand Disconnected Mobile Sales screen that appears is
dependent upon whether the create or update is on a top-level module or a child module and whether
it is a single or multiple create or update.
If the create or update is on a single record, then the detail page in context of the single record
launches.
If the operation is on multiple top-level records, then the module screen with the list of records
filtered to the newly created or updated list of records displays, as well as the detail page of the first
record created or updated.
There is an exception with the Call module. If the operation is for calls on different days, the earliest
day that a record is created or updated displays with the call detail page for the call. The user has
to navigate to the other days manually to display other call records that were created or updated.
If the operation is on multiple child-level records, then the application displays a list of child-level
records for the parent record (based on both module id and child module id).
Error Cases
Any failures encountered in creating or updating records using the inbound URL result in a warning
message being displayed to the user in Oracle CRM On Demand Disconnected Mobile Sales and the
default start screen displayed. The warning messages displayed include the following information:
Invalid module Ids from the inbound URL.
One or more fields in the inbound URL cannot be found.
Required fields are not specified or set to empty in the inbound URL.
In the event of an update request and a valid context was provided, but the record could not be
found. For example, Account Id cannot be found.
Values specified that are invalid. For example, not the correct field type for the field, or the record
was not found for the references.
Any validations (soft or hard) that occur during save of a new or existing record via updating or
creating in Oracle CRM On Demand Disconnected Mobile Sales still apply to updates or creates.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using the DMS.js JavaScript Library in Oracle CRM On Demand Disconnected Mobile
Sales Client Inbound WritebacK API
150
DRAFT - Modified May 27, 2014 4:45 pm
As Read/Write access controls in Oracle CRM On Demand Disconnected Mobile Sales should be
maintained, if the user does not have access rights to create or update records for the specified
module, then Oracle CRM On Demand Disconnected Mobile Sales cannot create or update the
records.
Any other failures to insert or update records.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
151
DRAFT - Modified May 27, 2014 4:45 pm
10Using HTML in Oracle CRM On
Demand Disconnected Mobile
Sales
This chapter covers HTMP programming for Oracle CRM On Demand Disconnected Mobile Sales. It
includes the following topics:
Using Custom HTML for Oracle CRM On Demand Disconnected Mobile Sales on page 151
Creating a Custom User Interface Using HTML on page 155
Adding Customizeable HTML Views on page 159
Navigating to an HTML View from a Custom Button on page 160
Creating HTML Page Layouts for Presentations on page 161
Reading System Keys on page 163
Configuring HTML Components for Oracle CRM On Demand Disconnected Mobile Sales for Tablets on
page 164
File Structure for HTML Components on the Mobile Device on page 167
Using Custom HTML for Oracle CRM On
Demand Disconnected Mobile Sales
This topic guides you through creating an HTML applet, including the collaterals and uploading them
in Admin console and displaying it in an iPad. It includes of the following:
Structure of an HTML File on page 151
Bundling with Collaterals on page 153
About jQuery on page 153
Debugging CSS on page 153
Debugging CSS on page 153
About the melt:// Function on page 154
Available JSON Actions on page 154
Directory Structure on page 154
Structure of an HTML File
Below is a sample HTML file that illustrates the structure of an HTML applet.
<ht ml ><head>
<met a name=" vi ewpor t " cont ent =" wi dt h=def aul t - wi dt h; user - scal abl e=no; i ni t i al -
scal e=1. 6; maxi mum- scal e=1. 6" >
<t i t l e>i Sal es</ t i t l e>
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Using Custom
HTML for Oracle CRM On Demand Disconnected Mobile Sales
152
DRAFT - Modified May 27, 2014 4:45 pm
<l i nk r el =" st yl esheet " t ype=" t ext / css" hr ef =" dms_st yl e. css" >
<st yl e t ype=" t ext / css" >
body {
backgr ound- col or : r gb( 245, 250, 255) ;
}
/ * Rest of CSS */
</ st yl e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " sr c=" j quer y- 2. 0. 3. mi n. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " char set =" ut f - 8" >
var modul eXEnabl ed = f al se;
f unct i on onBodyLoad( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: i sModul eXExi st ( ) " ;
}
f unct i on i sModul eXExi st ( ) {
var opt i ons = [ {
act i on : " sel ect " ,
i nvoke : " onLoadJ SON" ,
par amet er s : [ {
modul ef i el ds : [ {
modul e : " cad_menui t ems" ,
f i el ds : [ " modul e_i d" ]
}] ,
f i l t er : " modul e_i d=xx"
}] ;
}] ;
r et ur n DMS. act i on( opt i ons) ;
}
f unct i on onLoadJ SON( x) {
i f ( x. l engt h > 0) {
modul eXEnabl ed = t r ue;
}
var opt i ons = [ . . . ] ;
r et ur en DMS. act i on( opt i ons) ;
}
/ * Rest of j avascr i pt */
</ scr i pt >
</ head>
<body onl oad=" onBodyLoad( ) " >
<! - - Rest of HTML - - >
</ body>
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Using Custom
HTML for Oracle CRM On Demand Disconnected Mobile Sales
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
153
DRAFT - Modified May 27, 2014 4:45 pm
<st yl e t ype=" t ext / css" >
</ st yl e>
</ ht ml >
Bundling with Collaterals
When creating an HTML applet, you can use many CSS, JavaScript, and image files. All these files
must be placed in the same folder and compressed in the zip format while preserving the hierarchical
model.
With CSS you can reuse a consistent set of attractive styles when creating or adapting custom HTML.
Start by creating reusable CSS classes for:
Tables
Headers
Multi value lists
Buttons
Check boxes
The classes should be:
Named. The prefix is DMS.
Specific. The CSS must be specific to the case in the user interface (not the business
functionality). For example, the quick selector column header should have a specific name.
A CSS file might be included in an Oracle-specific distribution directory.
About jQuery
jQuery is a JavaScript framework designed to simplify the client side scripting of HTML. To use
jQuery, add the following script tag in your HTML:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" j quer y- 2. 0. 3. mi n. j s" ></ scr i pt >
Example JavaScript code.
var sl i des = document . get ELement sByCl assName( " sl i de" ) ;
f or ( var i = 0; i < sl i des. l engt h; i ++) {
sl i des[ i ] . st yl e. col or = " r ed" ;
}
For a quick review of jQuery, visit:
ht t p: / / l ear n. j quer y. com/
Debugging CSS
In the Safari Web inspector, use the DOM tree view to display how the CSS translates to output view.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Using Custom
HTML for Oracle CRM On Demand Disconnected Mobile Sales
154
DRAFT - Modified May 27, 2014 4:45 pm
About the melt:// Function
The melt://executeFunction tells the application to use the Mobile Edge API. For example:
f unct i on onBodyLoad( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: i sModul eXExi st ( ) " ;
}
This tells the application that when the document body loads onBodyLoad comes into effect due to
body tag's inline script attribute (<body onload="onBodyLoad()">) , and onBodyLoad function in
turn invokes the melt function.
Available JSON Actions
The following JSON actions are available:
delete Action on page 154
exitpage Action on page 154
delete Action
The delete action deletes records. Here is an example of its usage:
opt i on = {
act i on : " del et e" ,
modul e : " 25" ,
ui d : DMS. get ( pr od[ 0] , PRODDETAI LED. ui d) ,
upsync : " yes" ,
del et ef r omcr m: " yes" ,
r emovef r omdevi ce: " yes"
};
exitpage Action
the exitpage actions tells the application to close the HTML Component.
opt i on = {
act i on : " exi t page"
}
Directory Structure
For efficient management, put all images in an images folder, CSS files in a styles folder and
JavaScript files in a scripts folder. When using these files do not forget to reference them with their
correct paths.
All HTML files are stored in the Documents folder in the client. The Documents folder has subfolders,
two of which are HTMLComponents and JSLibrary:
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating a Custom
User Interface Using HTML
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
155
DRAFT - Modified May 27, 2014 4:45 pm
JSLibrary. This contains the subfolder Oracle where the Json library is stored - it could contain
other subfolders specified by the customer.
HTMLComponents. This is the folder where HTML Components are stored. There is a subfolder
called Oracle where code included in the WAR is unpacked to. It could also contain other
subfolders specified by the customer.
All HTML components installed in the vendor-specific (Or acl e) folder are inaccessible from the server
user interface. You cannot upload or overwrite the files in this folder. The files are listed in the user
interface, but their folder names do not display. There are no subfolders, all files are stored in one
folder.
The Document s folder therefore becomes the root folder for accessing the JavaScript and HTML
libraries. All HTML code is stored in the HTMLComponent s/ Or acl e subfolders, so there are two levels
in the structure that you need to navigate through to get to the root Document s folder. Therefore,
the following code can reference code stored in JavaScript library DMS.js file:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
If you upload files in the user interface, you must specify the destination folder. This folder is a
subfolder of HTMLComponent s. If you create a subfolder called Test HTML, then the structure of files
uploaded is:
Document s
HTMLComponent s
Test HTML
Any zip file uploaded is unpacked in the client. Any existing subfolders in the zip are maintained. If
you want to reference the JavaScript library, assuming you have uploaded to
Document s>HTMLComponent s>Test HTML, there is also a two level subfolder structure, therefore you
can also use the following code to access DMS. j s in the Or acl e JSLibrary folder:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
Creating a Custom User Interface Using
HTML
You can create a custom user interface (UI) using HTML, CSS, and JavaScript. The following example
shows a normal HTML page:
<ht ml ><head>
<! - - Speci f y t he scal e l evel of t he page. - - >
<met a name=" vi ewpor t " cont ent =" wi dt h=def aul t - wi dt h; user - scal abl e=no;
i ni t i al scal e=1. 6; maxi mum- scal e=1. 6 " >
<! - - Speci f y t he t i t l e of t he doc page. - - >
<t i t l e>i Sal es</ t i t l e>
<! - - Li nk css f i l e. - - >
<l i nk r el =" st yl esheet " t ype=" t ext / css" hr ef =" st yl es/ dms_st yl e. css" >
<st yl e t ype=" t ext / css" >
body {
backgr ound- col or : r gb( 245, 250, 255) ; I nl i ne CSS
}
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating a Custom
User Interface Using HTML
156
DRAFT - Modified May 27, 2014 4:45 pm
/ * Rest of CSS */
</ st yl e>
<! Li nk DMS. j s - - >
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
<! - - > Li nk t o j Quer y l i br ar y. - - >
<scr i pt t ype=" t ext / j avascr i pt " sr c=" scr i pt s/ j quer y- 2. 0. 3. mi n. j s" ></ scr i pt
<! - - I nl i ne Scr i pt begi ns now. - - >
<scr i pt t ype=" t ext / j avascr i pt " char set =" ut f - 8" >
var modul eXEnabl ed = f al se;
f unct i on onBodyLoad( ) {
/ / onBodyLoad i s bei ng cal l ed on body l oad. Thi s i s speci f i ed i n t he body t ag.
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: i sModul eXExi st ( ) " ;
/ / Thi s r egi st er s a f unct i on i sModul eXExi st wi t h t he i OS code and expect s a J SON
as r et ur n f r omt he f unct i on.
}
f unct i on i sModul eXExi st ( ) {
var opt i ons = [ {
act i on : " sel ect " ,
i nvoke : " onLoadJ SON" ,
par amet er s : [ {
modul ef i el ds : [ {
modul e : " cad_menui t ems" ,
f i el ds : [ " modul e_i d" ]
}] ,
f i l t er : " modul e_i d=xx"
}] ;
}] ;
r et ur n DMS. act i on( opt i ons) ;
}
f unct i on onLoadJ SON( x) {
i f ( x. l engt h > 0) {
modul eXEnabl ed = t r ue;
}
var opt i ons = [ . . . ] ;
r et ur n DMS. act i on( opt i ons) ;
}
/ * Rest of j avascr i pt */
</ scr i pt >
</ head>
<body onl oad=" onBodyLoad( ) " >
<! - - Rest of HTML - - >
</ body>
<st yl e t ype=" t ext / css" >
</ st yl e>
</ ht ml >
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating a Custom
User Interface Using HTML
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
157
DRAFT - Modified May 27, 2014 4:45 pm
Packaging with Collaterals
Table 44 shows the directory structure of a normal HTML project.
While creating an HTML application, you use many CSS, JavaScript, and image files. These files must
be placed in the same folder and compressed to zip format while preserving the hierarchical model.
In the Admin Console, navigate to HTML Components and click Add. Table 45 shows the fields you
must complete.
Referring to Other Packages and JS Libraries
When linking to other files in the package or zip archive, use relative paths. For example if the JS
file for jQuery is in the scripts folder, the script tag is:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" scr i pt s/ j quer y- 2. 0. 3. mi n. j s" ></ scr i pt >
Link to DMS.js file as follows:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
Table 44. Directory Structure of an HTML Project
Object Name Object Type
fonts Folder
images Folder
PDQS.html HTML document
scripts Folder
styles Folder
Table 45. HTML Component Fields
Field Setting
Create new subfolder Selected
Folder Name SPM
Name Structured Product Menu
Type Quick Selector
Object Product Detailed
Title Products Detailed
Home page PDQS.html
Component package spm.zip
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating a Custom
User Interface Using HTML
158
DRAFT - Modified May 27, 2014 4:45 pm
melt Commands
A mel t command passes JSON actions to the application and fetches the results. For example, the
following code sample shows the onBodyLoad function:
<body onl oad=" onBodyLoad( ) " >
f unct i on onBodyLoad( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: i sModul eXExi st ( ) " ;
}
Now the application expects a JSON return from every function invoked.
Another example of mel t uses showAlert:
wi ndow. l ocat i on = " mel t : / / showAl er t : Hel l o Wor l d! "
This line displays a dialogue box with the phrase Hello World!.
Retrieving Data
To fetch data of various modules, use the select action. For example, if you want to fetch the address
of todays appointments, use the following method in the body tag:
<body onl oad=" onBodyLoad( ) " >
Use the following method in the onBodyLoad function:
f unct i on onBodyLoad( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: get Cal l Addr ess( ) " ;
}
Use the following method in the getCallAddress function:
f unct i on get Cal l Addr ess( ) {
var opt i on = {};
opt i on. act i on = " sel ect " ;
opt i on. i nvoke = " addr essObt ai ned" ;
opt i on. par amet er s = [ ] ;
opt i on. par amet er s[ 0] = {
modul ef i el ds : [ {
modul e : " 20" ,
f i el ds :
[ " ui d" , " CUSTTXT08" , " CUSTDESCRI PTI ON" , " CUSTTXT06" , " CUSTTXT07" , " CUSTTXT01" , " CUSTTXT0
5" , " CUSTTXT02" ]
}] ,
f i l t er : " 20. ui d i n ( sel ect CLOGADDRESS f r om7 wher e CLOGSTARTTI ME > " + new
Dat e( ( new Dat e( ) ) . t oLocal eDat eSt r i ng( ) ) / 1000 + " ) "
};
r et ur n DMS. act i on( [ opt i on] ) ;
}
Now the function addressObtained is invoked and its argument contains the address of todays
appointments.
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Adding
Customizeable HTML Views
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
159
DRAFT - Modified May 27, 2014 4:45 pm
exitpage Action
You can close the HTML page using the exitpage action. For example, if you have a button in HTML
and you want this button to close the HTML page, implement it like this:
<but t on i d=" cl ose" onCl i ck=" onCancel ( ) " >Cancel </ but t on>
f unct i on onCancel ( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: cancel Me( ) " ;
}
f unct i on cancel Me( ) {
r et ur n " [ {\ " act i on\ " : \ " exi t page\ " }] " ;
}
Alternatively, if DMS.js is linked, you can use this:
f unct i on cancel Me( ) {
r et ur n DMS. act i on( [ {act i on : ' exi t page' }] ) ;
}
Adding Customizeable HTML Views
You can create HTML User Interface components to be displayed in the Oracle CRM On Demand
Disconnected Mobile Sales client. The following features are available:
Oracle CRM On Demand Disconnected Mobile Sales displays custom Web components in a full
screen HTML View to the right of the vertical navigation bar.
Oracle CRM On Demand Disconnected Mobile Sales displays custom Web components in a popup
HTML View similar to a quick selector popup.
Oracle CRM On Demand Disconnected Mobile Sales displays custom Web components in a related
item HTML view, replacing the related item screen.
For example, you want a scheduling tab for sales reps to organize their calls. When clicking on the
scheduling tab, the sales representative has the ability to view the full week's schedule in a Gantt
chart style, drag and drop contacts or actions into time slots to create calls, adjust call by dragging
and dropping to different times, and apply call routes to a given week.
Table 46 shows the HTML page sizes.
Table 46. HTML Page Sizes
View Type Size
Data view/edit Frame 620 X 748
Full Screen 960 X 748
New Record 768 X 748
Context/Related List 620 X 748
Record List 340 X 748
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Navigating to an
HTML View from a Custom Button
160
DRAFT - Modified May 27, 2014 4:45 pm
Navigating to an HTML View from a
Custom Button
You can launch a shared HTML file and have separate functions within that HTML file, depending on
where the HTML was called from. You can call the HTML page from any object. You also have the
option to invoke a function on loading the HTML file, to have separate select queries, depending on
the page from which the query was launched. For example, Call Activity History can have a custom
action for Accounts and a different action for Contacts. Each action can execute a different function,
so when displaying Call Activity History, you can choose whether to display Account Calls or
Professional Calls.
In the following examples there are two functions used to perform a select action, one is the standard
onLoadJSON() function, which is called by default. The second function is loadFromAccount(), which
can select a different set of data if invoked.
The following example shows HTML Example JSON code (used when launched from Contact):
f unct i on onLoadJ SON( ) {
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " i sCont act Rel at edModul e\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 2\ " , \ " f i el ds\ " : \ " ui d\ " } ] , \ " f i l t er \ " : \ " 2. ui d
=$2. ui d\ " } ] }] " ;
}
The following example shows HTML Example JSON code (used when launched from Account):
f unct i on l oadFr omAccount ( ) {
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " i sAccount Rel at edModul e\ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 1\ " , \ " f i el ds\ " : \ " ui d\ " } ] , \ " f i l t er \ " : \ " 1. ui d
=$1. ui d\ " } ] }] " ;
}
To configure these actions you can create a Custom Action script for contacts that starts the HTML
page, at which point the onLoadJSON function is invoked. The following code sample shows one such
script:
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/
DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onAct i onJ SON( ) {
r et ur n
" [ {\ " act i on\ " : \ " l aunchscr een\ " , \ " ht ml page\ " : \ " Appoi nt ment Li st \ " , \ " t ar get f r ame\ " : \ "
f ul l scr een\ " }] " ;
}
</ scr i pt ></ head><body></ body></ ht ml >
You can configure a different launch screen to invoke the loadFromAccount function in a Custom
Action script for accounts, as follows:
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating HTML
Page Layouts for Presentations
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
161
DRAFT - Modified May 27, 2014 4:45 pm
<ht ml ><head><t i t l e>i Sal es</ t i t l e><scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/
DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onAct i onJ SON( ) {
r et ur n
" [ {\ " act i on\ " : \ " l aunchscr een\ " , \ " ht ml page\ " : \ " Appoi nt ment Li st \ " , \ " t ar get f r ame\ " : \ "
f ul l scr een\ " , \ " i nvoke\ " : \ " l oadFr omAccount \ " }] " ;
}
</ scr i pt ></ head><body></ body></ ht ml >
These samples show how one HTML page can perform different select queries depending on which
page the query was launched from. You can still use the $X.uid select as the current record in view
(when the custom action was launched from) is remembered.
Creating HTML Page Layouts for
Presentations
You can design and create HTML page layouts for presentations that can include content navigation
controls along the top of the page, similar to page tabs. These content navigations would typically
link to other message plan items using the navigatetoitem API. Content navigations along the top of
the page may go from left to right and stretch into the top center of the page and screen.
Example: Create a message plan with the default menu bar control check box turned on:
<! DOCTYPE ht ml >
<ht ml >
<head>
<scr i pt >
var message = " hi de" ;
f unct i on myFunct i on( ) {
i f ( message == " show" )
{message = " hi de" }
el se
{message = " show" }
wi ndow. l ocat i on = " mel t : / / det ai l er menubar : " + message; }
</ scr i pt >
</ head>
<body>
<p>Cl i ck t he but t on t o Show/ Hi de Menubar . </ p>
</ b>
<but t on oncl i ck=" myFunct i on( ) " >Cl i ck me</ but t on>
<p i d=" demo" >
</ p>
</ body>
</ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Creating HTML
Page Layouts for Presentations
162
DRAFT - Modified May 27, 2014 4:45 pm
You must then remove the existing mappings of DisableNavigation, DisableResponse,
DefaultMenuBarControl and replace with the configuration shown in Table 47.
Table 47. Messaging Plan Field Mappings
Order
Data Source
Field Name
Server
Field
Name Label Type
Attri
bute Look Up Skip? Required
1.1 Name CUSTME
SSAGEPL
ANNAME
Name TEXT(
80)
None Yes(1) No Yes
1.2 ProductId CUSTREF
PRODUC
T
ProductId REFER
ENCE(
Produ
ct)
None No No Yes
1.3 Type CUSTME
SSAGEPL
ANTYPE
Type KEYW
ORD(
Messa
ging
Plan,
Type)
None Yes(2) No No
1.4 OwnerfullNam
e
CUSTOW
NER
Owner:
Name
OWNE
R(80)
None No No No
1.5 LockSequence CUSTKW
01
Lock
Sequence
CHEC
KBOX(
0)
None No No No
1.6 EnableFollowu
p
CUSTKW
02
Enable
Followup
CHEC
KBOX(
0)
None No No No
1.7 Audience CUSTTXT
01
Audience TEXT(
80)
None No No No
1.8 Comments CUSTTXT
02
TEXT(
80)
None No No No
1.9 DisableNaviga
tion
DISABLE
NAVIGAT
ION
Disable
Navigation
CHEC
KBOX(
0)
None No No No
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Reading System
Keys
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
163
DRAFT - Modified May 27, 2014 4:45 pm
The new HTML page is available for use after you download the new configuration to the client.
Reading System Keys
You can read the value of a system key. The following code sample illustrates how to read the value:
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " sr c=" Or acl e/ DMS. j s" ></ scr i pt >
<scr i pt t ype=" t ext / j avascr i pt " >
f unct i on onAct i onJ SON( ) {
var opt i ons=[ ] ;
opt i ons. push( DMSUt i l . syst emKeyI nf o( " t eskey" ) ) ;
cur r ent =APPOI NTMENT;
opt i ons[ 1] ={};
opt i ons[ 1] . act i on=" sel ect " ;
opt i ons[ 1] . i nvoke=" t est met hod" ;
opt i ons[ 1] . par amet er s = [ {
modul ef i el ds : [ {
modul e : cur r ent ,
f i el ds : [ cur r ent . STATUS, cur r ent . ui d]
}] ,
f i l t er : " ui d = $" +cur r ent +" . ui d or devi cer owi d = $" +cur r ent +" . ui d"
}] ;
r et ur n DMS. act i on( opt i ons) ;
}
f unct i on t est met hod( r ows) {
var val ue=DMSUt i l . get Syst emKey( " t eskey" ) ;
al er t ( val ue) ;
r et ur n DMS. val i dat eAct i on( " t r ue" ) ;
}
</ scr i pt ></ head></ ht ml >
1.10 DisableRespo
nse
DISABLE
RESPON
SE
Disable
Response
CHEC
KBOX(
0)
None No No No
1.11 DefaultMenuB
arControl
DEFAULT
MENUBA
RCONTR
OL
Default
Menu Bar
Control
CHEC
KBOX(
0)
None No No No
Table 47. Messaging Plan Field Mappings
Order
Data Source
Field Name
Server
Field
Name Label Type
Attri
bute Look Up Skip? Required
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Configuring HTML
Components for Oracle CRM On Demand Disconnected Mobile Sales for Tablets
164
DRAFT - Modified May 27, 2014 4:45 pm
Configuring HTML Components for
Oracle CRM On Demand Disconnected
Mobile Sales for Tablets
The purpose of HTML components in Oracle CRM On Demand Disconnected Mobile Sales for Tablets
is to replace a certain part of the client UI with an equivalent HTML view. You can customize the HTML
view to have, for example, a Close button and other features as required. The HTML view appears in
one of the following formats in the client application:
As a full screen HTML page that is displayed to the right of the vertical navigation bar.
As a full screen pop-up HTML page that is similar to the existing quick selector pop-up screen.
As a related item HTML page that replaces the existing related item screen.
HTML components are uploaded to the Oracle CRM On Demand Disconnected Mobile Sales for Tablets
Server and associated with a module. There are three types of HTML components, as follows:
Data Display. This HTML view type displays the standard list and detail information for a
module. You can customize the HTML view by specifying the target view to navigate to when the
user is finished with the view, and also by using the core JavaScript and JSON APIs supported by
Oracle CRM On Demand Disconnected Mobile Sales for Tablets. For example, you can:
Use the JSON API to perform query, create, update, and delete operations on a modules list
and detail information from the HTML page.
Create scripts to query the Oracle CRM On Demand database and retrieve information to
display and use within a presentation context.
Create write back operations to the Oracle CRM On Demand database for objects and
attributes that are outside core Message Response tracking.
Quick Selector. This HTML view type displays the quick selector information for a module. You
can customize the HTM L view, for example, by including a Close button on the HTML page as
follows:
<i nput t ype=" but t on" val ue=" Cancel " onCl i ck=" onCancel ( ) " / >
f unct i on onCancel ( ) {
wi ndow. l ocat i on = " mel t : / / execut eFunct i on: cancel Me( ) " ;
}
f unct i on cancel Me( ) {
r et ur n " [ {\ " act i on\ " : \ " exi t page\ " }] " ;
}
When the Close button is selected, the HTML view closes and the user is returned to the detail
page from where the HTML view was launched.
Inbound URL. This HTML view type starts a browser and navigates to a particular URL address,
or starts a new application.
The following procedure shows you how to configure HTML components.
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Configuring HTML
Components for Oracle CRM On Demand Disconnected Mobile Sales for Tablets
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
165
DRAFT - Modified May 27, 2014 4:45 pm
To configure HTML components
1 Start the Admin application.
2 If not already done, enable HTML components for use on client devices as follows:
Click Administrator, then System Keys on the vertical navigation bar.
Set the enable.html.components system key to Yes.
3 Configure a new HTML component as follows:
a Click HTML Components on the vertical navigation bar.
The following table describes the information that is displayed on the page that opens.
b Click Add.
c On the page that opens, complete the fields shown in the following table.
Field Description
Name The name of the HTML component. For example: CAH, PDQS, Appt.
Object The name of the module in Oracle CRM On Demand Disconnected Mobile
Sales for Tablets. For example: CallActivityHistory, Call ProdDetail,
Appointment.
Type The type of HTML component, which can be one of the following: Data
Display, Quick Selector, or Inbound URL.
Title The title of the page.
Folder The folder where the HTML component file is stored. For example:
Oracle/CAH.html
Oracle/PDQS.htm
Oracle/Appt.zip
For more information, see File Structure for HTML Components on the Mobile
Device on page 167
Field Description
Select Folder Specify where to upload the HTML component package to by doing one of
the following:
Select the Create new subfolder option, and then enter a name for the
new subfolder.
Select the Upload to Existing Subfolder option, and then select an
existing folder from the drop-down list.
Name Enter a name for the HTML component package.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales Configuring HTML
Components for Oracle CRM On Demand Disconnected Mobile Sales for Tablets
166
DRAFT - Modified May 27, 2014 4:45 pm
d Click Save.
4 Add the appropriate onQui ckAct i on( ) JavaScript configuration to a modules Detailer button as
follows:
a Click Map Settings, then Module Settings on the vertical navigation bar.
b Click More next to a module, and then click Quick Action.
c Click Edit next to the Detailer button. If there is no Detailer button configured for the module,
then configure one. Note that the Detailer button is a hardcoded function, which is automatically
called. You must overwrite this old function to configure the HTML component.
d Replace the following old function:
r et ur n " [ {\ " act i on\ " : \ " showdet ai l \ ", \ "ht ml page\ " : \ " Message Pl an
Det ai l s\ " , \ " i nvoke\ " : \ " showDet ai l sOf MsgPl an\ " , \ " par amet er \ " : \ " " + pl an +"\ " }] " ;
with the following new function, for example:
f unct i on onQui ckAct i on( ) { r et ur n
"[ {\ " act i on\ ": \ "l aunchscr een\ ", \ "t ar get f r ame\ " : \ " det ai l scr een\ " , \ " ht ml page\ " : \ "
Message Pl an Det ai l s\ " , \ " i nvoke\ ": \ " showDet ai l sOf MsgPl an\ ", \ "par amet er \ ": \ "" +
pl an +"\ " }] " ; }
This example indicates to display the Message Plan Details HTML view and to call the
showDetailsOfMsgPlan function.
5 Add a custom action, which includes the JavaScript to launch the HTML view, as follows:
a Click Map Settings, then Module Settings on the vertical navigation bar.
b Click More next to the module, select JavaScript, and then Add JavaScript.
Type Specify the type of HTML component package that you are uploading, which
can be one of the following:
Data Display. Select this option if uploading an HTML component
package to display the standard list and detail information for a module.
Quick Selector. Select this option if uploading an HTML component
package to display the quick selector information for a module.
Inbound URL. Select this option if uploading an HTML component
package to start a browser and navigate to a particular URL address, or
to start a new application.
Object Select a module to associate the HTML component with from the drop-down
list.
Title Enter a title.
Home Page Enter a home page URL.
Component
Package
Click Browse to go to the location on your local machine where the HTML
component package is stored, and then click Open.
Field Description
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales File Structure for
HTML Components on the Mobile Device
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
167
DRAFT - Modified May 27, 2014 4:45 pm
c Select CustomActions from the Type drop-down list.
d Enter a display value for the custom action.
e Enter the JavaScript to launch the HTML view in the Expression box. The JavaScript used to
launch the HTML view is as follows:
f unct i on onAct i onJ SON( ) { r et ur n
"[ {\ " act i on\ ": \ "l aunchscr een\ ", \ "ht ml page\ " : \ " HTMLComponent Name\ " , \ " t ar get f r ame
\ " : \ " f ul l scr een\ " }] " ;
where:
HTMLComponentName defines which HTML component to launch within the frame. The
value that you enter must correspond to the actual name of the component as stored in
the Name field on the HTML Components List page.
The targetframe for the HTML view is fullscreen in this example, but it could also be
detailscreen. In both cases, the HTML view is launched in a frame occupying the work
area of the application (right hand pane).
6 Enable the module in question to be displayed in HTML format on client devices as follows:
a Click Map Settings, then Module Settings on the vertical navigation bar.
b Click Edit next to the module.
c Select the Display as HTML check box.
7 Deploy the updated metadata to users for the changes to take effect.
File Structure for HTML Components on
the Mobile Device
The Documents folder is the root folder for accessing JavaScript and HTML library files in Oracle CRM
On Demand Disconnected Mobile Sales for Tablets. The Documents folder has the following
subfolders:
JSLibrary. This folder contains the subfolder Oracle, where the JSON library is stored. JSLibrary
can contain other subfolders as required.
HTMLComponents. This is the folder where HTML Components are stored. HTML Components
contains a subfolder called Oracle where the code that is included in the WAR file is unpacked to.
HTML Components can contain other subfolders as required.
When you upload a new HTML component package in the Admin application, you must specify
which folder to upload the package to, and the folder must be a subfolder of HTMLComponents.
For Oracle, all HTML code is stored in the HTMLComponent s/ Or acl e subfolder.
If you have uploaded HTML components to Document s/ HTMLComponent s/ Or acl e, then you can
use the following to reference and access the DMS.js file in the JSLibrary folder:
<scr i pt t ype=" t ext / j avascr i pt " sr c=" . . / . . / J SLi br ar y/ Or acl e/ DMS. j s" ></ scr i pt >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Using HTML in Oracle CRM On Demand Disconnected Mobile Sales File Structure for
HTML Components on the Mobile Device
168
DRAFT - Modified May 27, 2014 4:45 pm
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
169
DRAFT - Modified May 27, 2014 4:45 pm
11Local Database Tables for
Oracle CRM On Demand
Disconnected Mobile Sales
Client
This chapter introduces the Oracle CRM On Demand Disconnected Mobile Sales for Tablets application
local database tables. It contains the following topics:
Overview of Database Tables on page 169
Viewing Stored Records in the Local Database of the Client Application on page 170
Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables on page 170
Local Database Tables Field Definition on page 172
Overview of Database Tables
Oracle CRM On Demand Disconnected Mobile Sales for Tablets uses a local database containing a
number of tables that store information for the Oracle CRM On Demand Disconnected Mobile Sales
for Tablets client application. The tables store information about, for example, the configurations for
the Oracle CRM On Demand Disconnected Mobile Sales for Tablets client application, the records that
are accessible in the client application, and the requests waiting to be synchronized with Oracle CRM
On Demand.
You can access the local database tables using the Oracle CRM On Demand Disconnected Mobile Sales
for Tablets client application and JavaScript. For example:
You can use the tables as part of the filter criteria for JavaScript Object Notation (JSON)
For more information, see JSON Filter Parameter on page 103 which explains how the
me_datarelation table is used in the filter parameter of the JSON Select action.
You can directly query the tables using the JSON Select action.
For example, cad_menuitems stores a list of modules that are enabled on user devices.
The following Select action queries for AttendeeCalls (Module 64) in cad_menuitems and invokes
the isAttendeeCallModuleExist function, which checks the results to determine if the module is
enabled. If the module is enabled, then certain actions are performed. If the module is not
enabled, then no other actions are performed.
r et ur n " [
{\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " i sAt t endeeCal l Modul eExi st \ " , \ " par amet er s\ " :
[ {\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " cad_menui t ems\ " , \ " f i el ds\ " : \ " modul e_i d\ "
} ] , \ " f i l t er \ " : \ " modul e_i d=64\ " } ] } ] " ;
You can use the tables when trying to diagnose issues that occur, especially when using
JavaScript in Oracle CRM On Demand Disconnected Mobile Sales client application.
For more information, see Oracle CRM On Demand Disconnected Mobile Sales Local Database
Tables on page 170.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Viewing Stored Records in the Local Database of the Client Application
170
DRAFT - Modified May 27, 2014 4:45 pm
Viewing Stored Records in the Local
Database of the Client Application
The following procedure shows you how to search for and view the stored records in the local
database of the Oracle CRM On Demand Disconnected Mobile Sales application.
To view the stored records in the local database of the client application
1 Tap the Oracle CRM On Demand Disconnected Mobile Sales application on your user device to
start the Oracle CRM On Demand Disconnected Mobile Sales application.
2 Tap Accounts, Contacts, or Detailer on the application banner to display the list.
3 Tap the Search/Lookup bar, then enter the following search string.
cr m***
4 Tap Search on the keyboard, and then tap Show database.
5 Enter a suitable query, and then tap Run.
For example, enter the following to query the pending requests table:
sel ect * f r omme_r equest queue
The list of pending requests, waiting to synchronize with Oracle CRM On Demand is returned.
Oracle CRM On Demand Disconnected
Mobile Sales Local Database Tables
Table 48 lists the database tables that are used in the Oracle CRM On Demand Disconnected Mobile
Sales application.
Table 48. Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables
Table Name Table Description
cad_apprules Stores all the application validation rules.
cad_context Stores context settings from the server.
cad_externalappscheme Stores all external application configurations.
cad_fieldgroups Fields are grouped into different display groups. Information on
grouping is stored in this table.
cad_field_conditions Contains all the field conditions, whether they are required, read only,
or hide conditions. Also stores the JavaScript filters for reference
objects (conditionQueryJSON).
cad_formfields Stores the map settings for each field, including the following: module
ID, field ID, field label, type, length, default value.
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
171
DRAFT - Modified May 27, 2014 4:45 pm
cad_implicit_ids Stores the modules with a REFERENCE-IMPLICIT type, that are not
used in Oracle CRM On Demand Disconnected Mobile Sales but are
only used in Microsoft CRM.
cad_keyword Stores all the information related to keywords, including the following:
keyword ID display value, alias information, conditional information.
cad_lookup Stores the fields that are enabled for lookup, listed by module.
cad_menuitems Stores the module settings and menu settings information, including
the following: module IDs, labels, sort fields, search fields, heading
information, read only and delete settings, and so on.
cad_modulefields Contains the menu settings and the business card settings.
cad_moduleicons Stores information relating to any conditional icons configured in the
Oracle CRM On Demand Disconnected Mobile Sales application,
including the conditional rules and icons used.
cad_modulerules Stores the JavaScript code. The onSave, onDelete, onOpen code is
stored by module ID.
cad_options Stores information about the Oracle CRM On Demand CRM Server and
copy to calendar, address book, and task options displayed in Global
Settings.
cad_qsfields Stores the parameters for all fields configured within the Quick
Selector, including fields stored, length, parent and child details.
cad_qsfilters Stores the JavaScript used to define filters, validation, and toggle
buttons for the Quick Selector.
cad_qsmodules Stores information about all modules with configured Quick Selectors.
Contains the information defined in the list section of Quick Selector
menu.
cad_quickactions Stores all quick action button configurations, including icon files used.
cad_stfields Lists all of the fields and settings used if modules are configured to be
displayed in a Table Form.
cad_stfilters Contains the JavaScript code, which filters the information displayed
in tables.
cad_systemkeys Stores the system keys, and their settings.
me_addressbookuid Stores the address book entries that have been synchronized to the
native client application. If the data is removed from Oracle CRM On
Demand Disconnected Mobile Sales, then this table is used to remove
the data from the native application also.
me_alertdata Stores all the data that is displayed in the synchronization log.
me_attachments Stores the details of attachments, if configured. Contains signature,
and are used for photos in future releases.
Table 48. Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables
Table Name Table Description
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
172
DRAFT - Modified May 27, 2014 4:45 pm
Local Database Tables Field Definition
This topic lists the fields defined in each of the Oracle CRM On Demand Disconnected Mobile Sales
local database tables described in Table 48 on page 170.
me_calendaruid Stores the calendar entries that have been synchronized to the native
calendar application on the user device. If data is removed from
Oracle CRM On Demand Disconnected Mobile Sales, then this table is
used to remove the data from the native application also.
me_datarelation Stores the Parent-Child relationships, including the row ID or
temporary device row ID relationships, and the modules related to
every record where a relationship exists.
me_edited Stores edited information, pending successful update to Oracle CRM
On Demand. If the update permanently fails, then the data is restored
from this table.
me_geocode Stores the latitude and longitude information for addresses.
me_login Stores the login details of the current user.
me_lookup Stores the cached lookup requests, data searched for, status and
count of records returned.
me_lookupresponse Stores the cached lookup response from the server, including all
information displayed in the lookup results page.
me_requestqueue Stores all the XML requests from the user device that are waiting to
be sent to the server. If the user device is switched to offline mode,
then you can see the exact requests queued to server.
me_sortfields Stores the fields and the order in which they are sorted in the
application.
me_temp Stores the temporary packets received from the server during and
initial load or update. When the packets have been downloaded to this
table, they are processed in the order that they were received.
me_uniqueid Stores the C+ incremental value used in combination with the device
PIN to calculate the devicerowid of record.
medata_x, where x is the
moduleid.
These tables are created when the CAD is received, and store all data
on the user device in the corresponding module ids(x). For example
Appointment (Module ID 7) is stored in medata_7.
Table 48. Oracle CRM On Demand Disconnected Mobile Sales Local Database Tables
Table Name Table Description
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
173
DRAFT - Modified May 27, 2014 4:45 pm
cad_apprules Table
The cad_apprules table stores all the application validation rules. Table 49 lists the fields defined in
cad_apprules.
cad_context Table
The cad_context table stores the context settings from the server. Table 50 lists the fields defined in
cad_context.
Table 49. cad_apprules Table Field Definition
Field Name Data Type Constant Values
rule_name text None
message text None
status integer The status for the active rule is 1,
and for the inactive rule is zero (0).
Table 50. cad_context Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
context_id integer None
listview varchar(1) The constant values are:
form view is zero (0).
list view is 1.
multiref is 2.
sortfield1 varchar(40) None
sortfield2 varchar(40) None
sortfield3 varchar(40) None
sortfield4 varchar(40) None
sortfield5 varchar(40) None
sortfield6 textvarchar(40) None
condition text None
NOTE: If the condition is True, then hide the
related item.
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
174
DRAFT - Modified May 27, 2014 4:45 pm
cad_externalappscheme Table
The cad_externalappscheme table stores all the external application configurations. Table 51 lists the
fields defined in cad_externalappscheme.
cad_fieldgroups Table
The cad_fieldgroups table stores information about how the fields are grouped into different display
groups. Table 52 lists the fields defined in cad_fieldgroups.
condition_tags text None
NOTE: The XML tags, which are included in
the condition field.
context_delete text None
context_label text None
Table 51. cad_externalappscheme Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
moduleid integer None
applicationurl text None
integrationpoint text None
parameters text None
displayname text None
Table 52. cad_fieldgroups Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
group_id integer None
field_id integer None
viewtoken text None
grouplabel text None
Table 50. cad_context Table Field Definition
Field Name Data Type Constant Values
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
175
DRAFT - Modified May 27, 2014 4:45 pm
cad_fieldconditions Table
The cad_field_conditions table contains all the field conditions, whether they are required, read only,
or hide conditions. Also stores the JavaScript filters for reference objects (conditionQueryJSON).
Table 53 lists the fields defined in cad_field_conditions.
cad_formfields Table
The cad_formfields stores the map settings for each field. Table 54 lists the fields defined in
cad_formfields.
Table 53. cad_field_conditions Table Field Definition
Field Name Data Type Constant Values
module_id integer None
field_id integer None
mefield text None
condition text None
condition_type integer The constant values are:
required is zero (0).
readonly or hidden is 1.
javascript is 2.
Table 54. cad_formfields Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
field_id text None
field_label text None
field_type integer None
field_length integer None
default_value text None
xml_tag varchar(40) None
attributes integer None
other varchar(20) None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
176
DRAFT - Modified May 27, 2014 4:45 pm
cad_implicit_ids Table
The cad_implicit_ids table stores the modules with a REFERENCE-IMPLICIT type, that are used not
in Oracle CRM On Demand Disconnected Mobile Sales but are only used in Microsoft CRM. Table 55
lists the fields defined in cad_implicit_ids.
cad_fieldkeyword Table
The cad_keyword table stores all the information related to keywords. Table 56 lists the fields defined
in cad_keyword.
cad_lookup Table
The cad_lookup table stores the fields that are enabled for lookup, listed by module. Table 57 lists
the fields defined in cad_lookup.
Table 55. cad_implicit_ids Table Field Definition
Field Name Data Type Constant Values
implicit_id integer None
module_id text None
Table 56. cad_keyword Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
keyword_id integer None
alias_name text None
element_name text None
parent_name text None
Table 57. cad_lookup Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
field_id integer None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
177
DRAFT - Modified May 27, 2014 4:45 pm
cad_menuitems Table
The cad_menuitems table stores the module settings and menu settings information. Table 58 lists
the fields defined in cad_menuitems.
Table 58. cad_menuitems Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
listname text None
menuname text None
toplevel varchar(1) The constant values for these fields are:
No is zero (0).
Yes is 1.
grouped varchar(1)
readonly varchar(1)
allowedit varchar(1)
recordlimit integer None
NOTE: This field is currently not used.
module_type integer None
sortfield1 varchar(40) None
NOTE: These fields are kept for
compatibility purposes.
sortfield2 varchar(40)
sortfield3 varchar(40)
sortfield4 varchar(40)
sortfield5 varchar(40)
sortfield6 varchar(40)
headingfield1 varchar(40)
headingfield2 varchar(40)
headingfield3 varchar(40)
searchfield1 varchar(40)
searchfield2 varchar(40)
searchfield3 varchar(40)
searchfield4 varchar(50)
isremovable varchar(1) The constant values for these fields are:
No is zero (0).
Yes is 1.
isTableview varchar(1)
removeFromDevice varchar(1)
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
178
DRAFT - Modified May 27, 2014 4:45 pm
cad_modulefield Table
The cad_modulefields table contains the menu settings and the business card settings. Table 59 lists
the fields defined in cad_modulefields.
cad_moduleicons Table
The cad_moduleicons table stores information relating to any conditional icons configured in the
Oracle CRM On Demand Disconnected Mobile Sales application, including the conditional rules and
icons used. Table 60 lists the fields defined in cad_moduleicons.
Table 59. cad_modulefields Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id text None
title_fields text None
search_fields text None
description_fields text None
businesscard_fields text None
Table 60. cad_moduleicons Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id text None
condition text None
iconpath text None
condition_tags text None
type integer None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
179
DRAFT - Modified May 27, 2014 4:45 pm
cad_modulerules Table
The cad_modulerules table stores the JavaScript code. The onSave, onDelete, onOpen code is stored
by module ID. Table 61 lists the fields defined in cad_modulerules.
cad_options Table
The cad_options table stores information about the Oracle CRM On Demand CRM Server and copy to
calendar, address book, and task options displayed in Global Settings. Table 62 lists the fields defined
in cad_options.
Table 61. cad_modulerules Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id text None
event_type text None
jscript text None
displayname text None
Table 62. cad_options Table Field Definition
Field Name Data Type Constant Values
protocol text None
server_name text None
server_port varchar(30) None
server_context varchar(30) None
copy_contacts varchar(1) The constant values for these fields are:
No is zero (0)
Yes is 1.
copy_leads varchar(1)
copy_task varchar(1)
copy_calendar varchar(1) The constant values are:
No is zero (0).
Yes is 1.
Copy calendar owner is 2.
isdownloadonelevel varchar(5) None
Applogo text None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
180
DRAFT - Modified May 27, 2014 4:45 pm
cad_qsfields Table
The cad_qsfields table stores the parameters for all fields configured within the Quick Selector.
Table 63 lists the fields defined in cad_qsfields.
cad_qsfilters Table
The cad_qsfilters table stores the JavaScript used to define filters, validation, and toggle buttons for
the Quick Selector. Table 64 lists the fields defined in cad_qsfilters.
Table 63. cad_qsfields Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
parenttype integer None
childtype integer None
mefield text None
fieldtype text None
fieldwidth text None
ishidden text None
Table 64. cad_qsfilters Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
parenttype integer None
childtype integer None
expression text None
filter_label text None
filter_type text None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
181
DRAFT - Modified May 27, 2014 4:45 pm
cad_qsmodules Table
The cad_qsmodules table stores information about all modules with configured Quick Selectors.
Contains the information defined in the list section of Quick Selector menu. Table 65 lists the fields
defined in cad_qsmodules.
cad_quickactions Table
The cad_quickactions table stores all quick action button configurations, including icon files used.
Table 66 lists the fields defined in cad_quickactions.
Table 65. cad_qsmodules Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
parenttype integer None
childtype integer None
title text None
parentprimaryfield text None
intersectionfield text None
Table 66. cad_quickactions Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
moduleid integer None
placeholder integer None
iconurl text None
actionstring text None
qafilter text None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
182
DRAFT - Modified May 27, 2014 4:45 pm
cad_stfields Table
The cad_stfields table lists all of the fields and settings used if modules are configured to be displayed
in a Table Form. Table 67 lists the fields defined in cad_stfields.
cad_stfilters Table
The cad_stfilters table contains the JavaScript code, which filter the information displayed in tables.
Table 68 lists the fields defined in cad_stfilters.
Table 67. cad_stfields Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
moduleid integer None
fieldtype text None
mefield text None
fieldwidth text None
istotal text None
ispreload text None
Table 68. cad_stfilters Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
moduleid integer None
expression text None
filter_label text None
filter_type text None
filter_module integer None
filter_mefield text None
input_type text None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
183
DRAFT - Modified May 27, 2014 4:45 pm
cad_systemkeys Table
The cad_systemkeys table stores the system keys, and their settings. Table 69 lists the fields defined
in cad_systemkeys.
me_addressbookuid Table
The me_addressbookuid table stores the address book entries that have been synchronized to the
native client application. If the data is removed from Oracle CRM On Demand Disconnected Mobile
Sales, then this table is used to remove the data from native application also. Table 70 lists the fields
defined in me_addressbookuid.
Table 69. cad_systemkeys Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
key text None
value text None
description text None
Table 70. me_addressbookuid Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
meuid text None
addressbookuid text None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
184
DRAFT - Modified May 27, 2014 4:45 pm
me_alertdata Table
The me_alertdata table stores all the data that is displayed in the synchronization log. Table 71 lists
the fields defined in me_alertdata.
me_attachments Table
The me_attachments table stores the details of attachments, if configured. Contains signature, and
are used for photos in future releases. Table 72 lists the fields defined in me_attachments.
Table 71. me_alertdata Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
uid text None
alert_type integer None
module_id integer None
title text None
received_date text None
details text None
status text None
message text None
edited_fields text None
Table 72. me_attachments Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
uid text None
deviceroid text None
xmltag text None
filename text None
attachment text None
thumb_filename text None
isedited integer None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
185
DRAFT - Modified May 27, 2014 4:45 pm
me_calendaruid Table
The me_calendaruid table stores the calendar entries that have been synchronized to the native
calendar application on the user device. If data is removed from Oracle CRM On Demand
Disconnected Mobile Sales, then this table is used to remove the data from the native application
also. Table 73 lists the fields defined in me_calendaruid.
me_datarelation Table
The me_datarelation table stores the Parent-Child relationships, including the row ID or temporary
device row ID relationships, and the modules related to every record where a relationship exists.
Table 74 lists the fields defined in me_datarelation.
Table 73. me_calendaruid Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
meuid text None
eventid text None
Table 74. me_datarelation Table Field Definition
Field Name Data Type Constant Values
parenttype integer None
childtype integer None
parentid text None
childid text None
devicerowidparent text None
devicerowidchild text None
referencetype integer None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
186
DRAFT - Modified May 27, 2014 4:45 pm
me_edited Table
The me_edited table stores edited information, pending successful update to Oracle CRM On
Demand. If the update permanently fails, then the data is restored from this table. Table 75 lists the
fields defined in me_edited.
me_geocode Table
The me_geocode table stores the latitude and longitude information for addresses. Table 76 lists the
fields defined in me_geocode.
Table 75. me_edited Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
uid text None
module_id integer None
xmltags text None
xmlvalues text None
dbvalues text None
status integer None
Table 76. me_geocode Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
addressid text None
latitude integer None
longitude text None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
187
DRAFT - Modified May 27, 2014 4:45 pm
me_login Table
The me_login table stores the login details of the current user. Table 77 lists the fields defined in
me_login.
me_lookup Table
The me_lookup table stores the cached lookup requests, data searched for, status and count of
records returned. Table 78 lists the fields defined in me_lookup.
Table 77. me_login Table Field Definition
Field Name Data Type Constant Values
user integer primary key None
isremember varchar(1) The constant values are:
No is zero (0).
Yes is 1. isvalid varchar(1)
owner text None
userid text None
modified_date text None
expiry_minutes integer None
Table 78. me_lookup Table Field Definition
Field Name Data Type Constant Values
uid text None
module_id integer None
request_value text None
status integer None
count integer None
downloadingids text None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
188
DRAFT - Modified May 27, 2014 4:45 pm
me_lookupresponse Table
The me_lookupresponse table stores the cached lookup response from the server, including all
information displayed in the lookup results page. Table 79 lists the fields defined in
me_lookupresponse.
me_requestqueue Table
The me_requestqueue table stores all the XML requests from the user device that are waiting to be
sent to the server. If the user device is switched to offline mode, then you can see the exact requests
queued to server. Table 80 lists the fields defined in me_requestqueue.
Table 79. me_lookupresponse Table Field Definition
Field Name Data Type Constant Values
uid text None
module_id integer None
display_value text None
xmltags text None
xmlvalues integer None
merecordid text None
Table 80. me_requestqueue Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
uid text None
operation_type varchar(50) None
module_id integer None
xml_data text None
details text None
createdtime text None
retryinterval integer None
send_status integer None
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
189
DRAFT - Modified May 27, 2014 4:45 pm
me_sortfields Table
The me_sortfields table stores all the fields and the order in which they are sorted in the application.
Table 81 lists the fields defined in me_sortfields.
me_temp Table
The me_temp table stores the temporary packets received from the server during and initial load or
update. When the packets have been downloaded to this table, they are processed in the order that
they were received. Table 82 lists the fields defined in me_temp.
Table 81. me_sortfields Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
module_id integer None
sortfield varchar(40) None
isascending varchar(1) The constant values are:
No is zero (0).
Yes is 1.
all_sortfields text None
Table 82. me_temp Table Field Definition
Field Name Data Type Constant Values
uid text None
content_total integer None
content_number integer None
xml text None
all_sortfields text None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Local Database Tables for Oracle CRM On Demand Disconnected Mobile Sales Client
Local Database Tables Field Definition
190
DRAFT - Modified May 27, 2014 4:45 pm
me_uniqueid Table
The me_uniqueid table stores the C+ incremental value used in combination with the device PIN to
calculate the devicerowid of record. Table 83 lists the fields defined in me_uniqueid.
metadata_x Table
The metadata_x table, where x is the module id, is created when the CAD is received. metadata_x
stores all the data on the user device in the corresponding module ids(x). For example Appointment
(Module ID 7) is stored in medata_7. Table 84 lists the fields defined in metadata_x.
Table 83. me_uniqueid Table Field Definition
Field Name Data Type Constant Values
uniqueid integer None
Table 84. medata_x Table Field Definition
Field Name Data Type Constant Values
auto_number integer primary key None
uid text None
istemporary text The constant values are:
No is zero (0)
Yes is 1.
devicerowid text None
All ME fields for the
module
text None
createddate integer None
modifieddate integer None
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
191
DRAFT - Modified May 27, 2014 4:45 pm
A Example: Using JavaScript
Object Notation to Cascade Copy
Records
This appendix shows an example of how to use JSON code to cascade copy records in Oracle CRM
On Demand Disconnected Mobile Sales. It includes the following topic:
Cascade Copy Records Example on page 191
Cascade Copy Records Example
In the example, a custom action button is created with JSON code to ensure that child records of a
parent are cascade copied to another set of child records that are related to the parent record. The
following assumptions are made in this example:
There is an Account Call
Product Detailed records of the Account Call are cascade copied to each of the Attendee Calls on
the Account Call.
The Product Detailed records are inserted into the Attendee Calls, which does not contain any
Product Detailed records.
The complete code example with header and footer information follows. There are inline comments
in the script.
<ht ml ><head><t i t l e>i Sal es</ t i t l e>
<scr i pt t ype=" t ext / j avascr i pt " >
var pr oduct Det ai l s = nul l ;
var at t endeeCal l s = nul l ;
var bI mpor t = f al se;
f unct i on onAct i onJ SON( )
{
r et ur n " [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " i sAccount Cal l \ " , \ " par amet er s\ " : [
{\ " modul ef i el ds\ " : [ { \ " modul e\ " : \ " 7\ " , \ " f i el ds\ " : \ " CLOGKW03\ " } ] ,
\ " f i l t er \ " : \ " 7. ui d=$7. ui d\ " } ]
}, {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " i sAt t endeeModul eExi st \ " , \ " par amet er s\ " : [ {\ " m
odul ef i el ds\ " : [ {\ " modul e\ " : \ " cad_menui t ems\ " , \ " f i el ds\ " : \ " modul e_i d\ " }] , \ " f i l t er \ "
: \ " modul e_i d=64\ " }] } ] " ;
}
/ ** i sAccount Cal l checks i f cur r ent cal l i s Account Cal l and t hr ows er r or i f i t s
not **/
f unct i on i sAccount Cal l ( r ow1) {
var r esul t =f al se;
i f ( r ow1[ 0] . _7. CLOGKW03 ! = " Account Cal l " ) {
wi ndow. l ocat i on=" mel t : / / showAl er t : Possi bl e onl y i n Account Cal l " +
r ow1[ 0] . _7. CLOGKW03;
}el se{
r esul t =t r ue;
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Example: Using JavaScript Object Notation to Cascade Copy Records Cascade Copy
Records Example
192
DRAFT - Modified May 27, 2014 4:45 pm
}
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " " +r esul t +" \ " }] " ;
}
f unct i on i sAt t endeeModul eExi st ( r ow1) {
/ ** checks i f At t endee Cal l ( 64) exi st s and f et ches t he Pr oduct Det ai l ed ( 25) chi l d
r ecor ds. **/
i f ( r ow1. l engt h>0) {
r et ur n
" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " get At t endeeCal l Pr oduct Det ai l ed\ " , \ " par amet er
s\ " : [ {\ " modul ef i el ds\ " : [ {\ " modul e\ " : \ " 25\ " , \ " f i el ds\ " : \ " CU
STREFPRODUCT, CUSTTXT01, CUSTKW11, CUSTKW12, CUSTOWNER\ " }] , \ " f i l t er \ " : \ " 25. CUSTREF2=$7
. ui d\ " }, {\ " modul ef i el ds\ " : [ {\ " modul e\ " : \ " 64\ " , \ " f i el ds\ " : \ " ui d\ " }] , \ " f i l t er \ " : \ " 64
. CUSTREF1=$7. ui d\ " }] }] " ;
}
r et ur n " [ {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " f al se\ " }] " ;
}
f unct i on get At t endeeCal l Pr oduct Det ai l ed ( r ow1, r ow2) {
/ ** r ow1 cont ai ns Pr oduct Det ai l ed r ecor ds whi ch ar e chi l dr en of Account Cal l **/
/ ** r ow2 cont ai ns ui d val ues of At t endee Cal l s whi ch ar e chi l dr en of Account Cal l **/
account Cal l Pr oduct Det ai l s = r ow1;
at t endeeCal l s = r ow2;
var
j sonscr i pt =" [ {\ " act i on\ " : \ " sel ect \ " , \ " i nvoke\ " : \ " copyPr oduct Det ai l s\ " , \ " par amet er s
\ " : [ " ;
f or ( i =0; i <r ow2. l engt h; i ++) {
j sonscr i pt +=" {\ " modul ef i el ds\ " : [ {\ " modul e\ " : \ " 25\ " , \ " f i el ds\ " : \ " count ( *) \ " }] , \ " f i l
t er \ " : \ " 25. CUSTREF1=' " + r ow2[ i ] . _64. ui d + " ' \ " }" ;
j sonscr i pt += ( ( i == r ow2. l engt h - 1) ? " " : " , " ) ;
}
j sonscr i pt +=" ] }] " ;
r et ur n j sonscr i pt ;
}
f unct i on copyPr oduct Det ai l s( ) {
/ ** ar gument s var i abl e cont ai ns t he count of Pr oduct Det ai l ed chi l dr en of each
At t endee Cal l r ecor d **/
var j sonscr i pt =" [ " ;
r ow1 = account Cal l Pr oduct Det ai l s;
r ow2 = at t endeeCal l s;
f or ( i =0; i <r ow2. l engt h; i ++) {
/ ** Onl y i f t he At t endee Cal l r ecor d doesn' t have any Pr oduct Det ai l ed as chi l dr en,
t he i nser t oper at i on i s per f or med **/
i f ( ar gument s[ i ] [ 0] . _25. count == " 0" ) {
f or ( j =0; j <r ow1. l engt h; j ++) {
/ ** Each Pr oduct Det ai l ed r ecor d i s i nser t ed t o as chi l d of each At t endee Cal l i f
i t doesnot have any chi l dr en. 25. CUSTREF1 i s gi ven t he val ue 64. ui d **/
Example: Using JavaScript Object Notation to Cascade Copy Records Cascade Copy
Records Example
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
193
DRAFT - Modified May 27, 2014 4:45 pm
j sonscr i pt
+=" {\ " act i on\ " : \ " i nser t \ " , \ " modul e\ " : \ " 25\ " , \ " f i el ds\ " : [ {\ " f i el d\ " : \ " CUSTREFPRODUC
T\ " , \ " val ue\ " : \ " " +( r ow1[ j ] . _25. CUSTREFPRODUCT | |
" " ) +" \ " }, {\ " f i el d\ " : \ " CUSTTXT01\ " , \ " val ue\ " : \ " " +( r ow1[ j ] . _25. CUSTTXT01 | | " " )
+" \ " }, {\ " f i el d\ " : \ " CUSTKW11\ " , \ " val ue\ " : \ " " +( r ow1[ j ] . _25. CUSTKW11 | | " " )
+" \ " }, {\ " f i el d\ " : \ " CUSTKW12\ " , \ " val ue\ " : \ " " +( r ow1[ j ] . _25. CUSTKW12 | |
" " ) +" \ " }, {\ " f i el d\ " : \ " CUSTOWNER\ " , \ " val ue\ " : \ " " +( r ow1[ j ] . _25. CUSTOWNER | |
" " ) +" \ " }, {\ " f i el d\ " : \ " CUSTREF1\ " , \ " val ue\ " : \ " " +( r ow2[ i ] . _64. ui d | |
" " ) +" \ " }] , \ " upsync\ " : \ " yes\ " }, " ;
i f ( ! bI mpor t ) {
bI mpor t = t r ue;
}
}
}
}
j sonscr i pt +=" {\ " act i on\ " : \ " val i dat e\ " , \ " r esul t \ " : \ " t r ue\ " }] " ;
wi ndow. l ocat i on =" mel t : / / showAl er t : " +( ( bI mpor t ) ? " I mpor t Fi ni shed" : " No r ecor ds
i mpor t ed" ) ;
r et ur n j sonscr i pt ;
}
</ scr i pt ></ head></ ht ml >
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Example: Using JavaScript Object Notation to Cascade Copy Records Cascade Copy
Records Example
194
DRAFT - Modified May 27, 2014 4:45 pm
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
195
DRAFT - Modified May 27, 2014 4:45 pm
Index
A
about this guide 13
actions
about 97
functions returning actions 98
JSON actions 98
JSON getcondition action 108
JSON goToURL action 107
JSON insert action 106
JSON select action 102
JSON showprompt action 109
JSON update action 105
JSON validate action 107
primary and secondary actions 101
validating data 101
adding JavaScript code 27
module ID and field name, obtaining 22
using cut and paste 21
appointment and attendee call logic 129
available events
for modules 28
for quick action buttons 34
for quick selectors 31
for tables 32
B
button functions 83
C
call and record locking
about 136
DMS.fieldsOnDelete function 136
DMSCall.onDelete function 137
call logic for appointment and attendee call
about 129
DMSCall.onAcceptAndSign(options) 130
DMSCall.onSaveJSONCall(options) 129
DMSCall.onSubmitCall(options) 131
callback functions
about 133
example 135
onAcceptAndSign and acceptSignData 133
onSubmitCall and validateSubmitData 134
calling external applications 85
cascade copy records, example 191
controlled substances, validation API 140
custom action buttons, implementing 83
D
database tables
cad_apprules table 173
cad_context table 173
cad_externalappscheme table 174
cad_fieldconditions table 175
cad_fieldgroup table 174
cad_formfields table 175
cad_implicit_ids table 176
cad_keyword table 176
cad_lookup table 176
cad_menuitems table 177
cad_modulefield table 178
cad_moduleicons table 178
cad_modulerules table 179
cad_options table 179
cad_qsfields table 180
cad_qsfilters table 180
cad_qsmodules table 181
cad_quickactions table 181
cad_stfields table 182
cad_stfilters table 182
cad_systemkeys table 183
local, field definition 172
local, for Oracle CRM On Demand
Disconnected Mobile Sales 170
me_addressbookuid table 183
me_alertdata table 184
me_attachments table 184
me_calendaruid table 185
me_datarelation table 185
me_edited table 186
me_geocode table 186
me_login table 187
me_lookup table 187
me_lookupresponse table 188
me_requestqueue table 188
me_sortfields table 189
me_temp table 189
me_uniqueid table 190
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Index E
196
DRAFT - Modified May 27, 2014 4:45 pm
metadata_x table 190
overview 169
viewing records stored in local 170
detailer button, configuring 33
device messages 25
device messages, creating 25
device record ID 26
DMS.js library file
call and record locking API 136
call logic for appointment and attendee
call 129
callback functions 133
defining JSON actions for 120
DMS.action function 121
DMS.checkIfModuleExist function 117
DMS.conditionQuery function 128
DMS.fieldsOnCancel function 124
DMS.fieldsOnConditionQuery function 125
DMS.fieldsOnDefault function 124
DMS.fieldsOnFilter function 128
DMS.fieldsOnPreSave function 125
DMS.get function 117
DMS.onValidateJSON function 129
DMS.quickActionDetailer function 126
DMS.showAlert function 117
field condition conditionQuery function 127
insert action 122
list of modules and fields 118
quick selector and quick selector validate
API 137
select action 121
update action 122
using 115
using JavaScript code in 123
validate action 123
validation API for controlled substances 140
DMSUtil.systemKeyInfo 144
doneSignature 73
E
enabling JavaScript functionality 27
Epoch time 24
event handlers
eventJSON 41
fieldsOnEvent and onEvent 39
standard handlers 42
eventJSON event handler 41
excludeFromPreload function 79
external applications
calling from Oracle CRM On Demand
Disconnected Mobile Sales 85
passing data to 84
F
field condition scripts, in quick selector
lists 81
field name information, obtaining 23
fieldsOnEvent and onEvent event
handler 39
fieldsOnSave and OnSave, example 71
fieldsOnSave and onSave, functions 71
filters
configuring for quick selectors 76
configuring for reference fields 75
functions
onCancel 48
onCreate 50
onDelete 43
onEdit 57
onOpen 58
onSave and onPreSave 61
functions returning actions 98
H
HTML footer 42
HTML header 38
I
invoked function, example 110
J
JavaScript
actions, about 97
adding 21
body 38
button functions 83
calling external application 85
enabling 27
event handlers 39
excludeFromPreload function 79
HTML footer 42
HTML header 38
implementing buttons 83
inclusions 38
overview of support for 13
passing data to an external application 84
reference functions 76
showViewAll parameter 81
structure of code 37
supported events 16
to filter information 75
using to cascade copy records 191
View All button 81
when to use 14
where to use in the Admin application 15
Index M
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
197
DRAFT - Modified May 27, 2014 4:45 pm
JavaScript body 38
JavaScript code
actions, about 97
adding 27
adding to fields 29
adding to modules 28
adding to quick action buttons 32
adding to quick selectors 30
adding to tables 31
before adding 21, 36
button functions 83
calling external applications 85
creating device messages 25
custom device messages 25
excludeFromPreLoad function 79
implementing buttons 83
module ID and field name, obtaining 22
onCancel function 48
onCreate function 50
onDelete function 43
onEdit function 57
onOpen function 58
onSave and onPreSave function 61
passing data to an external application 84
showViewAll parameter 81
to filter information 75
using cut and paste 21
using keywords in queries 24
using to cascade copy records 191
using to filter information 75
View All button 81
JavaScript inclusions 38
JavaScript library
configuring 34
uploading to the server 35
JavaScript library, using 115
JSON actions 98
JSON filter parameter 103
JSON modulefields parameter 103
M
module ID
obtaining 22
obtaining using Utility Menu 23
module ID and field name
obtaining 22
obtaining in bulk 23
O
onCancel
defining a query for 49
example 49
functions 48
onCreate
conditional insert example 53
defining a query for 51
functions 50
onCreateJSON function 55
read and insert example 52
onDelete
checking a single condition example 44
checking multiple conditions example 46
defining a query for 44
functions 43
onDeleteJSON 47
onEdit
function 57
onEditJSON function 57
onOpen
defining a query for 58
read and insert example 58
onPostCreateJSON 56
onPreCreateJSON 55
onPreSave
checking a parent example 67
checking a single condition example 62
checking multiple conditions example 65
defining a query for 62
functions 61
onSave
conditional query example 70
functions 68
nonconditional data example 69
onSaveFixedJSON 72
Oracle CRM On Demand Disconnected Mobile
Sales
adding JavaScript to 21
after adding JavaScript code to 36
before adding JavaScript code to 21
Oracle Social Network 88
P
passing data to an external application 84
primary and secondary actions 101
Q
quick action buttons
configuring 32
detailer button, configuring 33
for external applications, configuring 33
quick action buttons, implementing 83
quick selector and quick selector validate
API
about 137
for blocked products 139
for HCP contact allocation 139
Oracle CRM On Demand Disconnected Mobile Sales Developers Reference
Release 1.9
Index R
198
DRAFT - Modified May 27, 2014 4:45 pm
for samples, promotional items, and product
detailed 138
quick selectors
configuring filters for 76
excludeFromPreload function 79
support for field condition scripts 81
R
record ID 26
reference fields, configuring filters for 75
reference functions
conditional filter example 77
for JavaScript 76
simple filter example 77
S
shared JavaScript library, configuring 34
showViewAll parameter 81
success and error codes, JSON event
handlers 41
System Keys 163
system keys 144
U
Unix time 24
V
validating data, actions 101
View All button 81

You might also like