Endpoint Get Attachments By Parent Row Search
Name
get_attachments_by_parent_search
Description
Get table rows [API reference]
Parameters
| Parameter | Required | Options | ||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Name:
Label: Page Size (Default=2000, Max=10000) Max can be 10000 but it may decrease performance if you fetching less than 10K rows in some requests. |
YES | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: TableName Table name |
YES | |||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: Attachment Filter / Order By Server-side filter for sys_attachment (file name, size, type, date, parent record, etc.) |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: PagingOffset |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: SysId Row 'sys_id' |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: Fields to include in response (Keep blank to get all fields -OR- Enter comma separated list) Comma-separated field names you want to return in the response. E.g. sys_id,name,label,sys_name,sys_updated_on. Using this setting reduces the response size and speed up the processing. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Name:
Label: Query / Order By (Server Side Filter) Server-side encoded query for filtering and ordering records. Supports string, numeric, date, NULL checks, AND/OR logic, and ORDER BY clauses. |
|
Output Columns
| Label | Data Type (SSIS) | Data Type (SQL) | Length | Description |
|---|---|---|---|---|
| sys_id |
DT_WSTR
|
nvarchar(32)
|
32 | |
| table_sys_id |
DT_WSTR
|
nvarchar(32)
|
32 | |
| file_name |
DT_WSTR
|
nvarchar(512)
|
512 | |
| content_type |
DT_WSTR
|
nvarchar(255)
|
255 | |
| hash |
DT_WSTR
|
nvarchar(64)
|
64 | |
| state |
DT_WSTR
|
nvarchar(50)
|
50 | |
| size_bytes |
DT_I8
|
bigint
|
||
| size_compressed |
DT_I8
|
bigint
|
||
| chunk_size_bytes |
DT_I8
|
bigint
|
||
| image_width |
DT_I4
|
int
|
||
| image_height |
DT_I4
|
int
|
||
| average_image_color |
DT_WSTR
|
nvarchar(16)
|
16 | |
| compressed |
DT_BOOL
|
bit
|
||
| table_name |
DT_WSTR
|
nvarchar(80)
|
80 | |
| sys_created_by |
DT_WSTR
|
nvarchar(128)
|
128 | |
| sys_updated_by |
DT_WSTR
|
nvarchar(128)
|
128 | |
| sys_tags |
DT_WSTR
|
nvarchar(1024)
|
1024 | |
| sys_created_on |
DT_DBTIMESTAMP
|
datetime
|
||
| sys_updated_on |
DT_DBTIMESTAMP
|
datetime
|
||
| sys_mod_count |
DT_I4
|
int
|
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 Attachments By Parent Row Search
| Optional Parameters | |
|---|---|
| Attachment Filter / Order By | |
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 Attachments By Parent Row Search
| Optional Parameters | |
|---|---|
| Attachment Filter / Order By | |
ODBC application
Use these SQL queries in your ODBC application data source:
Get Attachments By Parent Row Search
-- Find attachments for specific parent records (multiple parent IDs)
SELECT * FROM get_attachments_by_parent_search
WITH(TableName='problem', Query='sys_idIN62304320731823002728660c4cf6a7e8,6632130c730123002728660c4cf6a734')
-- Parent-level filter: problems updated in last 2 days; attachment-level filter: file name ends with .png or .zip
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName='problem',
Query='sys_updated_on>=<<today-2d,FUN_TO_DATETIME>>',
AttachmentQuery='file_nameENDSWITH.png^ORfile_nameENDSWITH.zip'
)
-- Parent-level filter by sys_id and attachment filter by exact file name
SELECT * FROM get_attachments_by_parent_search
WITH(TableName='problem', Query='sys_id=62304320731823002728660c4cf6a7e8', AttachmentQuery='file_name=dump.png')
-- Attachments uploaded by a specific user for parents matched by parent query
SELECT * FROM get_attachments_by_parent_search
WITH(TableName='incident', Query='opened_by=jsmith', AttachmentQuery='sys_created_by=jsmith')
-- Attachments larger than 1 MB for problems updated in the last month
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName='problem',
Query='sys_updated_on>=<<today-1m,FUN_TO_DATETIME>>',
AttachmentQuery='size_bytes>1048576'
)
-- Only image attachments (content type starts with "image/") for a given parent
SELECT * FROM get_attachments_by_parent_search
WITH(TableName='problem', Query='sys_id=62304320731823002728660c4cf6a7e8', AttachmentQuery='content_typeSTARTSWITHimage/')
-- Order attachments by creation date (per-parent results ordered by attachment date)
SELECT * FROM get_attachments_by_parent_search
WITH(TableName='problem', Query='sys_updated_on>=<<today-2d,FUN_TO_DATETIME>>', AttachmentQuery='ORDERBYsys_created_on')
-- Combine parent IN-list and attachment name contains filter
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName='problem',
Query='sys_idIN62304320731823002728660c4cf6a7e8,6632130c730123002728660c4cf6a734',
AttachmentQuery='file_nameLIKEerror'
)
SQL Server
Use these SQL queries in SQL Server after you create a data source in Data Gateway:
Get Attachments By Parent Row Search
DECLARE @MyQuery NVARCHAR(MAX) = '-- Find attachments for specific parent records (multiple parent IDs)
SELECT * FROM get_attachments_by_parent_search
WITH(TableName=''problem'', Query=''sys_idIN62304320731823002728660c4cf6a7e8,6632130c730123002728660c4cf6a734'')
-- Parent-level filter: problems updated in last 2 days; attachment-level filter: file name ends with .png or .zip
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName=''problem'',
Query=''sys_updated_on>=<<today-2d,FUN_TO_DATETIME>>'',
AttachmentQuery=''file_nameENDSWITH.png^ORfile_nameENDSWITH.zip''
)
-- Parent-level filter by sys_id and attachment filter by exact file name
SELECT * FROM get_attachments_by_parent_search
WITH(TableName=''problem'', Query=''sys_id=62304320731823002728660c4cf6a7e8'', AttachmentQuery=''file_name=dump.png'')
-- Attachments uploaded by a specific user for parents matched by parent query
SELECT * FROM get_attachments_by_parent_search
WITH(TableName=''incident'', Query=''opened_by=jsmith'', AttachmentQuery=''sys_created_by=jsmith'')
-- Attachments larger than 1 MB for problems updated in the last month
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName=''problem'',
Query=''sys_updated_on>=<<today-1m,FUN_TO_DATETIME>>'',
AttachmentQuery=''size_bytes>1048576''
)
-- Only image attachments (content type starts with "image/") for a given parent
SELECT * FROM get_attachments_by_parent_search
WITH(TableName=''problem'', Query=''sys_id=62304320731823002728660c4cf6a7e8'', AttachmentQuery=''content_typeSTARTSWITHimage/'')
-- Order attachments by creation date (per-parent results ordered by attachment date)
SELECT * FROM get_attachments_by_parent_search
WITH(TableName=''problem'', Query=''sys_updated_on>=<<today-2d,FUN_TO_DATETIME>>'', AttachmentQuery=''ORDERBYsys_created_on'')
-- Combine parent IN-list and attachment name contains filter
SELECT * FROM get_attachments_by_parent_search
WITH(
TableName=''problem'',
Query=''sys_idIN62304320731823002728660c4cf6a7e8,6632130c730123002728660c4cf6a734'',
AttachmentQuery=''file_nameLIKEerror''
)';
EXEC (@MyQuery) AT [LS_TO_SERVICENOW_IN_GATEWAY];