0 Replies Latest reply: May 18, 2012 3:56 AM by felipe ieder - oracle RSS

    How to change the Task title on runtime?

    felipe ieder - oracle
      Hi experts again,

      My customer is struggling with something very simple: how to customize the Task title. You can certainly create an argument in the task, use Data Associations to map the argument, and then use XPath expression to get the value from the task payload and set it to the task title. That works fine. But it only executes once, when the process instance 'enters' in the task.

      So once the Task is created, you can see the custom title in the Workspace.

      Now, can we change the Title on runtime? I thought you could get the task payload, update the title and finally update the task but this does not seem to work. Here's the code that does it.
      In this example, the priority is updated successfully but not the title.

      FacesContext context = FacesContext.getCurrentInstance();
      String tskId = (String)context.getApplication().evaluateExpressionGet(context,
      "#{pageFlowScope.bpmWorklistTaskId}", String.class);
      IWorkflowServiceClient workflowSvcClient = WorkflowService.getWorkflowServiceClient();
      ITaskService taskSvc = workflowSvcClient .getTaskService();
      ITaskQueryService wfQueryService = workflowSvcClient.getTaskQueryService();
      IWorkflowContext wfContext = WorklistUtil.getWorkflowContextForASelectedTask();
      Task myTask;

      try {
      myTask = wfQueryService.getTaskDetailsById(wfContext, tskId);

      Element payloadElem = myTask.getPayloadAsElement();

      System.out.println("****************" + myTask.getTitle());
      System.out.println("****************" + myTask.getPriority());

      myTask.setTitle("Task Title 3");
      myTask.setPriority(2);

      myTask.setPayloadAsElement(payloadElem);
      taskSvc.updateTask(wfContext, myTask);

      } catch (Exception e) {
      e.printStackTrace();
      }

      The results which printed out in console after execute above code twice.
      ****************Task Title 1
      ****************3
      ****************Task Title 1
      ****************2