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:

DocumentReferenceService - DocumentReferenceService()

Instantiates a DocumentReferenceService object.

Table 1. Parameters
Name Type Description
None

Example

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)

Adds a document reference to a target table record.

Table 2. Parameters
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 3. Returns
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"
}
<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.

Data type: String

Example

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)

Removes a document reference from the Document References [ds_document_reference] table.

Table 4. Parameters
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 5. Returns
Type Description
Object 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

Example

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