The "linkLabelsToRecords" action links one or more labels to one or more records in a table. It adds to the links already assigned to the record, if any. It does not return an error if the specified labels are already assigned to the specified records.
The operation is atomic. If it returns an error, the action does not apply the requested changes. If some or all of the specified labels are already linked to the specified records, the action returns success with a warning: The "Label LLL is already linked to database DDD, owner OOO, and table TTT with primary key PPP".
Request examples
Minimal
This example links the label "myLabel1" to records 1 and 2 in the table "my_table" owned by the default account and database .
{
"action": "linkLabelsToRecords",
"params":
{
"labels": [ { "name": "myLabel1" } ],
"tableName": "my_table",
"ids": [1,2]
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Maximal
This example links the labels "myLabel1" and "myLabel2" in group "myGroup" to records 1 and 2 in the table "my_table" owned by the "db" user in the "faircom" database .
{
"api": "db",
"action": "linkLabelsToRecords",
"params":
{
"labels":
[
{
"group": "myGroup",
"name": "myLabel1"
},
{
"group": "myGroup",
"name": "myLabel2"
}
],
"databaseName": "faircom",
"ownerName": "db",
"tableName": "my_table",
"ids": [1,2],
"verifyLinks": true
},
"authToken": "replaceWithAuthTokenFromCreateSession"
}
Request properties ("params")
| Property | Description | Default | Type | Limits (inclusive) |
|---|---|---|---|---|
labels |
The The
When using tag actions, the optional |
Required - No default value
Defaults to
|
array of objects |
1 or more label objects
Values are managed in the Label API with the group of |
|
labels .group |
The The The group name may contain up to 64 bytes of UTF-8 encoded characters. When you assign a group name to a label, the server automatically checks if the group name exists in the list of groups that the
|
Optional with default of ""
|
string | 1 to 64 bytes |
|
labels .name |
The The The
|
Required - No default value | string | 1 to 64 bytes |
databaseName |
The You specify this property when you want to use a different database instead of the default. This property is useful because objects, such as tables and code packages, can have the same name in multiple databases. This feature allows you to create multiple environments in the same server and reuse the same JSON actions in each environment. For example, you can create It is an error to set If no default database is specified during |
Defaults to the session's "defaultDatabaseName" property |
string | 1 to 64 bytes |
ownerName |
The You specify this property when you want to use a different account instead of the default. Your session's account must have the appropriate privileges to access the code package. This property is useful because objects, such as tables and code packages, can have the same name in the same database as long as different accounts own each object. This feature allows you to create duplicate objects for different users on the same server and reuse the same JSON actions on those objects. For example, an administrator can copy objects from a production environment to her account so she can troubleshoot an issue using the same JSON actions, JavaScript, and SQL code. It is an error to set If no default owner is specified during |
Optional with default of the session's "defaultOwnerName" property |
string | 1 to 64 bytes |
tableName |
The See table name in System specifications for the table naming requirements and limitations.
"params": {
"tableName": "ctreeTable"
} |
Required - No default value | string | 1 to 64 bytes |
ids |
An
|
Automatically generated by the server | array of integers | Each array item is an integer from 0 to 2147483647
|
verifyLinks |
The |
Optional with default of true
|
Boolean |
|