You are viewing limited content. For full access, please sign in.

Question

Question

How to save a document to a specific template?

asked on November 21, 2016

So I'm trying to save a document to a specific template but can't figure out how to specify the template.  The following code is the best I have so far -- but it just saves tags and when I see the document in the repository it's labeled as having no template.

 

@Override
public void saveDocument(Session session, String path, FileType fileType, EnumSet<EntryNameOption> tags, FileInputStream fis) throws IOException {
    Document theDocument = Document.create(path, tags, session);
    Template template = new Template("Members", session);
    Field field = new Field("AcctNo", session);
    field.setType(FieldType.STRING);
    FieldValueCollection fvc = new FieldValueCollection();
    fvc.getTemplateFields().assignTemplate(template);
    fvc.add(field, "1923");
    theDocument.setFields(fvc);
    theDocument.setExtension(fileType.name());
    theDocument.getTemplate();
    theDocument.writeEDoc(fis, new Long(fis.available()), fileType.mimeType);
    theDocument.unlock();
    theDocument.save();
}
0 0

Replies

replied on November 21, 2016

as above except instead of 

fvc.getTemplateFields().assignTemplate(template);

I needed

fvc.assignTemplate(template);

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.