Foren

Kaleo Workflow: No KaleoTaskInstanceToken exists

thumbnail
Ivano Carrara, geändert vor 12 Jahren.

Kaleo Workflow: No KaleoTaskInstanceToken exists

Expert Beiträge: 345 Beitrittsdatum: 03.07.05 Neueste Beiträge
Hi all,

In my portlet I'll assign a Task to a User.

So, I get the WorkflowInstanceLink:

WorkflowInstanceLink workflowInstanceLink= WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, groupId(), SomeClass.class.getName(), someClassPK);


Here I retrieve the task I'm looking for, for example workflowInstanceLink.getWorkflowInstanceId() is 14938.

Then I try to assign it to a User:

WorkflowTaskManagerUtil.assignWorkflowTaskToUser(
					companyId,
					userId,
					workflowInstanceLink.getWorkflowInstanceId(),
					assigneeUserId,
					"Some comments ...",
					null,
					null);


But I get the error: "com.liferay.portal.kernel.workflow.WorkflowException: com.liferay.portal.workflow.kaleo.NoSuchTaskInstanceTokenException: No KaleoTaskInstanceToken exists with the primary key 14938"

In fact the in the kaleinstancetoken table there are two records about the task that I'll to assign with kaleoTaskInstanceTokenId of 14939 and 14945.

Please, anyone can help me?

Thank you in advance,
Ivano C.
Vlad Kuzmyk, geändert vor 11 Jahren.

RE: Kaleo Workflow: No KaleoTaskInstanceToken exists

New Member Beiträge: 10 Beitrittsdatum: 18.01.12 Neueste Beiträge
Hi Ivano,

I have the same problem when try to assign task to user with a groovy script in workflow task definition for document library when new document gets added.

WorkflowInstanceLink workflowInstanceLink = WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, groupId, className, classPK);
WorkflowInstance workflowInstance = WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, workflowInstanceLink.getWorkflowInstanceId());
System.out.println(workflowInstance.getWorkflowContext() );

WorkflowTaskManagerUtil.assignWorkflowTaskToUser(companyId, userId, classPK, 27743, "Automatically assigned", now, workflowInstance.getWorkflowContext());



Did you solve this problem?
Maxim Kuleshov, geändert vor 10 Jahren.

RE: Kaleo Workflow: No KaleoTaskInstanceToken exists

New Member Beiträge: 5 Beitrittsdatum: 28.04.13 Neueste Beiträge
I'm also experiencing similar problem. I'm developing hook over EditArticleAction. So I see standard behaviour creates new instance (via startWorkflowInstance) and I'm able to retrieve that instance via WorkflowInstanceManagerUtil - but I do not see any "tasks" associated with that newly-created instance. For older instances - tasks are available and I can load them via WorkflowTaskManagerUtil.

Nethertheless, I see task id in the database and also in the UI I see there is task associated with new flow instance.

Why that task is not visible programmatically, at least just after calling startWorkflowInstance?
Sudhanshu Kumar Shukla, geändert vor 6 Jahren.

RE: Kaleo Workflow: No KaleoTaskInstanceToken exists

Junior Member Beiträge: 35 Beitrittsdatum: 29.08.16 Neueste Beiträge
Hi All,

I Know It's for you guys this Answer of your problem but It HelpFull for future Developers.

But the Problem In Your Above Code Is your Are passing the Explicit WorkflowTaskId but
Where Keleo Engine Will Tooks All the things Related To Workflow Task Stores Into WorkFlowTaskLog

So from there You Can Get The workflowTaskId.

Below Is the Sample Code Which Worked For Me.

WorkflowInstanceLink instanceLink=WorkflowInstanceLinkLocalServiceUtil.getWorkflowInstanceLink(companyId, groupId, Leave.class.getName(), leaveId);
			WorkflowInstance workflowInstance=WorkflowInstanceManagerUtil.getWorkflowInstance(companyId, instanceLink.getWorkflowInstanceId());
			List<workflowlog> workflowLogs=getWorkflowLogs(companyId, workflowInstance.getWorkflowInstanceId());
			long workflowTaskId = 0;
			if(!workflowLogs.isEmpty())
				workflowTaskId = workflowLogs.get(workflowLogs.size()-1).getWorkflowTaskId();
			WorkflowTask assignToMe = WorkflowTaskManagerUtil.assignWorkflowTaskToUser(companyId, userId,
					workflowTaskId, userId, "Programtically Assign to myself.", null, workflowInstance.getWorkflowContext());
			if (Validator.isNotNull(assignToMe)) {
				WorkflowTaskManagerUtil.completeWorkflowTask(companyId, userId, workflowTaskId,
						"review", "Leave Approved", workflowInstance.getWorkflowContext());
				log.info("Your Leave is granted by " + display.getUser().getFullName());
			}
		} catch (Exception e) {
			log.error("Unable to assign Workflow for self : " + e.getMessage());
		}

	}

	private List<workflowlog> getWorkflowLogs(long companyId, long workflowInstanceId) throws WorkflowException {
		List<integer> assignLogTypes = new ArrayList&lt;&gt;();
		assignLogTypes.add(WorkflowLog.TASK_ASSIGN);
		List<workflowlog> workflowLogs = WorkflowLogManagerUtil.getWorkflowLogsByWorkflowInstance(companyId,
				workflowInstanceId, assignLogTypes, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
				WorkflowComparatorFactoryUtil.getLogCreateDateComparator(true));
		if(Validator.isNotNull(workflowLogs))
			log.debug("WorkFlow Logs Founnd");
		else
			return new ArrayList&lt;&gt;();
		
		return workflowLogs;
	}</workflowlog></integer></workflowlog></workflowlog>


Below Is the Usefull Link Related To WorkflowTask Programmatically.

how-to-execute-custom-entity-kaleo-workflow-programmatically-in-liferay-dxp

Hope This Will Help Future Developers....

Enjoy Coding........emoticonemoticon