---
sourceDocument: Xanadu API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/xanadu/api-reference

 Release :

    - xanadu

ft:locale :

    - en-US

ft:publication_title :

    - Xanadu API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# DocumentReferenceService - Scoped, Global

# DocumentReferenceService - Scoped, Global {#ariaid-title1}

* Release version: Xanadu
* 
* Updated August 1, 2024
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 2 minutes to read

The DocumentReferenceService API provides methods for managing document references within a target table, such as the Incidents \[incident\] or Knowledge \[kb_knowledge\] table. You can use document references
to associate information with a record.

This API requires the Document Management
plugin (com.snc.platform_document_management) and is provided within the
`sn_doc_services` namespace. For information, see [Document Services](https://www.servicenow.com/docs/access?context=document-services-landing-page&version=xanadu&pubname=xanadu-servicenow-platform&ft:locale=en-US).  
The following APIs enable you to define and manage documents:

* [SystemDocument](https://servicenow-prod.fluidtopics.net/hiu62Cu~o3jKLyJ5uf3yhg#SystemDocumentBothAPI "The SystemDocument API provides methods for setting fields of a record in the Documents [ds_document] table.") -- Define a document object.
* [DocumentService](https://servicenow-prod.fluidtopics.net/CHqHZXeSYpjShUPRtBPrNA#DocumentServiceBothAPI "The DocumentService API provides methods for creating, deleting, and updating a document.") -- Add, update, or delete a document.
{#DocumentReferenceServiceBothAPI__ul_krc_vmf_vpb}

## DocumentReferenceService - DocumentReferenceService() {#ariaid-title2}

Instantiates a DocumentReferenceService object.
{#DRS-DocumentReferenceService__table_zw5_mcg_tpb__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Table 1. Parameters]

{#DRS-DocumentReferenceService__table_zw5_mcg_tpb}  
The following example shows how to instantiate a
DocumentReferenceService object.

    var result = new sn_doc_services.DocumentReferenceService();

## DocumentReferenceService - addDocumentReference(String docSysId, String targetTable, String
tableSysId) {#ariaid-title3}

Adds a document reference to a target table record.
{#DRS-addDocumentReference_S_S_S__table_w4z_2cg_tpb__entry__3}{#DRS-addDocumentReference_S_S_S__ph_docserv_parm_docID}

| Name | Type | Description |
|-|-|-|
| docSysId | String | Sys_id of a document record in the Documents \[ds_document\] table. |
| targetTable | String | Name of the target table on which to provide a document reference. |
| tableSysId | String | Sys_id of the target table record to which the document reference is to be added. |
[Table 2. Parameters]

{#DRS-addDocumentReference_S_S_S__table_w4z_2cg_tpb} {#DRS-addDocumentReference_S_S_S__table_x4z_2cg_tpb__entry__2}

| Type | Description |
|-|-|
| Object | Sys_id of the new record in the Document References \[ds_document_reference\] table with a success message. Error message otherwise. { "message": "String", "status": "String" } {#DRS-addDocumentReference_S_S_S__api_docserv_codeblock_dets} |
| \<Object\>.message | Message confirming success or error. If successful, includes the sys_id of the record the document reference was added to. Data type: String |
| \<Object\>.status | Status indicating whether the operation is successful. Possible values: * success - The operation was successful. * failure -- The operation was not successful. The message provides details. {#DRS-addDocumentReference_S_S_S__ul_rlv_5cv_j4b} Data type: String |
[Table 3. Returns]

{#DRS-addDocumentReference_S_S_S__table_x4z_2cg_tpb}  
The following example shows how to add a document reference to a record in the Incidents
\[incident\] table.

    var docReference = new sn_doc_services.DocumentReferenceService();

    var result = docReference.addDocumentReference("<docSysId>", "incident", "<tableSysId>");

    gs.info(JSON.stringify(result, null, 2));

Output:

    {
      "message": "Adding an entry to DocumentReference for the given docId to target table : incident, sysId : <tableSysId> is successful.",
      "status": "success"
    }

## DocumentReferenceService - removeDocumentReference(String docSysId, String targetTable,
String tableSysId) {#ariaid-title4}

Removes a document reference from the Document References \[ds_document_reference\]
table.
{#DRS-removeDocumentReference_S_S_S__table_w4z_2cg_tpb__entry__3}{#DRS-removeDocumentReference_S_S_S__ph_docserv_parm_docID}

| Name | Type | Description |
|-|-|-|
| docSysId | String | Sys_id of a document record in the Documents \[ds_document\] table. |
| targetTable | String | Name of the table containing the document reference. This information is listed with the document in the Document References \[ds_document_reference\] table. |
| tableSysId | String | Sys_id of the record from which the document is referenced. You can find related information listed with the document in the Document References \[ds_document_reference\] table. |
[Table 4. Parameters]

{#DRS-removeDocumentReference_S_S_S__table_w4z_2cg_tpb} {#DRS-removeDocumentReference_S_S_S__table_x4z_2cg_tpb__entry__2}

| Type | Description |
|-|-|
| Object | Success message. Error message otherwise. { "message": "String", "status": "String" } {#DRS-removeDocumentReference_S_S_S__api_docserv_codeblock_dets} |
| \<Object\>.message | Message confirming success or error. If successful, includes the sys_id of the record the document reference was removed from. Data type: String |
| \<Object\>.status | Status indicating whether the operation is successful. Possible values: * success - The operation was successful. * failure -- The operation was not successful. The message provides details. {#DRS-removeDocumentReference_S_S_S__ul_rlv_5cv_j4b} Data type: String |
[Table 5. Returns]

{#DRS-removeDocumentReference_S_S_S__table_x4z_2cg_tpb}  
The following example shows how to remove a document reference from a record in the
Incidents \[incident\] table.

    var docReference = new sn_doc_services.DocumentReferenceService();

    var result = docReference.removeDocumentReference("<docSysId>", "incident", "<tableSysId>");

    gs.info(JSON.stringify(result, null, 2));

Output:

    {
      "message": "Deleting an entry to DocumentReference for the given docId to target table : incident, sysId : <tableSysId> is successful.",
      "status": "success"
    }


