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

Question

Question

Assign document template using CMIS

SDK
asked on October 2, 2020

HI all,

I'm attempting to use the Port CMIS library to manage documents within Laserfiche. I have code working to create a document, but attempts to assign a value to the lf:templateName property are ignored. Inspecting with the debugger, it looks like that property is ReadOnly.

Is assigning a template to a document possible using the CMIS gateway? I've found answers on this site showing how to search by templateName, but I can't find anything about assigning a template in the first place.

Thanks in advance for your time.

0 0

Replies

replied on October 7, 2020
public IDocument CreateDocument(string path, string filename, string mimetype, byte[] contentBytes, string templateName = null)
{
     IDictionary<string, object> properties = new Dictionary<string, object>
     {
          [PropertyIds.Name] = filename,
          [PropertyIds.ObjectTypeId] = "lf:document"
     };

     // prepare properties
     if (!String.IsNullOrWhiteSpace(templateName))
     {
          List<String> secondaryTypes = new List<String>() { $"template:{templateName}", "lf:fields" };
          properties[PropertyIds.SecondaryObjectTypeIds] = secondaryTypes.ToArray();

          // example of setting fields
          properties["field:SOME_FIELD_NAME"] = "Some value";
     }

     IFolder parent = (IFolder)Session.GetObjectByPath(path);

     Stream stream = new MemoryStream(contentBytes);

     IContentStream contentStream = Session.ObjectFactory.CreateContentStream(filename, contentBytes.Length, mimetype, stream);

     // create the document
     return parent.CreateDocument(properties, contentStream, VersioningState.None);
}

 

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

Sign in to reply to this post.