<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hello Nico,</p>
    <p>I've tried that myself today. You're right - there's no channel
      there. It was due to a bug in midPoint, which I've fixed on master
      branch (<a
href="https://github.com/Evolveum/midpoint/commit/39581c451f2e06a8cc19932310f41cc0b3da5cba">https://github.com/Evolveum/midpoint/commit/39581c451f2e06a8cc19932310f41cc0b3da5cba</a>).
      If you want to use it for 3.4.x, please cherry-pick it to
      3.4-support branch and build + test the WAR file.</p>
    <p>However. I verified that when initiating the operation from GUI,
      the channel is really <i><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></i>.
      When doing import from resource, I haven't used a custom hook (as
      you did), but much simpler approach: specific user template:</p>
    <p>In the resource definition:</p>
    <p><tt>            <reaction></tt><tt><br>
      </tt><tt>              
        <situation>unmatched</situation></tt><tt><br>
      </tt><tt>               <objectTemplateRef
        oid="7ee3c422-c66a-4725-bb9e-12d5f85ecf6b"
        type="c:ObjectTemplateType"/></tt><tt><br>
      </tt><tt>               <action></tt><tt><br>
      </tt><tt>                 
<handlerUri><a class="moz-txt-link-freetext" href="http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser">http://midpoint.evolveum.com/xml/ns/public/model/action-3#addUser</a></handlerUri></tt><tt><br>
      </tt><tt>               </action></tt><tt><br>
      </tt><tt>            </reaction></tt><tt><br>
      </tt></p>
    <p>The template looks like this:</p>
    <p><tt><objectTemplate oid="7ee3c422-c66a-4725-bb9e-12d5f85ecf6b"
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>></tt><tt><br>
      </tt><tt>    <name>Custom User Template</name></tt><tt><br>
      </tt><tt>    <mapping></tt><tt><br>
      </tt><tt>        <expression></tt><tt><br>
      </tt><tt>            <value></tt><tt><br>
      </tt><tt>                 <targetRef
        oid="7d8cb641-d247-4b1a-bd73-12db459b7627"
        type="RoleType"/>    <!-- role with the auto approval ...
        --></tt><tt><br>
      </tt><tt>            </value></tt><tt><br>
      </tt><tt>        </expression></tt><tt><br>
      </tt><tt>        <target></tt><tt><br>
      </tt><tt>            <path>assignment</path></tt><tt><br>
      </tt><tt>        </target></tt><tt><br>
      </tt><tt>    </mapping>  </tt><tt><br>
      </tt><tt></objectTemplate></tt></p>
    <p>But what's important is that when the user was added via "Import
      from resource", the workflow hook was <i>not</i> involved at all.
      The operation that was executed was a part of the <i>secondary
        delta</i> - meaning the delta that was "induced" by another
      change. In this particular situation, the cause was the existence
      of resource object that was imported. And workflows react only to
      primary deltas.<br>
    </p>
    <p>What does your custom hook do? Does it modify primary delta? If
      yes, you could maybe change it to work with the secondary delta:
      that would be cleaner. And, if your hook does only the assignment
      of a role, it would be best to replace it by using standard
      midPoint mechanism for this - and this is object template.</p>
    <p>Best regards,<br>
    </p>
    <pre class="moz-signature" cols="72">Pavol Mederly
Software developer
evolveum.com
</pre>
    <div class="moz-cite-prefix">On 08.12.2016 10:43, Nico
      Pätzelt-Schäkel wrote:<br>
    </div>
    <blockquote
cite="mid:CAGh9kZxTSuixidV+NSoa1QuSkAEJKaLAAWMgEGCd8X1714Y_-A@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>Hello Pavol Mederly,<br>
        </div>
        thanks for the answer. I have checked the output from :<br>
        <pre>midpoint.getCurrentTask().getChannel()
</pre>
        <pre>In both cases (import account as Superuser and request a role via GUI) the output of getChannel is "null".
</pre>
        <pre>I checked the output from midpoint.getCurrentTask() which gives me something like  Task(id:1481189325403-0-1, name:null, oid:null).
</pre>
        <pre>If I search the task ID in the server tasks GUI. There is no task or subtask with this taskid. 
</pre>
        <pre>Have you any idea why this is the case? 
</pre>
        <pre>Kind regards 
</pre>
        <pre>Nico
</pre>
      </div>
      <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>