Skip to content

$Documents

Provides trusted server-side document automation within the current tenant. Normal operations do not enforce the invoking user ACL; authorize user-supplied targets before calling them. Use Document for lifecycle, files, profile, and security operations.

1
const $Documents;

Examples

Archive a generated report as a document

1
2
3
4
5
6
var doc = $Documents.New('Purchase Order ' + $Xml.Evaluate('Id'));
doc.Description = 'Created by instance ' + $Instance.Number;
doc.Files.AddPDF($Xml.Evaluate('OrderHtml'), 'PurchaseOrder.pdf');
doc.Publish('Purchasing\\Orders');

$Xml.SetValue('DocumentId', doc.Id);

Capabilities

Retrieval

Creation

  • $Documents.New: Creates an unsaved Draft document with new version and branch IDs, initially version 1.0.0.
  • $Documents.NewVersion: Creates a Draft version for the specified document family; call Save or Publish to persist the record.