<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <p>Hi Mariano,</p>
    <p>I'm not sure if I understand.</p>
    <p>Does the logic work as supposed for both scenarios, when doing
      import, for creating the users for the very first time?<br>
    </p>
    <p>What exact scenario does not work for you?</p>
    <p>I can see the mapping in the object template for "name" attribute
      is weak. So if the name already has value, it will not be
      overwritten.</p>
    <p>I also could suggest that you do the logic for choosing which
      attribute to use for setting user/name in the inbound mapping by
      using something like this:</p>
    <pre><attribute></pre>
    <pre>  <ref>ri:id</ref> <!-- this is the attribute which always has value) --></pre>
    <pre>    <inbound></pre>
    <pre>      <source></pre>
    <pre>        <path>$account/attributes/email</path> <!-- source: the email attribute --></pre>
    <pre>      </source></pre>
    <pre>      <expression></pre>
    <pre>        <script></pre>
    <pre>          <code></pre>
    <pre>if (basic.isEmpty(email)) return input // input is ri:id here</pre>
    <pre>else return email
</pre>
    <pre>          </code></pre>
    <pre>        </script>
</pre>
    <pre>      </expression>
</pre>
    <pre>      <target></pre>
    <pre>        <path>$user/name</path>
</pre>
    <pre>      </target></pre>
    <pre>    </inbound>
</pre>
    <pre></attribute>
</pre>
    I have not tried this recently, but it could work.<br>
    You can still have other mappings, e.g. one to copy the email to
    $user/emailAddress etc.<br>
    <br>
    The question is how you will have set the correlation rules then...<br>
    <br>
    Regards,<br>
    Ivan<br>
    <br>
    <div class="moz-cite-prefix">On 08/30/2016 08:49 PM, mariano marron
      wrote:<br>
    </div>
    <blockquote
cite="mid:CALrFv6nKvrAKoD71-1WiYWjhLr-6E9GesegnmD_pDdynBtKtiQ@mail.gmail.com"
      type="cite">
      <div dir="ltr">
        <div>
          <div>Hi everyone, I have the following issue: I need to import
            users from a database table (I'm using the database
            resource) but first I need to see if the user in the table
            has the field "email" not null, and if it does, that's the
            name I want for my user in midpoint. If it doesn't, I user
            another field of the table (id number). I have configured
            the resource inbound mapping to map the id number to the
            name first and I was trying to set the email if not null
            with an object template, using the following mapping:<br>
            <br>
               <mapping><br>
                  <strength>weak</strength><br>
                  <source><br>
                     <name>email</name><br>
                     <c:path>$user/emailAddress</c:path><br>
                  </source><br>
                  <expression><br>
                     <script><br>
                        <language><a moz-do-not-send="true"
href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                        <code><br>
                        return email.split("@")[0]<br>
                    </code><br>
                     </script><br>
                  </expression><br>
                  <target><br>
                     <c:path>name</c:path><br>
                  </target><br>
                  <condition><br>
                     <script><br>
                        <code><br>
                            email != null<br>
                        </code><br>
                     </script><br>
                  </condition><br>
               </mapping><br>
            <br>
          </div>
          This isn't working. Any ideas why? The resource is referenced
          to the template and it's executing it when I import users (I
          see some other logic applied to the user that is created in
          midpoint), but not renaming them. Thanks in advance.<br>
          <br>
        </div>
        Mariano<br>
      </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>
    <pre class="moz-signature" cols="72">-- 
Ivan Noris
Senior Identity Engineer
evolveum.com
</pre>
  </body>
</html>