Skip to content

Document Relationships

You can use the relationships query target to query links in annotations and other document relationships.

Use the Retrieve Document Type Relationships API to get the relationships queryable fields and object relationships. This includes the source__vr and target__vr relationships, which you can use to filter the returned document relationships.

The following are examples of relationship queries.

The following query retrieves relationship properties for link annotations:

SELECT source_doc_id__v, source_major_version__v, source_minor_version__v, relationship_type__v, target_doc_id__v, target_major_version__v, target_minor_version__v
FROM relationships
WHERE relationship_type__v = 'references__v'

The following query retrieves document metadata where the source document has a document type of Promotional Material:

SELECT source__vr.name__v, source__vr.document_number__v, relationship_type__v, target__vr.name__v, target__vr.document_number__v
FROM relationships
WHERE TONAME(source__vr.type__v) = 'promotional_material__c'

Retrieve Redacted Documents for Source Documents

Section link for Retrieve Redacted Documents for Source Documents

The following query retrieves relationship properties for original documents that have a linked redacted document:

SELECT source_doc_id__v, source_major_version__v, source_minor_version__v,
       relationship_type__v, target_doc_id__v, target_major_version__v, target_minor_version__v
FROM relationships
WHERE relationship_type__v = 'redacted_to__v'

Retrieve Source Documents from Redacted Documents

Section link for Retrieve Source Documents from Redacted Documents

The following query retrieves relationship properties for redacted documents and their linked source documents:

SELECT source_doc_id__v, source_major_version__v, source_minor_version__v,
       relationship_type__v, target_doc_id__v, target_major_version__v, target_minor_version__v
FROM relationships
WHERE relationship_type__v = 'redacted_from__v'