Fórum

Kaleo Workflow Engine - Scripted-notification-recipients

thumbnail
Jakub Liska, modificado 12 Anos atrás.

Kaleo Workflow Engine - Scripted-notification-recipients

Regular Member Postagens: 187 Data de Entrada: 25/03/10 Postagens Recentes
Greetings folks,

I like Kaleo workflow engine and there is practically everything that I need except for one thing.

Imagine that you have a use case without static Role or User who is assigned the task and who is to be notified. For instance when workflow concerns always one of thousands pairs of Users.

It is alright for notifications (onAssignment), that can be done "dynamically" via <scripted-assignment> where you can populate user / role variable as you wish.

But it is a problem for notifications (onExit). Because there is no scripting available, only static :
<recipients>
	<user ... />
</recipients>


so that you can dynamically notify only the reviewer, but you cannot dynamically notify the submitter !?!?

Example :

		<actions>
			<notification>
				<name>Review Notification</name>
				<template>You have a new submission waiting for your review in the workflow.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
			<notification>
				<name>Review Completion Notification</name>
				<template>
					Your submission has been reviewed and the reviewer has applied the following ${taskComments}.
				</template>
				<template-language>freemarker</template-language>
				<notification-type>email</notification-type>
				<execution-type>onExit</execution-type>
			</notification>
		</actions>
		<assignments>
			<scripted-assignment>
				<script>${workflow-scripts/scripted-assignment.groovy}</script>
				<script-language>groovy</script-language>
			</scripted-assignment>
		</assignments>

Here the recipient of the first notification (onAssignment), that is supposed to be sent to a reviewer, can be dynamically assigned in the script. BUT the second on (onExit), that is supposed to be sent to a submitter, cannot be dynamically assigned, only statically. So that both are sent to the approver.

There is one way to deal with this. You'd have to put user / role (to be notified) into context in <scripted-assignment> or before that and later on in NotificationSender (PrivateMessageNotificationSender, IMNotificationSender) ( that you'd have to implement yourself !) send him the message. It has a serious problem though, it is hard to implement a class of a third party plugin :- )

Please, let me know if you consider this a serious problem as I do, or you have a solution to it.

Regards, Jakub
thumbnail
Samir Gami, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Regular Member Postagens: 162 Data de Entrada: 04/02/11 Postagens Recentes
Yes Jakub, I am agree with you, it should be handle by kaleo plugin,

We had somewhat similar situation, but some how we manage it by changing the kaleo code emoticon
thumbnail
Jakub Liska, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Regular Member Postagens: 187 Data de Entrada: 25/03/10 Postagens Recentes
thumbnail
Michael C. Han, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Junior Member Postagens: 74 Data de Entrada: 13/06/07 Postagens Recentes
In 6.1, Kaleo's notification takes in two forms:
(1) Based on what is explicitly specified in the <recipients> node or
(2) Based on users assigned to the specific task (if no <recipient> node is defined)

For explicitly specified recipients, we can use role based, specific user, or specified email address (e.g. mailing list).

I believe what you are asking is resolved as part of 6.1's Kaleo since you can script what users are assigned a given task and notifications are sent to those assigned users. Please let me know if that's not the case.
thumbnail
Jakub Liska, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Regular Member Postagens: 187 Data de Entrada: 25/03/10 Postagens Recentes
Hi Michael,

I improved the question a little and I added an example, now it should really capture the problem. Simply put, Notifications that have onExit execution-type cannot have recipients determined through scripting ... <recipients> only

To fix this is really hard,

1. the solution I mentioned before is not helpful, because I can't just add something to workflow context in scripted-assigment :
workflowContext.put("onExitNotificationRecipient", dynamicallyDeterminedUserId);


and retrieve it in EmailNotificationSender
protected void getAssignedRecipients(
			List<internetaddress> internetAddresses,
			ExecutionContext executionContext)
		throws Exception {

		KaleoTaskInstanceToken kaleoTaskInstanceToken =
			executionContext.getKaleoTaskInstanceToken();

[b]		if (kaleoTaskInstanceToken == null) {
			Map<string, serializable> wc = executionContext.getWorkflowContext();
			long userId = GetterUtil.getLong(
				(String) wc.get("onExitNotificationRecipient"));
			getUserEmailAddress(userId, internetAddresses, executionContext);
			return;
		}[/b]
</string,></internetaddress>


because onExit, userId is null (even if I put it into serviceCotnext), because the workflow context is different than the one in scripting-assignment

2. an additional action can be created, it actually works, but it would need changes in NotificationSender :
<actions>
[b]			<action>
			      <name>setup-on-exit-recipient</name>
			      <script-language>groovy</script-language>			
			       <execution-type>onExit</execution-type>
			       <script>
					<![CDATA[
				  workflowContext.put("onExitNotificationRecipient", dynamicallyDeterminedUserId);
					]]>
			        </script>
			   </action>[/b]
			  <notification>
				<name>Review Notification</name>
				<template>You have a new submission waiting for your review in the workflow.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onAssignment</execution-type>
			</notification>
			<notification>
				<name>Review Completion Notification</name>
				<template>
					Your submission has been reviewed and the reviewer has applied the following ${taskComments}.
				</template>
				<template-language>freemarker</template-language>
				<notification-type>email</notification-type>
				<execution-type>onExit</execution-type>
			</notification>
		</actions>

Another explanatory scenario :
1. Imagine that reviewer Rejected a resource and it would have to be decided what to do next
2. you create a <condition> with <action> and <notification>. Action determines a few things, including a user to be notified
3. but there is no way to determine recipient dynamically and populate the context with it
	<!-- If Rejected first time, it is returned for correction, otherwise administrator needs to review it -->
	<condition>
		<name>determine-cycle</name>
		<script>${workflow-scripts/condition.groovy}</script>
		<script-language>groovy</script-language>
		<!-- First reject = send doc to google for correction and notify provider -->
		<transitions>
			<transition>
				<name>First</name>
				<target>return-for-correction</target>
				<default>true</default>
			</transition>
			<transition>
				<name>Second</name>
				<target>admin-review</target>
				<default>false</default>
			</transition>
		</transitions>
	</condition>

	<!-- If rejected for first time -->
	<task>
		<name>return-for-correction</name>
		<actions>
			<action>
				<name>send-to-google</name>
				<script>
					<![CDATA[
[b]					HERE IT IS MISSING A WAY TO DETERMINE NOTIFICATION RECIPIENT
					because : 
					    NotificationSender reads from context only these two :
					    	WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS);
					    	WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME);
					    BUT it is getting recipient information only from
					        <recipients> element or
					        kaleoTaskAssignmentInstances that doesn't exist without assignment !	 
					    SO THAT there is no way to determine recipients dynamically    [/b]
					]]>
				</script>
				<script-language>groovy</script-language>
				<execution-type>onEntry</execution-type>
			</action>
			<notification>
				<name>Notification about rejection reasons</name>
				<template>Your submission was rejected by client, please modify and resubmit.</template>
				<template-language>text</template-language>
				<notification-type>email</notification-type>
				<execution-type>onExit</execution-type>
			</notification>
		</actions>
	</task>


Btw, I wrote a blog post for those interested in internal working of Kaleo Engine
thumbnail
Michael C. Han, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Junior Member Postagens: 74 Data de Entrada: 13/06/07 Postagens Recentes
Jakub,

Thanks for the write on the kaleo engine. I will read it more carefully once I get some more time.

I now understand what you are asking for in Kaleo and it's something we can add to the road map. Unfortunately, I didn't see your reply earlier. It shouldn't take too much effort to put something in and I'll work with the team to sort through it. If I have time before we GA I'll try to squeeze it in.

Cheers,

-m
Jan Tošovský, modificado 9 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Liferay Master Postagens: 566 Data de Entrada: 22/07/10 Postagens Recentes
Hi Jakub,

I found your observations helpful, but the link to your blog doesn't work any more. Is there any alternative URL to it?

I found old Kaleo configuration which implements it somehow. Now I need some changes and don't want to break it.

Btw, is that 'setup-on-exit-recipient' or 'onExitNotificationRecipient' still needed for 6.2?

Thanks, Jan
Shruti Pandey, modificado 8 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

New Member Postagens: 23 Data de Entrada: 18/11/15 Postagens Recentes
Hi,

I know its an old post now.
I got stuck in Scripted notification recipients.
I have to send only User Notification.
I have assigned roles using groovy script.
Now I have to send notification to that role which is assigned through scripted assignment.
I tried the groovy script in recipients but I am not sure what I am doing wrong.
Here is my Post , I have added stacktrace which I am getting.

Can someone please guide me on this.

Thanks!
Ajay Jha, modificado 10 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

New Member Postagens: 14 Data de Entrada: 01/02/12 Postagens Recentes
From where you got the kaelo code??
thumbnail
Akash Patil, modificado 12 Anos atrás.

RE: Kaleo Workflow Engine - Scripted-notification-recipients

Junior Member Postagens: 75 Data de Entrada: 13/12/10 Postagens Recentes
Hi Friends.,
I have one problem., which you can help me to resolve this,
I have posted my problem here WorkFlowProblem
Please go through this and help,

Thanks and regards,
Akash Patil