AnsweredAssumed Answered

Getting JS value to WorkflowAction class`

Question asked by g_rathod on Sep 8, 2010
Latest reply on Oct 26, 2010 by groberts
Hi Friends,

I am doing my customization in Alfresco SHARE
I am stuck with strange issue.
There is Approve / Reject workflow.
Workflow is going fine, the problem is only setting my rejectComment through js to workflow property.
Once reviewer click Reject , it will open one Popup window having textarea ( for reason about reject ),
once user click ok of that popup, I want that reject reason in my WORKFLOW action class.
but some how I am not able to get it in my action class.

my Process definition

<?xml version="1.0" encoding="UTF-8"?>

<process-definition xmlns="urn:jbpm.org:jpdl-3.1"
   name="mywf:siteReview">

   <swimlane name="initiator" />

   <start-state name="start">
      <task name="mywf:submitSiteReviewTask" swimlane="initiator">
      </task>
      <transition name="" to="review" />
   </start-state>

   <task-node name="review">
      <task name="mywf:reviewMyTask">
         <assignment class="com.company.repo.workflow.GroupAssignment">
            <actors>#{mywf_approvalUser}</actors>
            <pooledactors>SuperAdmin</pooledactors>
         </assignment>

         <event type="pool-assign">
            <script>
               if (bpm_workflowDueDate != void) taskInstance.dueDate =
               bpm_workflowDueDate;
               if (bpm_workflowPriority != void)
               taskInstance.priority =
               bpm_workflowPriority;
                </script>
         </event>
      </task>
      <transition name="ApproveSite" to="approved" />
      <transition name="RejectSite" to="rejected" >
         
      </transition>

   </task-node>

   <task-node name="rejected">

      <event type="node-enter">
         <action class="com.company.repo.workflow.MyWorkflowAction">
            <status>rejected</status>
         </action>
      </event>
      <task name="mywf:rejectedTask" swimlane="reviewer">

      </task>

      <transition name="" to="end" />
   </task-node>

   <task-node name="approved">

      <event type="node-enter">
         <action class="com.company.repo.workflow.MyWorkflowAction">
            <status>approved</status>
         </action>
      </event>
      <transition name="" to="end" />
   </task-node>

   <end-state name="end" />

</process-definition>
I have my custom method inside /share/components/dashlets/my-tasks-min.js


doActionOnOkClick: function MyTasks_doActionOnOkClick(taskId, transitionId,rejectComment)
      {
        
        // Set this taskId to true so we don't send multiple calls for the same task
            this.activeTaskTransitions[taskId] = true;

            var url = YAHOO.lang.substitute("api/workflow/task/end/{taskId}/{transitionId}/{rejectComment}",
            {
               taskId: taskId,
               transitionId: transitionId,
            rejectComment: rejectComment
            });
         
      
            // Transition the task
            Alfresco.util.Ajax.request(
            {
               url: Alfresco.constants.PROXY_URI + url,
               method: "post",
               successCallback:
               {
                  fn: function()
                  {
                     this.onTaskTransitionSuccess();
                  },
                  scope: this
               },
               successMessage: this._msg("transition.success"),
               failureCallback:
               {
                  fn: function()
                  {
                     this.activeTaskTransitions[taskId] = false
                  },
                  scope: this
               },
               failureMessage: this._msg("transition.failure"),
               scope: this
            });
      },

and in turn it will be handled through alfresco side webscript end-task.post.desc.xml
and related JavaScript 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;
   }
  
   model.transitionId = transitionId;


    // Optional comment
   var rejectComment = url.templateArgs.rejectComment;
   if (rejectComment === undefined)
   {
      rejectComment = "";
   }
  
   model.rejectComment = rejectComment;

[b]I am getting here all below 3 parameters perfectly in logger output[/b]
   logger.log("*******  taskID :"+ taskId);
      logger.log("*******  transitionId :"+ transitionId);
        logger.log("*******  rejectComment :"+ rejectComment);


[b]Unfortunetely from below code, I am not able to set reject comment to my workflow property…  I am using alfresco 3.2r enterprise[/b]
   var workflowProperties = task.getProperties();
    workflowProperties["bpm:description"] = rejectComment;
    task.setProperties(workflowProperties);

   

   task.endTask(transitionId);
}

main();

any help appreciated.

Outcomes