cancel
Showing results for 
Search instead for 
Did you mean: 

Workflow updating document properties

crono40
Champ on-the-rise
Champ on-the-rise
Hello,

I have a question. I want to use the advanced workflow "Send Documents for review (Request document approval from one or more colleagues)".

When I put the document in my folder, i set a value to the document description (draft).

I would like to update this value, when i start a workflow on this document.

Finally, I would like to update it again when the workflow is validated.

Is there a way to do it easily ?

Thanks for yours answers.
12 REPLIES 12

kaynezhang
World-Class Innovator
World-Class Innovator
Do you mean  creating a new version of the document that the workflow action on?

Yes of course ,but you should make it versionable(if it is not already  versionable),below is sample code

if(!doc.isVersioned)
{
   doc.addAspect("cm:versionable");
}
// check it out and update  the working copy
var workingCopy = doc.checkout();
workingCopy.content = update working copy content";
workingCopy.properties['cm:description'] = "EN COURS DE REVISION";
// check it in
doc = workingCopy.checkin();

crono40
Champ on-the-rise
Champ on-the-rise
Yes thanks kaynezhang. I did it, helping me with this page : http://wiki.alfresco.com/wiki/JavaScript_API_Cookbook#Create_Document.2C_Make_it_Versionable.2C_Modi...

However, I have an other problem. When I start my workflow, the document description is updated and the version is changed (1.0 and become 1.1). I would like if the document is rejected, the document go back to 1.0 version. When I did it manually in Alfresco Share, the document version is going to 1.2

I tried removing doc of bpm_package and recreate it, to have file with 1.0 version, with this code

var files = [];
for(var j=0; j<bpm_package.children.length; j++){
bpm_package.children[j].properties['cm:description'] = "DRAFT!";
files[j] = bpm_package.children[j];
bpm_package.children[j].remove();
bpm_package.addNode(files[j]);
}


But when i start my workflow i have a permission error
org.activiti.engine.ActivitiException: Exception while invoking TaskListener: Exception while invoking TaskListener: 04210074 Failed to execute supplied script: 04210073 Access refusé. Vous n'avez pas la permission de réaliser cette opération.


Any ideas to solve it ? Thanks a lot

kaynezhang
World-Class Innovator
World-Class Innovator

Why not revert the document to previous version.when the document is rejected

for(var j=0; j<bpm_package.children.length; j++){
var doc = bpm_package.children[j];
doc.revert();
}