cancel
Showing results for 
Search instead for 
Did you mean: 

Starting a fully automated flow

rsaunder
Champ in-the-making
Champ in-the-making
I have a simple process consisting of a start task, two script tasks in sequence, and an end tasks. Both script tasks make the trivial assignment "a=1;". I start the process, then query to see what ran. Whether I query processes or tasks, the list comes back empty. Do I need to do something else to start this task, since the system has no users at all, it's just a REST service? Or is there something wrong with the query?

ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("myProcess",instanceVars);
       List<HistoricTaskInstance> tasks =
             processEngine.getHistoryService().createHistoricTaskInstanceQuery().processInstanceId("myProcess").list();
      System.out.println((Integer.toString(tasks.size())));
      HistoricTaskInstance task;
      for (Iterator<HistoricTaskInstance> iter = tasks.iterator(); iter.hasNext():smileywink: {
         task = (HistoricTaskInstanceEntity) iter.next();
         System.out.println(task.getName());
5 REPLIES 5

trademak
Star Contributor
Star Contributor
With HistoricTaskInstance you are querying for user tasks. You need HistoricActivityInstance to get a list that includes script tasks.

Best regards,

rsaunder
Champ in-the-making
Champ in-the-making
My query now reads as below.  On a process with two script tasks, the history list still comes back empty.

ProcessEngine processEngine = processEngineSession.getProcessEngine();
  ProcessInstance processInstance = processEngine.getRuntimeService().startProcessInstanceByKey("Entry",instanceVars);
   List<HistoricActivityInstance> activities =
     processEngine.getHistoryService().createHistoricActivityInstanceQuery().processInstanceId("Entry").list();
  System.out.println((Integer.toString(activities.size())));
  HistoricActivityInstance activity;
  for (Iterator<HistoricActivityInstance > iter = activities.iterator(); iter.hasNext():smileywink: {
   activity = (HistoricActivityInstance) iter.next();
   System.out.println(activity.getActivityName());

rsaunder
Champ in-the-making
Champ in-the-making
Here is how the engine is created:
processEngineConfiguration = ProcessEngineConfiguration
      .createStandaloneProcessEngineConfiguration();
    processEngineConfiguration.setJobExecutorActivate(true);
    processEngineConfiguration.setDatabaseSchemaUpdate("true");
    processEngineConfiguration
      .setJdbcDriver("org.postgresql.Driver");
    processEngineConfiguration
      .setJdbcUrl("jdbcSmiley Tongueostgresql://localhost:5432/SOA_PoC");
    processEngineConfiguration.setJdbcUsername("postgres");
    processEngineConfiguration.setJdbcPassword("admin");
    processEngine = processEngineConfiguration.buildProcessEngine();
    repositoryService = processEngine.getRepositoryService();
    runtimeService = processEngine.getRuntimeService();
    taskService = processEngine.getTaskService();
    FileInputStream bpmnStream = new FileInputStream(bpmnFile);
    repositoryService.createDeployment().addInputStream(bpmnFile, bpmnStream).name("Entry").deploy();

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,
Which history level do you use?
Doc: 11.2. History configuration

Regards
Martin

rsaunder
Champ in-the-making
Champ in-the-making
Spotted one problem–was querying the instance by process ID using the key instead. Fixing that didn't solve the problem. Looking in the database, I see the engine doing all the right things, so this is a query problem alone. The level is "audit".