AnsweredAssumed Answered

Web scripts and Workflows

Question asked by ricny046 on Oct 21, 2009
Latest reply on Oct 22, 2009 by ricny046
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?

Outcomes