Oracle CRM On Demand JavaScript API Developer's Guide > JavaScript API Reference >

Methods for CRUD Operations


This topic describes the methods available for create, read, update and delete (CRUD) operations on off-screen records. Table 11 lists the methods, which are under oraclecrmod.dataSvc. The parameters for the methods are discussed in Parameters and Return Values for CRUD Methods. For a code sample that performs a create operation, see Code Sample for a Custom Button That Creates a Record.

For the CRUD operations, only top-level record types are supported and not child-level record types. To access child-level record types, you can use the Oracle CRM On Demand REST API. For more information, see Oracle CRM On Demand REST API Developer's Guide.

To handle the results of a CRUD operation you must define a callback function as described in User-Defined Callback Function.

TIP:   All of the methods run asynchronously, so you must implement the callback function and subsequent function calls to allow for this.

The methods are asynchronous because CRUD operations need to communicate with the server to complete and this involves remote communication across the network using AJAX technology. Because of this, these operations normally take a significantly longer time to complete compared to other operations that happen inside the browser.

In the browser, all the JavaScript code runs in a single thread. If synchronous calls were used for the CRUD operations, the browser would not be able to handle any user interaction when the CRUD operations were in process. Asynchronous calls are therefore used for CRUD operations. During the CRUD operations the user can still interact with the page, and when the operation is finished, the framework calls the callback function to handle the result. This results in a much better user experience.

Table 11. Create, Read, Update, and Delete Methods
Method Name
Return Type
Description
Sample Code

createRecord (objectName, fieldNameValuePairs, createParameters, callback)

JSONObject

Creates an off-screen record. The parameters specify the record type, and field name-value pairs for the record. The method returns the row ID and mod ID of the record.

oraclecrmod.dataSvc.createRecord ("Account", {"Name" : "Account 1", "Account Contact Role" : "Admin", "Type" : "Customer", "Description" : "Description Test"}, null, callback);

readRecord (objectName, fieldNames, readParameters, callback)

JSONObject

Retrieves fields not exposed for the current record or from an off-screen record. The parameters specify the record type, list of field names, and search type and search specification. The method returns a list of the field names and their values.

NOTE:  Only row ID values are supported for the searchType parameter.

oraclecrmod.dataSvc.readRecord ("Account", "Name, Description", { searchType: "rowId", "rowId": "1QA2-TNRWW"}, callback);

updateRecord (objectName, fieldNameValuePairs, updateParameters, callback)

JSONObject

Updates an off-screen record. The required parameters specify the record type, field name-value pairs, and search type and search specification. The method returns the row ID and mod ID of the updated record.

NOTE:  Only row ID values are supported for the searchType parameter.

oraclecrmod.dataSvc.updateRecord ("Account", {"Name" : "Account 1", "Account Contact Role" : "Admin", "Type" : "Customer", "Description" : "Description Test"}, {searchType: "rowId", "rowId": "1QA2-TNRWW"}, callback);

deleteRecord (objectName, deleteParameters, callback)

JSONObject

Deletes an off-screen record. The required parameters specify the record type, and search type and search specification. The method deletes the specified record and returns the deletion results.

NOTE:  Only row ID values are supported for the searchType parameter.

oraclecrmod.dataSvc.deleteRecord ("Account", "1QA2-TNRWW", callback);

For create and update operations on required and read-only fields in off-screen records, only default preconfigured fields and not custom fields are supported.

If a preconfigured required field is missing, then the create or update operation fails. If an operation attempts to populate a read-only field, then it is ignored.

Oracle CRM On Demand JavaScript API Developer's Guide, Release 38 Copyright © 2019, Oracle and/or its affiliates. All rights reserved. Legal Notices.