cancel
Showing results for 
Search instead for 
Did you mean: 

Web scripts and Workflows

ricny046
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to modify the following web script a little bit to be able to also add a comment when a task is ended:
org/alfresco/repository/workflow/end-task.post.js:

function main(){   // Task ID   var taskId = url.templateArgs.taskId;   if (taskId === undefined)   {      status.setCode(status.STATUS_BAD_REQUEST, "TaskID missing when ending task.");      return;   }   // Check TaskId is valid   var task = workflow.getTask(taskId);   if (task === null)   {      status.setCode(status.STATUS_BAD_REQUEST, "Invalid TaskID when ending task.");      return;   }      model.taskId = taskId;      // Optional Transition ID   var transitionId = url.templateArgs.transitionId;   if (transitionId === undefined)   {      transitionId = null;   }   task.properties["bpm:comment"] = "test"   model.transitionId = transitionId;      task.endTask(transitionId);}main();‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The row that I have added is task.properties["bpm:comment"] = "test" just to see if I can add a comment. But the comment is not set and not displayed in the Workflow history. What am I doing wrong?
4 REPLIES 4

ricny046
Champ in-the-making
Champ in-the-making
Clarification: I'm using the built in Review & Approve workflow.

norgan
Champ in-the-making
Champ in-the-making
Hmm … are the three === correct ? Other than that - I have a similar problem.

Some user herementioned something about task variables and process variables not beeing synchronized correctly. Check out that blog, maybe that helps ?

ricny046
Champ in-the-making
Champ in-the-making
I think "===" is correct because the code works fine except for setting the comment. Here is a description for "===" in Javascript: http://javascript.about.com/library/blequals.htm

The problem is that my Javascript is not embedded in a Workflow. It is a web script interacting with a running workflow so I cannot do exactly the same thing that is possible when using Javascript directly within the workflow.

ricny046
Champ in-the-making
Champ in-the-making
Nobody know how to do this?