<div dir="ltr">We generate both email and username with iterationToken so it would not apply to you but I did find the below, looks sort of like yours but also has a few extra,<div><br></div><div><a href="https://github.com/Evolveum/midpoint/blob/master/model/model-intest/src/test/resources/iteration/user-template-iteration-unique-email.xml">https://github.com/Evolveum/midpoint/blob/master/model/model-intest/src/test/resources/iteration/user-template-iteration-unique-email.xml</a><br></div><div><br></div><div><br></div></div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">JASON</div></div></div>
<br><div class="gmail_quote">On Thu, Jun 23, 2016 at 9:59 AM, Martin Marchese <span dir="ltr"><<a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">To clarify, we are facing 2 different problems:<div><br></div><div>- Defining emailAddress as unique within the MidPoint schema (is this possible?), to get MidPoint return an error whenever the emailAddress already exists.</div><div><br></div><div>- Generating an unique emailAddress from the objectTemplate, but not the username.</div><div><br></div><div>Thanks in Advance</div></div><div class="gmail_extra"><span class=""><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><span></span><span></span>Ing. Martín Marchese</b><br><img src="http://www.identicum.com/img/favicon.ico">Identicum S.A.<br>Anchorena 1357 PB<br>Tel: <a href="tel:%2B54%20%2811%29%203526.5509" value="+541135265509" target="_blank">+54 (11) 3526.5509</a><br><a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a><br><a href="http://www.identicum.com" target="_blank">www.identicum.com</a></div></div></div></div></div>
<br></span><div><div class="h5"><div class="gmail_quote">On Thu, Jun 23, 2016 at 11:00 AM, Martin Marchese <span dir="ltr"><<a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Ivan,<div><br></div><div>In fact, I just need to get uniqueness in the emailAddress (I've already have username uniqueness since it's a personal ID #). The emailAddress, has nothing to do with the username in our design. Is there another way to achieve a field uniqueness?</div><div><br></div><div>Regards,</div></div><div class="gmail_extra"><span><br clear="all"><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><b><span></span><span></span>Ing. Martín Marchese</b><br><img src="http://www.identicum.com/img/favicon.ico">Identicum S.A.<br>Anchorena 1357 PB<br>Tel: <a href="tel:%2B54%20%2811%29%203526.5509" value="+541135265509" target="_blank">+54 (11) 3526.5509</a><br><a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a><br><a href="http://www.identicum.com" target="_blank">www.identicum.com</a></div></div></div></div></div>
<br></span><div><div><div class="gmail_quote">On Thu, Jun 23, 2016 at 3:23 AM, Ivan Noris <span dir="ltr"><<a href="mailto:ivan.noris@evolveum.com" target="_blank">ivan.noris@evolveum.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Hi Martin,<br>
    <br>
    my guess is that you are using object template, where name is not
    generated using iterationToken. I have searched our samples for the
    object template you've pasted and found one - possibly the same.<br>
    <br>
    The iterationToken in emailAddress will be non-empty only if the
    iterator was used to generate the unique name.<br>
    So, for example, if I tried to create one user called identicum01
    (given: John, family: Smith) and another user called identicum02
    (given: John, family: Smith), the usernames are unique, so the
    emailAddress attribute will both contain empty iterationToken, which
    is indeed not expected. The iterationToken is only used when you
    have configured the mapping for user/name attribute to use it. And
    then you can use iterationToken also in other mappings.<br>
    <br>
    If user/name is generated from given and family names,
    iterationToken would be used for both user/name values, and the same
    value would then be used in the emailAddress. The iterationToken is
    single-value attribute stored in User object and triggered only if
    the username is not unique and the mapping for user/name is using
    the iterationToken.<br>
    <br>
    See my attached object template; I've just tried it with the
    following use case:<br>
    1. create new user in midPoint, givenName: John, familyName: Smith,
    password: whatever. No name attribute filled. Save.<br>
    Username JSmith was generated, <a href="mailto:emailAddress=JSmith@domain.com" target="_blank">emailAddress=JSmith@domain.com</a><br>
    2. create new user in midPoint, givenName: John, familyName: Smith,
    password: whatever. No name attribute filled. Save.<br>
    Username JSmith1 was generated, <a href="mailto:emailAddress=JSmith1@domain.com" target="_blank">emailAddress=JSmith1@domain.com</a><br>
    <br>
    I think this is what you were trying to achieve.<br>
    Of course you need to specify the mapping strength as normal or
    strong if you wish to generate new user/name and user/emailAddress
    whenever user is renamed. If you don't need this, and only wish to
    set it for the very first time, weak is OK.<br>
    <br>
    See also <a href="https://jira.evolveum.com/browse/MID-1977" target="_blank">https://jira.evolveum.com/browse/MID-1977</a><br>
    <br>
    Regards,<br>
    Ivan<br>
    <br>
    <objectTemplate
    xmlns=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a><br>
                   
xmlns:icfs=<a href="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"</a><br>
                   
    xmlns:t=<a href="http://prism.evolveum.com/xml/ns/public/types-3" target="_blank">"http://prism.evolveum.com/xml/ns/public/types-3"</a><br>
                   
    xmlns:c=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/common/common-3"</a><br>
                   
    xmlns:q=<a href="http://prism.evolveum.com/xml/ns/public/query-3" target="_blank">"http://prism.evolveum.com/xml/ns/public/query-3"</a><br>
                   
xmlns:ri=<a href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" target="_blank">"http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"</a><br>
                    oid="c0c010c0-d34d-b33f-f00d-777222222333"<br>
                    version="1"><span><br>
       <name>User Template CSV sync</name><br></span>
       <description><br>
                Alternative User Template Object.<br>
                This object is used when creating a new account, to set
    it up as needed.<br>
                    </description><br>
       <metadata><br>
         
<createTimestamp>2016-06-23T08:14:13.745+02:00</createTimestamp><br>
          <creatorRef oid="00000000-0000-0000-0000-000000000002"
    type="c:UserType"><!-- administrator --></creatorRef><br>
         
<createChannel><a href="http://midpoint.evolveum.com/xml/ns/public/model/channels-3#objectImport" target="_blank">http://midpoint.evolveum.com/xml/ns/public/model/channels-3#objectImport</a></createChannel><br>
       </metadata><span><br>
       <iteration><br>
          <maxIterations>10</maxIterations><br>
          <tokenExpression><br>
             <script><br>
                <code><br>
              if (iteration == 0) {<br>
                return "";<br>
              } else {<br>
                return ""+iteration;<br>
              }<br>
            </code><br>
             </script><br>
          </tokenExpression><br>
       </iteration><br></span>
       <mapping><br>
          <description><br>
                    Property mapping.<br>
                    Defines how properties of user object are set up.<br>
                    This specific definition sets a full name as a
    concatenation<br>
                    of givenName and familyName.<br>
                            </description><br>
          <strength>weak</strength><br>
          <source><br>
             <c:path>$user/givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>$user/familyName</c:path><span><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br></span>
                                                    givenName + ' ' +
    familyName<br>
                                            </code><br>
             </script><br>
          </expression><br>
          <target><br>
             <c:path>fullName</c:path><br>
          </target><br>
       </mapping><span><br>
       <mapping><br>
          <strength>weak</strength><br>
          <source><br></span>
             <c:path>givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>familyName</c:path><span><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br>
              def givenNameStr = ''+givenName<br>
              givenNameStr.substring(0,1) + '' + familyName +
    iterationToken + '@<a href="http://domain.com" target="_blank">domain.com</a>'<br>
            </code><br>
             </script><br>
          </expression><br>
          <target><br></span>
             <c:path>$user/emailAddress</c:path><br>
          </target><br>
       </mapping><span><br>
       <mapping><br>
          <strength>weak</strength><br>
          <source><br></span>
             <c:path>givenName</c:path><br>
          </source><br>
          <source><br>
             <c:path>familyName</c:path><span><br>
          </source><br>
          <expression><br>
             <script><br>
               
<language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language><br>
                <code><br>
              def givenNameStr = ''+givenName<br>
              givenNameStr.substring(0,1) + '' + familyName +
    iterationToken<br></span>
            </code><br>
             </script><br>
          </expression><br>
          <target><br>
             <c:path>$user/name</c:path><br>
          </target><br>
       </mapping><br>
    </objectTemplate><div><div><br>
    <br>
    <div>On 06/22/2016 07:03 PM, Martin Marchese
      wrote:<br>
    </div>
    </div></div><blockquote type="cite"><div><div>
      <div dir="ltr">Hi all,
        <div><br>
        </div>
        <div>I have an Object Template for users, and since I need email
          to be unique, I defined an iteration on it:</div>
        <div><br>
        </div>
        <div>
          <div><i><font color="#999999"><objectTemplate
                oid="c0c010c0-d34d-b33f-f00d-777222222333"></font></i></div>
          <div><i><font color="#999999">  <name>User Template CSV
                sync</name></font></i></div>
          <div><i><font color="#999999">  <iteration></font></i></div>
          <div><i><font color="#999999">   
                <maxIterations>10</maxIterations></font></i></div>
          <div><i><font color="#999999">    <tokenExpression></font></i></div>
          <div><i><font color="#999999">      <script></font></i></div>
          <div><i><font color="#999999">        <code></font></i></div>
          <div><i><font color="#999999">          if (iteration == 0) {</font></i></div>
          <div><i><font color="#999999">            return "";</font></i></div>
          <div><i><font color="#999999">          } else {</font></i></div>
          <div><i><font color="#999999">            return ""+iteration;</font></i></div>
          <div><i><font color="#999999">          }</font></i></div>
          <div><i><font color="#999999">        </code></font></i></div>
          <div><i><font color="#999999">      </script></font></i></div>
          <div><i><font color="#999999">    </tokenExpression></font></i></div>
          <div><i><font color="#999999">  </iteration></font></i></div>
        </div>
        <div><i><font color="#999999">...</font></i></div>
        <div><i><font color="#999999">...</font></i></div>
        <div><i><font color="#999999"><br>
            </font></i></div>
        <div><font color="#000000">And then within the emailAddress
            mapping:</font></div>
        <div><font color="#000000"><br>
          </font></div>
        <div><font>
            <div style="color:rgb(153,153,153);font-style:italic"><mapping></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <strength>weak</strength></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <source></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>givenName</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </source></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <source></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>familyName</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </source></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <expression></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <script></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                <language><a href="http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy" target="_blank">http://midpoint.evolveum.com/xml/ns/public/expression/language#Groovy</a></language></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                <code></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                  def givenNameStr = ''+givenName</div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                  givenNameStr.substring(0,1) + '' + familyName +
              iterationToken + '@<a href="http://domain.com" target="_blank">domain.com</a>'</div>
            <div style="color:rgb(153,153,153);font-style:italic">     
                </code></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              </script></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </expression></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              <target></div>
            <div style="color:rgb(153,153,153);font-style:italic">     
              <path>$user/emailAddress</path></div>
            <div style="color:rgb(153,153,153);font-style:italic">   
              </target></div>
            <div style="color:rgb(153,153,153);font-style:italic"> 
              </mapping></div>
            <div style="color:rgb(153,153,153);font-style:italic"><br>
            </div>
            <div><font color="#000000">The problem is that whenever I
                create a user, the email is always being set as if the
                iterationToken is '' and this result on duplicate
                emailAddress attribute among users.</font></div>
            <div><font color="#000000"><br>
              </font></div>
            <div><font color="#000000">Is there something I'm doing
                wrong?</font></div>
            <div><font color="#000000"><br>
              </font></div>
            <div><font color="#000000">Thanks in Advance</font></div>
          </font></div>
        <div><br clear="all">
          <div>
            <div data-smartmail="gmail_signature">
              <div dir="ltr">
                <div>
                  <div dir="ltr"><b><span></span><span></span>Ing.
                      Martín Marchese</b><br>
                    <img src="http://www.identicum.com/img/favicon.ico">Identicum
                    S.A.<br>
                    Anchorena 1357 PB<br>
                    Tel: <a href="tel:%2B54%20%2811%29%203526.5509" value="+541135265509" target="_blank">+54 (11) 3526.5509</a><br>
                    <a href="mailto:mmarchese@identicum.com" target="_blank">mmarchese@identicum.com</a><br>
                    <a href="http://www.identicum.com" target="_blank">www.identicum.com</a></div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      </div></div><pre>_______________________________________________
midPoint mailing list
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><span><font color="#888888">
</font></span></pre><span><font color="#888888">
    </font></span></blockquote><span><font color="#888888">
    <br>
    <pre cols="72">-- 
  Ing. Ivan Noris
  Senior Identity Management Engineer & IDM Architect
  <a href="http://evolveum.com" target="_blank">evolveum.com</a>                     <a href="http://evolveum.com/blog/" target="_blank">evolveum.com/blog/</a>
  ___________________________________________________
  "Semper ID(e)M Vix."
</pre>
  </font></span></div>

<br>_______________________________________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com" target="_blank">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
midPoint mailing list<br>
<a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
<a href="http://lists.evolveum.com/mailman/listinfo/midpoint" rel="noreferrer" target="_blank">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
<br></blockquote></div><br></div>

<br>
<font size="2"><br><br>CONFIDENTIALITY NOTICE:<br>This e-mail together with any attachments is proprietary and confidential; intended for only the recipient(s) named above and may contain information that is privileged. You should not retain, copy or use this e-mail or any attachments for any purpose, or disclose all or any part of the contents to any person. Any views or opinions expressed in this e-mail are those of the author and do not represent those of the Baptist School of Health Professions. If you have received this e-mail in error, or are not the named recipient(s), you are hereby notified that any review, dissemination, distribution or copying of this communication is prohibited by the sender and to do so might constitute a violation of the Electronic Communications Privacy Act, 18 U.S.C. section 2510-2521. Please immediately notify the sender and delete this e-mail and any attachments from your computer. </font><br>