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

Add a document template

Audience:
api
•
Version: 10
Some tooltip text!
• 1 minute to read
 • 1 minute to read
  • RESTful REST API
  • HTTP RPC Agent API
var item = {}
item.Name = "Created by unit test";
item.Filename = "footemplate.txt";
item.Tooltip = "Unit Tests FTW";
item.SaveInDb = 1;
item.LoadTemplateFromPlugin = 0;
item = Post("api/v1/List/DocumentTemplate", item)

At this point, the document template record has been created, but there is no content for the document template. We need to upload some document content to the new record:

var id = item.DocumentTemplateId;
content = "Hello {name}.";
Put("api/v1/List/DocumentTemplate/" + id + "/content", content)

We could call SaveDocumentTemplateEntity and SaveDocumentTemplateStream separately as the REST API does, or we can use the agent call that does both in a single call:

content = "Hello {name}.";

var item = {}
item.Name = "Created by unit test";
item.Filename = "footemplate.txt";
item.Tooltip = "Unit Tests FTW";
item.SaveInDb = 1;
item.LoadTemplateFromPlugin = 0;

var req = { DocumentTemplateEntity: item, Stream: content }
item = Post("api/v1/Agents/List/SetDocumentTemplateStream", req)

At this point, the document template record has been created, and the content has been written to the archive.

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