<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hello Tim,<br>
<br>
a general answer is: midPoint is change-driven. So, if you provide
a mapping based on an expression, this expression is actually
evaluated twice: On original (old) value of its input, and on
current (new) value of it. And the original value in your case is
probably considered to be null.<br>
<br>
To be exact, scripts in inbound mappings are often executed only
once, because majority of resources are not able to provide true
deltas. (They provide only the "new" state.)<br>
But even considering that, there can be situations when true
deltas are processed by inbound mappings, e.g. if the value of the
resource object attribute was set by outbound mapping first.<br>
<br>
So, although I don't know the exact reason in your case, it can be
something like that.<br>
(If you would like to be sure, just look into log file created
with MODEL logging set to TRACE; or submit it here :)<br>
<br>
Best regards,<br>
Pavol<br>
<br>
<br>
On 31. 7. 2015 21:19, <a class="moz-txt-link-abbreviated" href="mailto:Tim.Strong@sita.aero">Tim.Strong@sita.aero</a> wrote:<br>
</div>
<blockquote
cite="mid:OF596E588B.6E49A391-ON85257E93.00682911-85257E93.006A3163@sita.aero"
type="cite"><font face="sans-serif" size="2">Hi folks,</font>
<br>
<font face="sans-serif" size="2">I'm doing some scripting on an
inbound
attribute that will never be null and I'm trying to understand
why the
expression fails if I do not check for a string first.</font>
<br>
<br>
<font face="sans-serif" size="2">This works...</font>
<br>
<font face="sans-serif" size="2"><code></font>
<br>
<font face="sans-serif" size="2"> String
result = basic.stringify(input)?.size() > 0 ?
basic.stringify(input).substring(0,
basic.stringify(input).indexOf('@')):'';</font>
<br>
<font face="sans-serif" size="2"> return
result;</font>
<br>
<font face="sans-serif" size="2"> </code></font>
<br>
<br>
<br>
<font face="sans-serif" size="2">And this does *not* work...</font>
<br>
<font face="sans-serif" size="2"><code></font>
<br>
<font face="sans-serif" size="2"> String result
= basic.stringify(input).substring(0,
basic.stringify(input).indexOf('@'));</font>
<br>
<font face="sans-serif" size="2"> return result;</font>
<br>
<font face="sans-serif" size="2"></code></font>
<br>
<font face="sans-serif" size="2">... claiming the input variable
is null.</font>
<br>
<br>
<font face="sans-serif" size="2">I know it's best to always check
if
something exists before doing an operation on it, but I'm
curious as to
why it fails in this case if I do not check. I'm executing
against
the same test set of accounts both times, and they all have the
attribute
in question.</font>
<br>
<br>
<font face="sans-serif" size="2">Thanks</font>
<br>
<font face="sans-serif" size="2">Tim</font>
<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>