Vue combinée Vue Plate Arborescence
Sujets [ Précédent | Suivant ]
toggle
Jakub Liska
Kaleo Workflow Engine - Scripted-notification-recipients
19 novembre 2011 06:44
Réponse

Jakub Liska

Rang: Regular Member

Publications: 187

Date d'inscription: 25 mars 2010

Publications Récentes

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 :
1<recipients>
2    <user ... />
3</recipients>


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

Example :
 1
 2        <actions>
 3            <notification>
 4                <name>Review Notification</name>
 5                <template>You have a new submission waiting for your review in the workflow.</template>
 6                <template-language>text</template-language>
 7                <notification-type>email</notification-type>
 8                <execution-type>onAssignment</execution-type>
 9            </notification>
10            <notification>
11                <name>Review Completion Notification</name>
12                <template>
13                    Your submission has been reviewed and the reviewer has applied the following ${taskComments}.
14                </template>
15                <template-language>freemarker</template-language>
16                <notification-type>email</notification-type>
17                <execution-type>onExit</execution-type>
18            </notification>
19        </actions>
20        <assignments>
21            <scripted-assignment>
22                <script>${workflow-scripts/scripted-assignment.groovy}</script>
23                <script-language>groovy</script-language>
24            </scripted-assignment>
25        </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
Samir Gami
RE: Kaleo Workflow Engine - Scripted-notification-recipients
22 septembre 2011 02:59
Réponse

Samir Gami

Rang: Regular Member

Publications: 162

Date d'inscription: 3 février 2011

Publications Récentes

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
Jakub Liska
RE: Kaleo Workflow Engine - Scripted-notification-recipients
4 octobre 2011 15:35
Réponse

Jakub Liska

Rang: Regular Member

Publications: 187

Date d'inscription: 25 mars 2010

Publications Récentes

LPS-21797
Michael C. Han
RE: Kaleo Workflow Engine - Scripted-notification-recipients
14 octobre 2011 06:06
Réponse

Michael C. Han

LIFERAY STAFF

Rang: Junior Member

Publications: 73

Date d'inscription: 13 juin 2007

Publications Récentes

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.
Akash Mohan Patil
RE: Kaleo Workflow Engine - Scripted-notification-recipients
18 octobre 2011 02:55
Réponse

Akash Mohan Patil

Rang: Junior Member

Publications: 70

Date d'inscription: 12 décembre 2010

Publications Récentes

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
Jakub Liska
RE: Kaleo Workflow Engine - Scripted-notification-recipients
20 novembre 2011 11:17
Réponse

Jakub Liska

Rang: Regular Member

Publications: 187

Date d'inscription: 25 mars 2010

Publications Récentes

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 :
1workflowContext.put("onExitNotificationRecipient", dynamicallyDeterminedUserId);


and retrieve it in EmailNotificationSender
 1protected void getAssignedRecipients(
 2            List<InternetAddress> internetAddresses,
 3            ExecutionContext executionContext)
 4        throws Exception {
 5
 6        KaleoTaskInstanceToken kaleoTaskInstanceToken =
 7            executionContext.getKaleoTaskInstanceToken();
 8
 9[b]        if (kaleoTaskInstanceToken == null) {
10            Map<String, Serializable> wc = executionContext.getWorkflowContext();
11            long userId = GetterUtil.getLong(
12                (String) wc.get("onExitNotificationRecipient"));
13            getUserEmailAddress(userId, internetAddresses, executionContext);
14            return;
15        }[/b]


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 :
 1<actions>
 2[b]            <action>
 3                  <name>setup-on-exit-recipient</name>
 4                  <script-language>groovy</script-language>            
 5                   <execution-type>onExit</execution-type>
 6                   <script>
 7                    <![CDATA[
 8                  workflowContext.put("onExitNotificationRecipient", dynamicallyDeterminedUserId);
 9                    ]]>
10                    </script>
11               </action>[/b]
12              <notification>
13                <name>Review Notification</name>
14                <template>You have a new submission waiting for your review in the workflow.</template>
15                <template-language>text</template-language>
16                <notification-type>email</notification-type>
17                <execution-type>onAssignment</execution-type>
18            </notification>
19            <notification>
20                <name>Review Completion Notification</name>
21                <template>
22                    Your submission has been reviewed and the reviewer has applied the following ${taskComments}.
23                </template>
24                <template-language>freemarker</template-language>
25                <notification-type>email</notification-type>
26                <execution-type>onExit</execution-type>
27            </notification>
28        </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
 1    <!-- If Rejected first time, it is returned for correction, otherwise administrator needs to review it -->
 2    <condition>
 3        <name>determine-cycle</name>
 4        <script>${workflow-scripts/condition.groovy}</script>
 5        <script-language>groovy</script-language>
 6        <!-- First reject = send doc to google for correction and notify provider -->
 7        <transitions>
 8            <transition>
 9                <name>First</name>
10                <target>return-for-correction</target>
11                <default>true</default>
12            </transition>
13            <transition>
14                <name>Second</name>
15                <target>admin-review</target>
16                <default>false</default>
17            </transition>
18        </transitions>
19    </condition>
20
21    <!-- If rejected for first time -->
22    <task>
23        <name>return-for-correction</name>
24        <actions>
25            <action>
26                <name>send-to-google</name>
27                <script>
28                    <![CDATA[
29[b]                    HERE IT IS MISSING A WAY TO DETERMINE NOTIFICATION RECIPIENT
30                    because :
31                        NotificationSender reads from context only these two :
32                            WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_ADDRESS);
33                            WorkflowConstants.CONTEXT_NOTIFICATION_SENDER_NAME);
34                        BUT it is getting recipient information only from
35                            <recipients> element or
36                            kaleoTaskAssignmentInstances that doesn't exist without assignment !    
37                        SO THAT there is no way to determine recipients dynamically    [/b]
38                    ]]>
39                </script>
40                <script-language>groovy</script-language>
41                <execution-type>onEntry</execution-type>
42            </action>
43            <notification>
44                <name>Notification about rejection reasons</name>
45                <template>Your submission was rejected by client, please modify and resubmit.</template>
46                <template-language>text</template-language>
47                <notification-type>email</notification-type>
48                <execution-type>onExit</execution-type>
49            </notification>
50        </actions>
51    </task>


Btw, I wrote a blog post for those interested in internal working of Kaleo Engine
Michael C. Han
RE: Kaleo Workflow Engine - Scripted-notification-recipients
14 décembre 2011 15:27
Réponse

Michael C. Han

LIFERAY STAFF

Rang: Junior Member

Publications: 73

Date d'inscription: 13 juin 2007

Publications Récentes

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
Ajay Jha
RE: Kaleo Workflow Engine - Scripted-notification-recipients
1 octobre 2013 00:14
Réponse

Ajay Jha

Rang: New Member

Publications: 14

Date d'inscription: 1 février 2012

Publications Récentes

From where you got the kaelo code??
Jan Tošovský
RE: Kaleo Workflow Engine - Scripted-notification-recipients
13 mars 2015 03:27
Réponse

Jan Tošovský

Rang: Expert

Publications: 424

Date d'inscription: 22 juillet 2010

Publications Récentes

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
RE: Kaleo Workflow Engine - Scripted-notification-recipients
17 décembre 2015 20:41
Réponse

Shruti Pandey

Rang: New Member

Publications: 23

Date d'inscription: 17 novembre 2015

Publications Récentes

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!