JSDO properties, methods, and events reference : assign( ) method (JSDO class)
  

assign( ) method (JSDO class)

Updates field values for the specified JSRecord object in JSDO memory.
The specified record object can be either the working record of a JSDO table reference or any record provided by a JSRecord object.
To synchronize the change on the server, call the saveChanges( ) method.
Alias: update( )
Return type: boolean
Applies to: progress.data.JSRecord class, progress.data.JSDO class, table reference property (JSDO class)

Syntax

jsrecord-ref.assign ( update-object )
jsdo-ref.assign ( update-object )
jsdo-ref.table-ref.assign ( update-object )
jsrecord-ref
A reference to a JSRecord object for a table record in JSDO memory.
You can obtain a JSRecord object by:
*Invoking a JSDO method that returns record objects from a JSDO table reference (find( ), findById( ), or foreach( ))
*Accessing the record property on a JSDO table reference that already has a working record.
*Accessing the record parameter passed to the callback of a JSDO afterCreate, afterDelete, or afterDelete event.
*Accessing each record object provided by the jsrecords property on the request object parameter passed to the callback of a JSDO afterSaveChanges event, or passed to the callback of any Promise object returned from the saveChanges( ) method. The jsrecords property is only available on completion of a Submit operation (saveChanges(true)) on a resource that supports before-imaging, and not if the resource supports before-imaging without Submit.
jsdo-ref
A reference to the JSDO. You can call the method on jsdo-ref if the JSDO has only a single table reference, and that table reference has a working record.
table-ref
A table reference on the JSDO that has a working record.
update-object
Passes in the data to update the specified record object in JSDO memory. Each property of the object has the name of a table field and the value to set for that field in the specified record. Any table fields without corresponding properties in update-object remain unchanged in the record.
Note: After this method updates the specified record object, and if you have set up automatic sorting using the autoSort property, all the record objects for the affected table reference are sorted accordingly. If the sorting is done using sort fields, any string fields are compared according to the value of the caseSensitive property.

Example

The following code fragment shows a jQuery event defined on a save button to save the current field values for a customer detail form to the corresponding eCustomer record in JSDO memory:
dataSet = new progress.data.JSDO( 'dsCustomerOrder' );

$('#btnSave').bind('click', function(event) {
  var jsrecord = dataSet.eCustomer.findById($('#custdetail #id').val());
  if (jsrecord) {jsrecord.assign(update-object);};
  dataSet.saveChanges();
});
The form has been displayed with previous values of the same record. When the button is clicked, the event handler uses the findById( ) method to find the original record with the matching internal record ID (jsrecord) and invokes the assign( ) method on jsrecord with an object parameter to update the fields in eCustomer with any new values entered into the form.

See also:

autoSort property, caseSensitive property, getSchema( ) method, saveChanges( ) method