$.udb(ds).rowCreate()

  • 1 August 2022
  • 0 replies
  • 115 views

This article is about the rowCreate() function of the DataSourceContainer object.

$.udb(ds).rowCreate()

Creates a new record in the data source.

Returns a Promise object or the 'this' object. From USoft 10.0.1I, returns a udbPromise instead of a Promise object.

Syntax

$.udb( ds ).rowCreate( options )

options ::= {
hostvars: hostvars,
initialValues: initial-values,
rows: rows,
before: before,
copyValues: copy-values,
promise: promise,
success: success-function,
error: error-function
}

before ::= { true | false }
copy-values ::= { true | false }
promise ::= { true | false }

The optional ds is a data source selector.

Options is a struct that can have the following items, all of which are optional.

Hostvars is a set of (temporary) name-value pairs that are passed as column values to the record being created. By default, hostvars is the empty set.

Initial-values is a set of (temporary) name-value pairs that override the default initial values of the newly created record. By default, initial-values is the empty set.

Rows is an array of predefined rows to be created.

Before is a boolean that specifies whether the new record must be created before or after the currently selected record. By default, it is created before.

Copy-values is a boolean that specifies whether all field values must be duplicated from the record currently selected, or not. By default, this duplication does not happen.

Promise determines the return value of this function. If promise has the value of 'true' (the default), a Promise object is returned. If promise has the value of 'false', the ‘this’ object is returned instead.

Success-function is a function called after a record has been successfully created.

If you pass success-function, you can use the return value of this function to control whether the record is actually created.

Error-function is a function called if an error occurs.

Example 1

$.udb('EMP').rowCreate({
success: function(r){
r.val('NAME','John');
}
});

A shorter version of this example is:

$.udb('EMP').rowCreate({
initialValues: { NAME: 'John' }
});

Example 2

This example creates an array of predefined rows:

$.udb('EMP').rowCreate({
rows: [
{
FIRST_NAME: 'John',
NAME: 'Smith'
},
{
FIRST_NAME: 'Jane',
NAME: 'Doe'
}
],
initialValues: { DEPT: 'Engineering' }
});

Related events

Event Applies to Occurs when
rowprecreate Data source objects Before a record is created.
rowpostcreate Data source objects After a record is created.

 


0 replies

Be the first to reply!

Reply