• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

Generate a document

Audience:
api
•
Version: 10
Some tooltip text!
• 2 minutes to read
 • 2 minutes to read
  • RESTful REST API
  • HTTP RPC Agent API
var doc = {}
doc.Header = "Testing test";
doc.Name = "foo.doc";
doc.OurRef = "foo/1";
doc.YourRef = "bar/99";
doc.Description = "BAZ FTW";
doc.DocumentTemplate = { DocumentTemplateId = 2 };
doc.Contact = { ContactId = 25 };
doc.Person = { PersonId = 63, ContactId = 25, }; 
doc = Post("api/v1/Document", doc);

At this point, the document record has been created, but the content is not generated yet. We can either upload some content directly:

id = res.DocumentId;
content = "This is some document content.";
Put("api/v1/Document/" + id + "/content", content)

Or we can use the document template to generate a fresh document for us:

id = res.DocumentId;
Post("api/v1/Document/" + id + "/content")
content = Get("api/v1/Document/" + id + "/content")
var doc = {}
doc.Header = "Testing test";
doc.Name = "foo.doc";
doc.OurRef = "foo/1";
doc.YourRef = "bar/99";
doc.Description = "BAZ FTW";
doc.DocumentTemplate = { DocumentTemplateId = 2 };
doc.Contact = { ContactId = 25 };
doc.Person = { PersonId = 63, ContactId = 25 };
doc = Post("api/v1/Agents/Document/SaveDocumentEntity", doc);

At this point, the document record has been created, but the content is not generated yet. We can either upload some content directly:

id = doc.DocumentId;
content = "This is some document content.";
var req = { DocumentId: id, Stream: content }
doc = Post("api/v1/Agents/Document/SetDocumentStreamFromId", req);

Or we can use the document template to generate a fresh document for us:

id = doc.DocumentId;
var req = { DocumentId: id }
doc = Post("api/v1/Agents/Document/CreateNewPhysicalDocumentFromTemplate", req);

This will generate a new document based on the template and return the updated document object to us.

Note

The examples are given in JavaScripty pseudocode.

In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top