<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Yes, that's the currently implemented
      behavior.<br>
      <br>
      In the future we definitely plan to do something about this.
      Namely, to allow the requester to see that the assignment is
      currently being approved, and to check the state of the approval.<br>
      <br>
      Currently, we only show a list of tasks attached to the user. So
      the (potential) requester can suppose that something is going on.
      But to know exactly what is being approved, he must click on the
      task and find the information there. Unfortunately, it is not
      sufficiently intuitive and requires significant access rights.<br>
      <br>
      The most probable future solution is this: After someone requests
      an assignment to be created, we would display it in the user list
      of assignments, but somehow distinguished - probably shown in a
      different color. So after the requester (or someone else) would
      open the user again, he will see that something like that is in
      the approval process and will not try to request it again.<br>
      <br>
      Regards,<br>
      Pavol<br>
    </div>
    <blockquote
      cite="mid:23F96C83E30B7E4DA253EBD07C550836014DB2BD@EX-MB2.solar.local"
      type="cite">
      <pre wrap="">I ask the role twice and take two identical Work Items.

-----Original Message-----
From: midPoint [<a class="moz-txt-link-freetext" href="mailto:midpoint-bounces@lists.evolveum.com">mailto:midpoint-bounces@lists.evolveum.com</a>] On Behalf Of Алексей Ващенков
Sent: Monday, June 1, 2015 4:40 PM
To: midPoint General Discussion
Subject: [midPoint] HA: HA: HA: HA: Send email to approval

I have asked one role twice in two separate edit operation. And After that I have only one Work Item in the dashboard and two messages in mailbox.
________________________________________
От: midPoint [<a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a>] от имени Pavol Mederly [<a class="moz-txt-link-abbreviated" href="mailto:pavol.mederly@gmail.com">pavol.mederly@gmail.com</a>]
Отправлено: 1 июня 2015 г. 16:23
Кому: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Тема: Re: [midPoint] HA:  HA:  HA:  Send email to approval

Алексей,

this is quite strange. If you asked for a role twice (in two separate "used edit" operations), two work items should get created. Are you sure only one was created?

Or, have you asked for two different assignments of the same role within one "user edit" operation? What was the difference between the assignments then?

Overall, each work item creation should result in exactly one mail notification.

Pavol
</pre>
      <blockquote type="cite">
        <pre wrap="">Hello. I have configured email notification to approver. And now if I ask for role twice I recieve two emails and only one work item where I must take a decision. How can I configure notifications to send it only onсe if the same role is requested more than one time?

Now my configuration looks like this:
          <simpleWorkflowNotifier>
             <category>workItemEvent</category>
             <operation>add</operation>
             <recipientExpression>
                <script>
                   <code>assignee.getEmailAddress()</code>
                </script>
             </recipientExpression>
             <bodyExpression>
                <script>
                   <code>
                      import com.evolveum.midpoint.wf.impl.processes.common.*;
                      import com.evolveum.midpoint.prism.*;
                      import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
                      import com.evolveum.midpoint.xml.ns.model.workflow.process_instance_state_3.*;
                      import com.evolveum.midpoint.prism.path.*;
                      import com.evolveum.midpoint.model.impl.controller.ModelController;
                      import com.evolveum.midpoint.task.api.Task;
                      import com.evolveum.midpoint.task.api.TaskManager;
                      import 
com.evolveum.midpoint.schema.result.OperationResult;

                      List segments = new ArrayList();
                      segments.add(new NameItemPathSegment(ProcessInstanceState.F_PROCESS_SPECIFIC_STATE));
                      segments.add(new NameItemPathSegment(ItemApprovalProcessState.F_APPROVAL_REQUEST));
                      segments.add(new NameItemPathSegment(ItemApprovalRequestType.F_ITEM_TO_APPROVE));
                      PrismPropertyValue value = 
(PrismPropertyValue)((PrismProperty)event.getProcessInstanceState().fi
nd(new ItemPath(segments))).getValues().get(0);

                      PrismReferenceValue reference = ((PrismReference) ((AssignmentType) value.getValue()).asPrismContainerValue().getItems().get(0)).getValue();
                      String oid = reference.getOid();
                      Class clazz = 
reference.getTargetTypeCompileTimeClass();

                      TaskManager taskManager = SpringApplicationContextHolder.getBean(TaskManager.class);
                      Task task = taskManager.createTaskInstance();
                      OperationResult parentResult = task.getResult();

                      PrismObject obj = 
SpringApplicationContextHolder.getBean(ModelController.class).getObjec
t(clazz, oid, null, task, parentResult);

                      body = "Пользователю "+(requestee.fullName!=null?requestee.fullName:"без имени")+ " ("+ requestee.name+") запрошены полномочия на \""+obj.asObjectable().getName() +"\".\nТребуется согласование.";
                   </code>
                </script>
             </bodyExpression>
             <transport>mail</transport>
          </simpleWorkflowNotifier>

________________________________________
От: midPoint [<a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a>] от имени Pavol 
Mederly [<a class="moz-txt-link-abbreviated" href="mailto:mederly@evolveum.com">mederly@evolveum.com</a>]
Отправлено: 19 мая 2015 г. 15:54
Кому: midPoint General Discussion
Тема: Re: [midPoint] HA:  HA:  HA:  Send email to approval

Yes, exactly. I've forgot about that in the meanwhile...

P.

----- Original Message -----
From: "Алексей Ващенков" <a class="moz-txt-link-rfc2396E" href="mailto:a.vashchenkov@solarsecurity.ru"><a.vashchenkov@solarsecurity.ru></a>
To: "midPoint General Discussion" <a class="moz-txt-link-rfc2396E" href="mailto:midpoint@lists.evolveum.com"><midpoint@lists.evolveum.com></a>
Sent: Tuesday, May 19, 2015 1:06:19 PM
Subject: [midPoint] HA:  HA:  HA:  Send email to approval

I've compared with version 3.1.1 and found that this error was fixed.
The error was in
com.evolveum.midpoint.notifications.impl.events.workflow.DefaultWorkfl
owEventCreator#createWorkItemCompleteEvent
________________________________________
От: midPoint [<a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a>] от имени Pavol 
Mederly [<a class="moz-txt-link-abbreviated" href="mailto:mederly@evolveum.com">mederly@evolveum.com</a>]
Отправлено: 19 мая 2015 г. 13:29
Кому: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Тема: Re: [midPoint] HA:  HA:  Send email to approval

That's really strange.

I've created the same configuration in my midPoint setup (although now 
I'm working on a branch other than master - but with respect to this 
it should be no difference), and I receive a message only on work item 
creation, not on completion.

Which version of midPoint do you use?

BTW, the expressionFilter can be written a bit simpler, as:

           <simpleWorkflowNotifier>
<category>workItemEvent</category>
              <operation>add</operation>
              <transport>mail</transport>
           </simpleWorkflowNotifier>

In my case I get a notification like this:

============================================ Tue May 19 12:24:38 CEST 
2015 Message{to='[<a class="moz-txt-link-abbreviated" href="mailto:test@test.sk">test@test.sk</a>]', subject='A new work item has been 
created', contentType='null', body='A new work item has been created

Process instance name: Adding Assigment testing to aaa Work item: 
Approve adding Assigment testing to aaa
Assignee: administrator

Notification created on: Tue May 19 12:24:38 CEST 2015

'}

... and no notification on work item completion.

Could you post here your midPoint version and your notification messages?
Also, don't you have (by mistake) also some other notifier that could 
produce the completion messages?

Pavol


On 19. 5. 2015 12:09, Алексей Ващенков wrote:
</pre>
        <blockquote type="cite">
          <pre wrap="">I've just try this.
I have notificator

           <simpleWorkflowNotifier>
              <operation>add</operation>
              <expressionFilter>
                 <script>
                    <code>import com.evolveum.midpoint.notifications.api.events.WorkItemEvent
                      event instanceof WorkItemEvent;
                    </code>
                 </script>
              </expressionFilter>
              <transport>mail</transport>
           </simpleWorkflowNotifier>

And I have the role
<role xmlns=<a class="moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/common/common-3">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a>
        oid="f7bb719e-5da9-40c6-9488-25cae7f850a7"
        version="1">
     <name>Assigment testing</name>
     <metadata>
        <createTimestamp>2015-05-18T16:56:58.728+03:00</createTimestamp>
        <creatorRef oid="00000000-0000-0000-0000-000000000002" type="UserType"><!-- administrator --></creatorRef>
        <createChannel><a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user">http://midpoint.evolveum.com/xml/ns/public/gui/channels-3#user</a></createChannel>
     </metadata>
     <activation>
        <administrativeStatus>enabled</administrativeStatus>
        <effectiveStatus>enabled</effectiveStatus>
        <enableTimestamp>2015-05-18T16:56:58.697+03:00</enableTimestamp>
     </activation>
     <iteration>0</iteration>
     <iterationToken/>
     <requestable>true</requestable>
     <approverRef xmlns:c=<a class="moz-txt-link-rfc2396E" href="http://midpoint.evolveum.com/xml/ns/public/common/common-3">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a>
                  oid="00000000-0000-0000-0000-000000000002"
                  type="c:UserType"><!-- administrator -->
        <description>Approval by the administrator</description>
     </approverRef>
</role>

And in this case I have two "standart" notification. First is created when approval is creadte. The second notifiacation creates after request was approve. It seems after approve created another work item which generates the second notification. But I need only the first one.
________________________________________
От: midPoint [<a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a>] от имени Pavol 
Mederly [<a class="moz-txt-link-abbreviated" href="mailto:mederly@evolveum.com">mederly@evolveum.com</a>]
Отправлено: 19 мая 2015 г. 12:45
Кому: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a>
Тема: Re: [midPoint] HA:  Send email to approval

If I understand you correctly, you want to distinguish between "work item was created" and "work item was finished" events.

In order to do this, there is the changeType attribute:

private ChangeType changeType;   // ADD = process/task start, DELETE = process/task finish (for now)

You can filter for this attribute directly in the notifier configuration (in system config), by using e.g.

<operation>add</operation>

directive to send notifications only on "work item was added" (i.e. created) events.

Is this what you were asking for?

Pavol

This is clear for me.
What should I use as flag to know that approver must take a dessision?
It seems I should use operationStatusCustom. It takes values:
- null if assignment is waiting for approval
- __REJECTED__, if approver rejected an assignment
- __APPROVED__, if approver appreved the assignment 
________________________________________
От: midPoint 
[<a class="moz-txt-link-abbreviated" href="mailto:midpoint-bounces@lists.evolveum.com">midpoint-bounces@lists.evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:midpoint-bounces@lists.evolveum.com"><mailto:midpoint-bounces@lists.ev
olveum.com></a>] от имени Pavol Mederly 
[<a class="moz-txt-link-abbreviated" href="mailto:mederly@evolveum.com">mederly@evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:mederly@evolveum.com"><mailto:mederly@evolveum.com></a>]
Отправлено: 19 мая 2015 г. 12:13
Кому: <a class="moz-txt-link-abbreviated" href="mailto:midpoint@lists.evolveum.com">midpoint@lists.evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:midpoint@lists.evolveum.com"><mailto:midpoint@lists.evolveum.com></a>
Тема: Re: [midPoint] Send email to approval

Alexej,

there are the following workflow-related events:

- WorkItemEvent - when a work item (a request to given approver) is 
being created or finished,
- WorkflowProcessEvent - when a complete workflow process is started 
or finished.

Note that a process can contain more approvals, e.g. in case of 
multilevel approvals.

So, depending on what you want to achieve, you could process one (or
both) of these two events.

Regards,
Pavol

On 19. 5. 2015 11:09, Алексей Ващенков wrote:


I want to send emails only to approver while assigning a role.
What easest way to find out if the event is event abount approve adding?
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:midPoint@lists.evolveum.com"><mailto:midPoint@lists.evolveum.com></a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>




_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:midPoint@lists.evolveum.com"><mailto:midPoint@lists.evolveum.com></a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><a class="moz-txt-link-rfc2396E" href="mailto:midPoint@lists.evolveum.com"><mailto:midPoint@lists.evolveum.com></a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>

_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
        </blockquote>
        <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
      </blockquote>
      <pre wrap="">
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>