Endpoint Get Record Labels (Tags)
Name
get_record_labels
Description
Returns UI labels (tags) applied to a specific record using the ServiceNow label framework.
Parameters
| Parameter | Required | Options | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Name:
Label: Parent Table Name Name of the parent table (for example: incident, problem, change_request). |
YES | |||||||||||||||||||||||||||||||
|
Name:
Label: Table (***DO NOT CHANGE***) |
||||||||||||||||||||||||||||||||
|
Name:
Label: ShowDisplayValue |
||||||||||||||||||||||||||||||||
|
Name:
Label: Parent Record Sys_ID Sys_ID of the parent record for which labels (tags) should be retrieved. |
||||||||||||||||||||||||||||||||
|
Name:
Label: Additional Filter (Optional) Optional encoded query to further filter label entries (for example by date or creator). |
|
Output Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| sys_id |
DT_WSTR
|
nvarchar(32)
|
32 | |
| [$parent.Pivot_Name$] |
DT_WSTR
|
nvarchar(2000)
|
2000 | |
| [$parent.Pivot_Name$]_diaplay_value |
DT_WSTR
|
nvarchar(2000)
|
2000 |
If the column you are looking for is missing, consider customizing ServiceNow Connector.
Input Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| There are no Static columns defined for this endpoint. This endpoint detects columns dynamically at runtime. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Examples
SSIS
Use ServiceNow Connector in API Source or in API Destination SSIS Data Flow components to read or write data.
API Source
API Source - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Record Labels (Tags)
| Required Parameters | |
|---|---|
| Parent Table Name | Fill-in the parameter... |
| Optional Parameters | |
| Table (***DO NOT CHANGE***) | label_entry |
| ShowDisplayValue | true |
| Parent Record Sys_ID | |
| Additional Filter (Optional) | |
API Destination
API Destination - ServiceNow
Read and write ServiceNow data effortlessly. Integrate, manage, and automate incidents, tasks, attachments, and records — almost no coding required.
ServiceNow
Get Record Labels (Tags)
| Required Parameters | |
|---|---|
| Parent Table Name | Fill-in the parameter... |
| Optional Parameters | |
| Table (***DO NOT CHANGE***) | label_entry |
| ShowDisplayValue | true |
| Parent Record Sys_ID | |
| Additional Filter (Optional) | |
ODBC application
Use these SQL queries in your ODBC application data source:
Query Record Labels (Tags) Using Parent Table and Record
-- 1. Get ALL labels (tags) for a specific Problem record
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8'
)
-- 2. Check whether the record has a specific label
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='label.name=trial'
)
-- 3. Get labels where the name starts with a prefix (e.g. odbc*)
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='label.nameSTARTSWITHodbc'
)
-- 4. Get labels where the name contains a keyword
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='label.nameLIKEpower'
)
-- 5. Get labels added by a specific user
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='sys_created_by=admin'
)
-- 6. Get labels added in the last 7 days
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='sys_created_on>=<<today-7d,FUN_TO_DATETIME>>'
)
-- 7. Combine multiple filters and order by most recent label
SELECT *
FROM get_record_labels
WITH(
ParentTableName='problem',
ParentSysId='62304320731823002728660c4cf6a7e8',
Query='label.nameLIKEtrial^sys_created_by=admin^ORDERBYDESCsys_created_on'
)
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Query Record Labels (Tags) Using Parent Table and Record
DECLARE @MyQuery NVARCHAR(MAX) = '-- 1. Get ALL labels (tags) for a specific Problem record
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8''
)
-- 2. Check whether the record has a specific label
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''label.name=trial''
)
-- 3. Get labels where the name starts with a prefix (e.g. odbc*)
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''label.nameSTARTSWITHodbc''
)
-- 4. Get labels where the name contains a keyword
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''label.nameLIKEpower''
)
-- 5. Get labels added by a specific user
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''sys_created_by=admin''
)
-- 6. Get labels added in the last 7 days
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''sys_created_on>=<<today-7d,FUN_TO_DATETIME>>''
)
-- 7. Combine multiple filters and order by most recent label
SELECT *
FROM get_record_labels
WITH(
ParentTableName=''problem'',
ParentSysId=''62304320731823002728660c4cf6a7e8'',
Query=''label.nameLIKEtrial^sys_created_by=admin^ORDERBYDESCsys_created_on''
)';
EXEC (@MyQuery) AT [LS_TO_SERVICENOW_IN_GATEWAY];