Sys.Data.DataService.insert Method

Inserts new data through the data service.

Syntax

insert: function(item, resourceSetUri, succeededCallback, failedCallback, userContext, provideReturnData)

Usage

var a = exampleDataService.insert(item, resourceSetUri, succeededCallback, failedCallback, userContext, provideReturnData);

Parameter

Definition

item

An object containing the new data to insert.

resourceSetUri

The URI of the resource set into which the new data is inserted.

succeededCallback

(Optional) The function to execute when the insert operation succeeds.

failedCallback

(Optional) The function to execute when the insert operation fails.

userContext

(Optional) The state object for this operation.

provideReturnData

(Optional) true if the data service should return the inserted data to the callback function; otherwise, false.

Return Value

The Sys.Net.WebRequest object that performed the insert operation.

Remarks

Use the insert method to add new data through a data service. The insert method immediately executes a single insert operation. If you must execute more than one operation as a single batch, use the createActionSequence method.

You pass the data to insert as a JavaScript object in the item parameter. The Boolean provideReturnData parameter enables you to specify whether the inserted data is returned from the method. The inserted data might be different than what you passed to the method if a trigger or some other code has modified the data.

The signatures for the callback functions should be similar to the following code:

function callbackSucceeded(result, context, operation)
function callbackFailed(error, context, operation)

The functions you assign to the callback functions must accept three parameters. The first parameter contains the result (or error) returned by the data service. The second parameter contains the state object for the data operation. The third parameter contains a description of the operation that was performed. For insert operations, the third parameter contains insert.

Caution

The insert method does not evaluate the provideReturnData parameter in the December CTP release. The method uses a default value of true. The data service will always return the data to the callback function.

This topic is ASP.NET Extensions documentation and is unsupported by Microsoft. Blank topics are included as placeholders and existing content is subject to change in future releases.