 
					
				
		
09-30-2016 07:06 AM
   var Logger = Java.type('org.slf4j.LoggerFactory');
   var log = Logger.getLogger('myTestLog');
   var HashMap = Java.type('java.util.HashMap');
   var variables = new HashMap();
   variables.put('test1, '1');
   variables.put('test2, '2');
   
   var theSCMProcess = runtimeService.startProcessInstanceByKey("SCM", variables);
   log.info("Process: " + theSCMProcess.getId()); // This is returning a process id
   // get the first user task that was generated
   var task1 = taskService.createTaskQuery().processInstanceId(theSCMProcess.getId()).singleResult();
   log.info("Task: " + task1); // This is returning null
2016-09-30 10:19:14,762 INFO  [Task1Listener.js] Task "Task 1" (380190) created.
2016-09-30 10:19:14,974 INFO  [SCMBulkUpload.js] Process: 380177
2016-09-30 10:19:14,998 INFO  [SCMBulkUpload.js] Task: null
 
					
				
		
09-30-2016 07:23 AM
 
					
				
		
10-12-2016 09:38 AM
 
					
				
		
11-23-2016 09:11 AM
07-13-2018 11:04 AM
I also had this issue.
The issue here is that you are creating user tasks in a SubProcess but quering for tasks using the processInstanceId of the parent process.
To fix this, first find the sub-process instance where the Tasks were created:
ProcessInstance subProcessInstance = runtimeService.createProcessInstanceQuery().superProcessInstanceId( theSCMProcess.getInstanceId() ).singleResult();
then perform the Task search using the id of the sub-process.
Task task1 = taskService.createTaskQuery().processInstanceId( subProcessInstance.getInstanceId() ).singleResult();
 
					
				
				
			
		
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.