Create a case with a document

Many organizations use multiple systems in day-to-day operations, sometimes collaborating in SharePoint and other times using specialized domain specific systems. All these systems can be connected behind the scenes using WorkZone Client as the Enterprise Content Management system that contains all case information, decisions, documents and other relevant documentation.

Often integrations can be developed to create cases and documents in WorkZone Client based on specific events defined in these 3rd-party systems.

The example below displays how to create a case and then add a document with metadata to the newly created case.

Example:


System.IO.FileStream fileStream = new System.IO.FileStream(@"C:\Temp\Documents\New Microsoft Word Document.docx", System.IO.FileMode.Open);
 
// uploading document.
Document doc = new Document();
context.AddToDocuments(doc); // Tells the context that it should send the document to the server on the next call to SaveChanges
context.SetSaveStream(doc, fileStream, true, "", "Document.docx"); // The supplied file name is not important, but the exension is.
context.SaveChanges(); // The document is uploaded to the archive here.
 
// creating an instance of File (our case) and setting required properties/metadata.
File file = new File
{
    Title = "Title of my new case",
    FileClass_Value = "UT"
};
 
// add to data service collection to have automatic change tracking.
DataServiceCollection<File> files = new DataServiceCollection<File>(context);
files.Add(file);
 
// create an instance of record (the document metadata) and associate it with the uploaded document.
Record rec = new Record
{
    Document = doc, // Associates the metadata with the doc we have uploaded
    Title = "Title for my document",
    State_Value = "ARK", // State archived
    RecordType_Value = "U", // Outgoing document
    LetterDate = DateTime.Today // letter date is today
};
 
// associate the record with the case.
file.FileRecords.Add(rec);
 
// Finally. Save all metadata in one transaction (Batch).
context.SaveChanges(SaveChangesOptions.Batch);
				

The copy image is missing