<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Hi Deepak,<br>
      <br>
      That's correct. iteration and iterationToken variables are only
      available in outbound expressions and in object template. But
      these are slightly different things. The iterationToken in
      outbound expression applied to accounts (or other resource
      objects). The iterationToken in object template applies to focal
      objects such as users and roles. These are independently used and
      independently incremented. This how it make sense to us: you may
      want to use iterationToken to find unique account name then use
      the one in outbound expressions. If you want to determine a unique
      name for user then use the iterationToken in user template.<br>
      <br>
      IterationToken in inbound expressions does not make much sense to
      me. The target of inbound expressions is focal object (e.g. user).
      Therefore it it just cannot be the same thing as iterationToken in
      outbound expression. The other thing is that midPoint needs to
      have a complete user to determine whether it is unique or not.
      Currently we check only uniqueness of user's name. But that will
      change in the future and you should be able to set uniqueness
      constraint on any property. Therefore we will need a complete user
      before we check uniqueness. And we also need an ability to
      recompute the expressions again and again until we find a unique
      combination. And this can only be done efficiently in the object
      template. Therefore the iterationToken is in the object template
      and not in inbound expressions. Oh yes, we could theoretically
      recompute all the inbound expressions in all the resources ... but
      that is just too much recomputation and it would complicate the
      code. Especially if resource dependencies are used. Therefore we
      have decided that having iterationToken just in object template is
      OK.<br>
      <br>
      However there are "tricks" how to use the iterationTokens almost
      everywhere. It is mostly passing it as an extension property. Or
      pre-computing some "stem" names in object template and placing
      these in the extension and then use them in outbound expressions.
      Similarly you can pass pass interim values from inbound to user
      extension and the use object template to iterate and find unique
      combination. There are many ways. We haven't found a use case that
      we could not easily implement with this approach. Maybe if you
      could describe your specific use case we can help you with your
      configuration.<br>
      <br>
      <pre class="moz-signature" cols="72">-- 

                                           Radovan Semancik
                                          Software Architect
                                             evolveum.com
</pre>
      <br>
      <br>
      On 07/01/2014 02:46 PM, Deepak Natarajan wrote:<br>
    </div>
    <blockquote cite="mid:53B2ADB2.5030909@trilobytesystems.com"
      type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <br>
      Hi Ivan -<br>
      <br>
      Thanks - yes, this is the first time I am trying using the script
      var in inbound mappings as well - apparently Midpoint doesn't like
      it - so I will have to do it in a template (like in your previous
      examples). I was already setting the user name in an inbound
      expression - just needed the iteration token to resolve conflicts.
      <br>
      <br>
      I already have your example - I was just trying to move it into
      the schema handling, rather than the object template, so I'll just
      do it like you did.<br>
      <br>
      Thanks!<br>
      <br>
      BR/Deepak<br>
      <br>
      <blockquote style="border: 0px none;"
        cite="mid:53B29BA5.2080101@evolveum.com" type="cite">
        <div style="margin:30px 25px 10px 25px;" class="__pbConvHr">
          <div style="display:table;width:100%;border-top:1px solid
            #EDEEF0;padding-top:5px">
            <div
              style="display:table-cell;vertical-align:middle;padding-right:6px;"><img
                photoaddress="ivan.noris@evolveum.com" photoname="Ivan
                Noris" src="cid:part1.00000609.06010200@evolveum.com"
                name="compose-unknown-contact.jpg" height="25px"
                width="25px"></div>
            <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
              <a moz-do-not-send="true"
                href="mailto:ivan.noris@evolveum.com"
                style="color:#737F92
                !important;padding-right:6px;font-weight:bold;text-decoration:none
                !important;">Ivan Noris</a></div>
            <div
              style="display:table-cell;white-space:nowrap;vertical-align:middle;">
              <font color="#9FA2A5"><span style="padding-left:6px">July
                  1, 2014 at 2:29 PM</span></font></div>
          </div>
        </div>
        <div style="color:#888888;margin-left:24px;margin-right:24px;"
          __pbrmquotes="true" class="__pbConvBody">
          <meta http-equiv="Content-Type" content="text/html;
            charset=ISO-8859-1">
          Hi Deepak,<br>
          <br>
          just a note from a practice: I've never used iterations on
          inbound. But you can use them in object template to generate
          (for example) unique user/name property.<br>
          <br>
          So in a few words, you would not set user/name from inbound
          expressions, but you would compute it from object template.<br>
          <br>
          I believe I've dropped some example to the list before, if
          not, I can drop one later today if you're interested.<br>
          <br>
          Regards<br>
          <br>
          Ivan<br>
          <br>
          <div class="moz-cite-prefix">On 07/01/2014 12:41 PM, Deepak
            Natarajan wrote:<br>
          </div>
          <br>
          <div>-- <br>
            Ing. Ivan Noris<br>
            Senior Identity Management Engineer<br>
            evolveum.com<br>
            ___________________________________________<br>
            "Idem per idem - semper idem Vix."<br>
          </div>
          <div>_______________________________________________<br>
            midPoint mailing list<br>
            <a moz-do-not-send="true" class="moz-txt-link-abbreviated"
              href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><br>
            <a moz-do-not-send="true" class="moz-txt-link-freetext"
              href="http://lists.evolveum.com/mailman/listinfo/midpoint">http://lists.evolveum.com/mailman/listinfo/midpoint</a><br>
          </div>
        </div>
        <div style="margin:30px 25px 10px 25px;" class="__pbConvHr">
          <div style="display:table;width:100%;border-top:1px solid
            #EDEEF0;padding-top:5px">
            <div
              style="display:table-cell;vertical-align:middle;padding-right:6px;"><img
                photoaddress="dnataraj@trilobytesystems.com"
                photoname="Deepak Natarajan"
                src="cid:part1.00000609.06010200@evolveum.com"
                name="compose-unknown-contact.jpg" height="25px"
                width="25px"></div>
            <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
              <a moz-do-not-send="true"
                href="mailto:dnataraj@trilobytesystems.com"
                style="color:#737F92
                !important;padding-right:6px;font-weight:bold;text-decoration:none
                !important;">Deepak Natarajan</a></div>
            <div
              style="display:table-cell;white-space:nowrap;vertical-align:middle;">
              <font color="#9FA2A5"><span style="padding-left:6px">July
                  1, 2014 at 1:41 PM</span></font></div>
          </div>
        </div>
        <div style="color:#888888;margin-left:24px;margin-right:24px;"
          __pbrmquotes="true" class="__pbConvBody">
          <meta http-equiv="Content-Type" content="text/html;
            charset=ISO-8859-1">
          <br>
          Hmmm. Looking at the documentation again, it seems inbound
          mappings are mentioned nowhere.<br>
          <br>
          Are these iteration tokens only valid for outbound mappings
          (i.e should I move this usage on inbound mappings to a user
          creation template?)<br>
          <br>
          Why is this so....? <br>
          <br>
          <br>
        </div>
        <div style="margin:30px 25px 10px 25px;" class="__pbConvHr">
          <div style="display:table;width:100%;border-top:1px solid
            #EDEEF0;padding-top:5px">
            <div
              style="display:table-cell;vertical-align:middle;padding-right:6px;"><img
                photoaddress="dnataraj@trilobytesystems.com"
                photoname="Deepak Natarajan"
                src="cid:part1.00000609.06010200@evolveum.com"
                name="compose-unknown-contact.jpg" height="25px"
                width="25px"></div>
            <div
style="display:table-cell;white-space:nowrap;vertical-align:middle;width:100%">
              <a moz-do-not-send="true"
                href="mailto:dnataraj@trilobytesystems.com"
                style="color:#737F92
                !important;padding-right:6px;font-weight:bold;text-decoration:none
                !important;">Deepak Natarajan</a></div>
            <div
              style="display:table-cell;white-space:nowrap;vertical-align:middle;">
              <font color="#9FA2A5"><span style="padding-left:6px">July
                  1, 2014 at 1:37 PM</span></font></div>
          </div>
        </div>
        <div style="color:#888888;margin-left:24px;margin-right:24px;"
          __pbrmquotes="true" class="__pbConvBody">
          <div>Hi -<br>
            <br>
            I'm trying to formulate unique uid's for the user on an
            inbound mapping.<br>
            I am using iterationToken (I am using a snippet from one of
            Ivan's<br>
            examples).<br>
            <br>
            This is my attribute mapping<br>
            <br>
            <attribute><br>
            <ref>icfs:name</ref><br>
            <limitations><br>
            <minOccurs>0</minOccurs><br>
            <access><br>
            <read>true</read><br>
            <add>true</add><br>
            <modify>true</modify><br>
            </access><br>
            </limitations><br>
            <inbound><br>
            <c:expression><br>
            <c:script><br>
            <c:code><br>
            input + '-apos' + iterationToken<br>
            </c:code><br>
            </c:script><br>
            </c:expression><br>
            <target><br>
            <path>$user/name</path><br>
            </target><br>
            </inbound><br>
            </attribute><br>
            <br>
            followed by the iteration definition :<br>
            <br>
            <iteration><br>
            <maxIterations>999</maxIterations><br>
            <tokenExpression><br>
            <script><br>
            <code><br>
            if (iteration == 0) {<br>
            return "";<br>
            } else {<br>
            return "" + (iteration + 1)<br>
            }<br>
            </code><br>
            </script><br>
            </tokenExpression><br>
            </iteration><br>
            <br>
            I am getting the following exception, when I import users :<br>
            <br>
            Caused by:<br>
com.evolveum.midpoint.util.exception.ExpressionEvaluationException:<br>
            groovy.lang.MissingPropertyException: No such property:
            iterationToken<br>
            for class: Script17 expression in mapping in inbound
            expression for<br>
            {<a moz-do-not-send="true" class="moz-txt-link-freetext"
href="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3">http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3</a>}name<br>
            in <a moz-do-not-send="true" class="moz-txt-link-freetext"
href="resource:036f0100-2fe8-49e1-a8fd-5548374f8703%28APOS">resource:036f0100-2fe8-49e1-a8fd-5548374f8703(APOS</a>
            CSV Feeder<br>
            Resource Definition)<br>
            at<br>
com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:124)<br>
            ~[model-common-3.0.jar:na]<br>
            at<br>
com.evolveum.midpoint.model.common.expression.script.ScriptExpression.evaluate(ScriptExpression.java:108)<br>
            ~[model-common-3.0.jar:na]<br>
            at<br>
com.evolveum.midpoint.model.common.expression.script.ScriptExpressionEvaluator.transformSingleValue(ScriptExpressionEvaluator.java:58)<br>
            ~[model-common-3.0.jar:na]<br>
            at<br>
com.evolveum.midpoint.model.common.expression.evaluator.AbstractValueTransformationExpressionEvaluator$1.process(AbstractValueTransformationExpressionEvaluator.java:420)<br>
            ~[model-common-3.0.jar:na]<br>
            ... 50 common frames omitted<br>
            Caused by: javax.script.ScriptException:<br>
            groovy.lang.MissingPropertyException: No such property:
            iterationToken<br>
            for class: Script17<br>
            at<br>
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:323)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            at<br>
org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:41)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            at javax.script.CompiledScript.eval(CompiledScript.java:92)<br>
            ~[na:1.7.0_45]<br>
            at<br>
com.evolveum.midpoint.model.common.expression.script.jsr223.Jsr223ScriptEvaluator.evaluate(Jsr223ScriptEvaluator.java:122)<br>
            ~[model-common-3.0.jar:na]<br>
            ... 53 common frames omitted<br>
            Caused by: groovy.lang.MissingPropertyException: No such
            property:<br>
            iterationToken for class: Script17<br>
            at<br>
org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            at<br>
org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            at<br>
org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            at Script17.run(Script17.groovy:2) ~[na:na]<br>
            at<br>
org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:320)<br>
            ~[groovy-1.8.6.jar:1.8.6]<br>
            ... 56 common frames omitted<br>
            <br>
            I seem to be following the general guidelines here :<br>
            <a moz-do-not-send="true" class="moz-txt-link-freetext"
href="https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO">https://wiki.evolveum.com/display/midPoint/Unique+Account+Username+HOWTO</a><br>
            <br>
            Am I missing something?<br>
            <br>
            Thanks in advance -<br>
            BR/Deepak<br>
            <br>
            <br>
            <br>
            <br>
          </div>
        </div>
      </blockquote>
      <br>
      <div class="moz-signature">-- <br>
        Deepak Natarajan<br>
        Director<br>
        <br>
        Trilobyte Systems ApS<br>
        <br>
        Falkoner Alle 1, 3            Frederikinkatu 61A, 6th Floor<br>
        2000 Frederiksberg         Business Center Papula<br>
        Denmark                          00100 Helsinki<br>
                                                Finland<br>
        <br>
        Tel : +45 29375068<br>
        <a moz-do-not-send="true" class="moz-txt-link-freetext"
          href="http://www.trilobytesystems.com">http://www.trilobytesystems.com</a><br>
        <br>
        <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>
    <br>
  </body>
</html>