06-07-2010 05:47 PM
/d/d/workspace/SpacesStore/2e0b110a-0ebd-4003-86ad-00b85787cb2a/new%20(Working%20Copy).pdfvar filename = null;
var content = null;
var title = "";
var description = "";
var taskId = "";
// locate file attributes
for each (field in formdata.fields)
{
if (field.name == "taskId")
{
taskId = field.value;
}
if (field.name == "title")
{
title = field.value;
}
else if (field.name == "desc")
{
description = field.value;
}
else if (field.name == "file" && field.isFile)
{
filename = field.filename;
content = field.content;
}
}
// create document in company home for uploaded file
updateNodeRef = workflow.getTask(taskId).getPackageResources()[0].nodeRef;
var workingCopy = search.findNode(updateNodeRef);
if (workingCopy.isLocked)
{
// We cannot update a locked document
status.code = 404;
status.message = "Cannot update locked document '" + updateNodeRef + "', supply a reference to its working copy instead.";
status.redirect = true;
}
if (!workingCopy.hasAspect("cm:workingcopy"))
{
// Ensure the original file is versionable - may have been uploaded via different route
if (!workingCopy.hasAspect("cm:versionable"))
{
// Ensure the file is versionable - but do not autoversion or create initial version yet
var props = new Array(2);
props["cm:autoVersion"] = false;
props["cm:initialVersion"] = false;
workingCopy.addAspect("cm:versionable", props);
}
if (workingCopy.versionHistory == null)
{
// Create the first version manually so we have 1.0 before checkout
workingCopy.createVersion("", true);
}
// It's not a working copy, do a check out to get the actual working copy
workingCopy = workingCopy.checkout();
}
// Update the working copy content
workingCopy.properties.content.write(content);
// Reset working copy mimetype and encoding
workingCopy.properties.content.guessMimetype(filename);
workingCopy.properties.content.encoding = "UTF-8";
// check it in again, with supplied version history note
workingCopy = workingCopy.checkin(description);
workingCopy.save();
model.document = workingCopy;06-08-2010 05:01 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.