Auto-increment type

Auto-increment type documentation.

Overview

This type generates auto-incremental unique numbers as new records are created within the entity.

Fields of this type cannot be edited and are consistently managed by the app. As of now, there is no method to reset the counter or set it to a starting position other than zero.

When a field of this type is added to an entity with existing records, it will be initialized by assigning values based on the creation order of the records.

Available features

NameSupported
Many multiplicityno
Default valuesno
Unique flagno
Required flagno
Indexable flagyes
Sensitive flagyes
Calculated valueno
Automatic initializationyes
Calculated initial valueyes
Aggregationno
Default type rulesyes
Default display optionsno

Type rules

Minimum value

This defines the minimum value to be assigned to the next record. For instance, if you set it to 10,000, the subsequent value will be 10,000. This setting proves useful when you want numbers to initiate from a specific value.

It’s important to note that this setting doesn’t affect pre-existing records. Moreover, if you modify the value to a number lower than the current auto-increment value, it will not have any impact. For example, if the last created record was assigned the number 3,000 and you alter the minimum value to 1,000, this change will not influence the next value, which will still be 3,001.

REST API

Read format

The format is a number:

"number": 8

Write format

There is no method for writing to an auto-increment field.

JavaScript API

Read format

The val() method within the wrapper will return a number.

// this will print something like "number: 23"
log('number: '+record.field('number').val());

Write format

There is no method for writing to an auto-increment field.

Wrapper method:
toHex()

The toHex() method returns string of hexadecimal representation of the value or empty ('') if null.

Returns

string - Hex value of number.

Samples
// prints the hex value of a integer field
var record = sys.data.findOne('projects', {name: 'Point-to-point link'});
sys.logs.debug('project number of people hex:'+record.field('numberOfPeople').toHex());


Wrapper method:
format(options)

Returns a string representing the formatted number value or an unformatted string.

Parameters
NameTypeRequiredDescription
optionsobjectnoThese parameters are used to format the value. If left empty, the default display options will be used for formatting.
- thousandsSeparator: Indicates whether to show a thousands separator. Options are “true” or “false.”
Returns

string - String of formatted value of number.

Samples
// prints the formated value of a integer field
var record = sys.data.findOne('projects', {name: 'Point-to-point link'});
sys.logs.debug('project number of people:'+record.field('numberOfPeople').format({thousandsSeparator: true}));



Export/Import

Export format

The export format is a simple number.

"id","tittle"
"1","task A"
"2","task B"

Import format

Auto-increment fields cannot be imported because they are generated.

Queries

For more information, please refer to the Query Language Documentation.

Available operators

OperatorSupported
equalsyes
notEqualsyes
emptyyes
notEmptyyes
likeno
greateryes
greaterOrEqualsyes
lessyes
lessOrEqualsyes
betweenyes
currentUserFieldno

Query formats

You should provide the number. For instance:

// finds tickets with field number higjer than 10 
var records_sample = sys.data.find('tickets', {'number': 'greater(10)'});
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// finds tickets with field number higjer than 10 
var query_sample = sys.data.createQuery('tickets')
    .field('tickets').greater(10)
var records_sample = sys.data.find(query_sample);
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// finds tickets with field number higjer than 10 
GET /data/contacts?tickets=greater(10)

Aggregate queries

Please refer to the Aggregate Queries Documentation for more detailed information.

Available operators

OperatorSupported
sumyes
avgyes
firstyes
lastyes
minyes
maxyes

UI queries

Please refer to the UI Queries Documentation for more detailed information.

Matching of values

PropertyDescription
Matching operatorequals

Available operators

OperatorSupported
Many valuesyes
Greaterno
Greater or equalsno
Lessyes
Less or equalsyes
Betweenyes