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.
vardoc=$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);