cancel
Showing results for 
Search instead for 
Did you mean: 

Getting JS value to WorkflowAction class`

g_rathod
Star Contributor
Star Contributor
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.
1 REPLY 1

groberts
Champ on-the-rise
Champ on-the-rise
Did you solve this ? I just googled for the same thing.

I see that the Community Edition of Alfresco 3.4 has a lot more Workflow functionality.