Group type

Group type documentation.

Overview

This field type enables the referencing of a group within the application.

Available features

NameSupported
Many multiplicityyes
Default valuesyes
Unique flagyes
Required flagyes
Indexable flagyes
Sensitive flagyes
Calculated valueyes
Automatic initializationno
Calculated initial valueno
Aggregationno
Default type rulesyes
Default display optionsno

Type rules

Filtering

This feature allows you to specify which groups can be assigned in this field. The available options include:

  • None: All groups will be listed.
  • By Groups: You can specify which groups will be available for selection in this field.

REST API

Read format

The read format is represented in JSON and comprises the following fields:

  • id: This corresponds to the ID of the referenced group.
  • label: This represents the label associated with the referenced group.

Sample group field in JSON format:

"group": {
  "id": "57fe5269e4b0f6600fdfbdba",
  "label": "Read-only user"
}

Write format

You have several options for the write format:

  • You can provide only the ID and omit the label field.

    "group": {"id": "57fe5269e4b0f6600fdfbdba"}
    

  • Alternatively, you can directly pass the ID as a string.

    "group": "57fe5269e4b0f6600fdfbdba"
    

  • Lastly, you can supply the label of the group.

    "group": "Read-only user"
    

JavaScript API

Read format

The val() method within the wrapper will return an object:

{
  "id": "57fe5269e4b0f6600fdfbdba",
  "label": "Read-only user"
}

Where:

  • id: This refers to the ID of the referenced group.
  • label: This corresponds to the label of the referenced group.

However, in most cases, rather than obtaining the raw value of the relationship, you will likely utilize the methods provided within the wrapper to directly access the ID or the label.

Write format

There are multiple ways to provide the value of a group in the JavaScript API.

  • You can provide only the ID.

    record.field("group").val({id: "57fe5269e4b0f6600fdfbdba"});
    

  • Alternatively, you can directly pass the ID as a string.

    record.field("group").val("57fe5269e4b0f6600fdfbdba");
    

  • Another option is to pass the label of the group.

    record.field("group").val("Read-only user");
    

The JavaScript API also offers the ability to set a group wrapper as shown below:

task1.field('group').val(task2.field('group'));

Wrapper method:
id()

Returns the ID of the referenced group or null if the field is empty.

Returns

string - The ID of the referenced group.

Samples
// prints the ID of the referenced group in the field
var record = sys.data.findOne('tasks', {number: 1});
log('group id: '+record.field('group').id());


Wrapper method:
label()

Returns the label of the referenced group or null if the field is empty.

Returns

string - The label of the referenced group.

Samples
// prints the label of the referenced group in the field
var record = sys.data.findOne('tasks', {number: 1});
log('group label: '+record.field('group').label());


Wrapper method:
name()

Returns the name of the referenced group or null if the field is empty.

Returns

string - The name of the referenced group.

Samples
// prints the name of the referenced group in the field
var record = sys.data.findOne('tasks', {number: 1});
log('group name: '+record.field('group').name());


Export/Import

Export format

The export format is the label of the group:

"groupField1","groupField2"
"Group A","Group B"

Import format

The import format can be either the name or the label of the group:

"groupField1","groupField2"
"Group A","groupB"

If there is ambiguity, the name takes precedence over the label.

Queries

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

Available operators

OperatorSupportedNotes
equalsyesMatching will be done based on the group’s ID, followed by the name, and then the label, in that order of precedence.
notEqualsyesMatching will be performed using the group’s ID, name, or label, in that order of precedence.
emptyyes-
notEmptyyes-
likeyesMatching will be carried out using the group’s label.
greaterno-
greaterOrEqualsno-
lessno-
lessOrEqualsno-
betweenno-
currentUserFieldno-

Query formats

By default, the label will be utilized for various query operators.

For instance, the following query will retrieve tasks where the assignee’s label is set to 'Read-only user':

// finds a task by group's label 
var records_sample = sys.data.find('tasks', {group: 'Read-only user'});
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// finds a task by group's label 
var query_sample = sys.data.createQuery('tasks')
    .field('group').equals('Read-only user')
var records_sample = sys.data.find(query_sample);
log('total: '+records_sample.count());
while (records_sample.hasNext()) {
    log(records_sample.next().label());
}
// finds a task by group's label 
GET /data/contacts?tasks?group=Read-only user

You can also provide the ID:

// finds a task by group's ID 
var records_sample2 = sys.data.find('tasks', {'group.id': '57fe5269e4b0f6600fdfbdba'});
log('total: '+records_sample2.count());
while (records_sample2.hasNext()) {
    log(records_sample2.next().label());
}
// finds a task by group's ID 
var query_sample2 = sys.data.createQuery('tasks')
    .field('group').equals('57fe5269e4b0f6600fdfbdba')
var records_sample2 = sys.data.find(query_sample2);
log('total: '+records_sample2.count());
while (records_sample2.hasNext()) {
    log(records_sample2.next().label());
}
// finds a task by group's ID 
GET /data/contacts?group.id=57fe5269e4b0f6600fdfbdba

Please note once more that the query builder will automatically recognize the ID, and you don’t need to append the “id” suffix.

Remember that when employing the query builder, you have the flexibility to utilize any of the formats accessible in the JavaScript API.

Aggregate queries

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

Available operators

OperatorSupported
sumno
avgno
firstyes
lastyes
minno
maxno

UI queries

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

Matching of values

PropertyDescription
Matching operatorlike
The label of the referenced group will be used for matching.

Available operators

OperatorSupported
Many valuesyes
Greaterno
Greater or equalsno
Lessno
Less or equalsno
Betweenno