DocumentReferenceService - Scoped, Global

concept brazil Updated Sep 10, 2026 2 min read DocumentReferenceServiceBothAPI.md
Raw file servicenow.com

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.

The following APIs enable you to define and manage documents:

Parent Topic:Server API reference

DocumentReferenceService - DocumentReferenceService()

Instantiates a DocumentReferenceService object.

Name Type Description
None

The following example shows how to instantiate a DocumentReferenceService object.

JavaScript
var result = new sn_doc_services.DocumentReferenceService();

DocumentReferenceService - addDocumentReference(String docSysId, String targetTable, String tableSysId)

Adds a document reference to a target table record.

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.

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" }

Text
</td></tr><tr><td>
&lt;Object&gt;.message
</td><td>
Message confirming success or error. If successful, includes the sys\_id of the record the document reference was added to.Data type: String
</td></tr><tr><td>
&lt;Object&gt;.status
</td><td>
Status indicating whether the operation is successful.Possible values:
-   success - The operation was successful.-   failure – The operation was not successful. The **message** provides details.
 Data type: String
</td></tr></tbody></table>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("", "incident", "");

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

Text
Output:

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

Text
## DocumentReferenceService - removeDocumentReference\(String docSysId, String targetTable, String tableSysId\)
Removes a document reference from the Document References \[ds\_document\_reference\] table.
|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 id="table_x4z_2cg_tpb" class="returns"><thead><tr><th>
Type
</th><th>
Description
</th></tr></thead><tbody><tr><td>
Object
</td><td>
Success message. Error message otherwise.```{  "message": "String",  "status": "String"}

<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.

Data type: String

The following example shows how to remove a document reference from a record in the Incidents \[incident\] table.
JavaScript
var docReference = new sn_doc_services.DocumentReferenceService();
var result = docReference.removeDocumentReference("<docSysId>", "incident", "<tableSysId>");
gs.info(JSON.stringify(result, null, 2));

Output:

JSON
{  "message": "Deleting an entry to DocumentReference for the given docId to target table : incident, sysId : <tableSysId> is successful.",  "status": "success"}
Search documentation
Search document titles and file paths on the brazil branch