<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,<br>
<br>
You cannot access $account in object templates. There are several
reasons for this. And as you are not the first to ask this
question I have added an answer to our documentation:<br>
<br>
<a class="moz-txt-link-freetext" href="https://wiki.evolveum.com/display/midPoint/Object+Template">https://wiki.evolveum.com/display/midPoint/Object+Template</a><br>
<p>Object template works just with a single object which is
typically a user. Therefore it only has the data from this
object and no other objects. It means that variables such as <code>$account</code>
cannot be used in an object template. The reason for this is the
<a href="http://en.wikipedia.org/wiki/Separation_of_concerns"
data-mce-href="http://en.wikipedia.org/wiki/Separation_of_concerns">separation
of concerns</a> principle. We try to design each component or
mechanism in midPoint to do a single thing. This allows us a
significant development advantage (debugging, testing) and also
provides a better code reusability. The power of midPoint is to
have simple principles (such as object template) that used over
and over again and combined with other simple principles (such
as inbound/outbound mappings) to create a flexible and
comprehensive solution.</p>
<p>There is also another reason for <strong>not</strong>
including account in object templates. The object template may
be used even if the account is not available, e.g. when user is
changed from the GUI. MidPoint is using <a
class="confluence-link"
data-linked-resource-default-alias="Relativity"
href="https://wiki.evolveum.com/display/midPoint/Relativity"
data-linked-resource-type="page"
data-linked-resource-id="3571869"
data-base-url="https://wiki.evolveum.com">relative changes</a>
therefore it is not always required to read all the accounts to
process a change. And in fact the account may not even be
available (e.g. because resource is temporarily down). Therefore
it would be a very inconvenient and inefficient if account
attributes are used in object templates.<br>
</p>
<p>Therefore if a property from an account (or other object) is
needed in an object template there are several ways how to do
it:</p>
<ul>
<li>Use <a class="confluence-link"
data-linked-resource-default-alias="Inbound Mapping"
href="https://wiki.evolveum.com/display/midPoint/Inbound+Mapping"
data-linked-resource-type="page"
data-linked-resource-id="4423963"
data-base-url="https://wiki.evolveum.com">inbound mappings</a>
instead. Inbound mappings can compute the value and place it
directly in the user property. Inbound mappings can see both
the account and the user. And midPoint can make sure that
these mappings are executed at the right moment and are not
executed when not needed. E.g. the mappings will be executed
only when midPoint detects a change on the resource.</li>
<li>Use combination of <a class="confluence-link"
data-linked-resource-default-alias="Inbound Mapping"
href="https://wiki.evolveum.com/display/midPoint/Inbound+Mapping"
data-linked-resource-type="page"
data-linked-resource-id="4423963"
data-base-url="https://wiki.evolveum.com"
data-mce-href="https://wiki.evolveum.com/display/midPoint/Inbound+Mapping">inbound
mappings</a>, extended user properties and object template.
Use object template to the computation. Use inbound mappings
to copy data from account to the user extended properties (<code>extension</code>
part of user object). Then use the extended properties as
input in the user template. This works around the separation
of concerns boundaries. And as the extended properties are
stored with the user in midPoint repository they are always
available without the need to read the account all the time.
Inbound mappings will make sure that these data are as fresh
as possible.</li>
</ul>
<br>
<pre class="moz-signature" cols="72">--
Radovan Semancik
Software Architect
evolveum.com
</pre>
<br>
<br>
On 01/02/2014 03:11 PM, Deepak Natarajan wrote:<br>
</div>
<blockquote cite="mid:52C5739B.5060007@trilobytesystems.com"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<br>
<span><br>
Hi Ivan -<br>
<br>
Thanks - I tried with $c:input and it worked.<br>
<br>
It's a bit weird since in an object template (which I use for
post-creation assignments etc), doing it like this worked :<br>
<br>
</span><mapping><br>
<source><br>
<name>varname</name><br>
<path>varpath</path><br>
</source><br>
<expression><br>
<script><br>
<code><br>
tokenize(varname...)<br>
</code><br>
</script><br>
</expression><br>
<br>
seems to work, but this fails when I try something similar in a
resource configuration...thought it is quite possible my varpath
had an error in it...(i used $account/attributes/ri:var)<br>
<br>
but using 'input' works, thanks!<br>
<blockquote style="border: 0px none;"
cite="mid:52C571B4.9080201@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:part5.08050008.06090009@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">January
2, 2014 at 4:03 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 blind shot - try to use implicit variable named "input"
(it is mapped to the "source" of the inbound expression, in
your case, ri:orgdesc).<br>
<br>
See an example (adapted from my customer's resource) written
in Groovy (not XPath):<br>
<br>
<attribute><br>
<ref>ri:orgUnitHierarchy</ref><br>
<displayName>Organizational
Hierarchy</displayName><br>
<access>read</access><br>
<inbound><br>
<expression><br>
<script><br>
<code><br>
String[] tmpHierarchyList = <b>input</b> ? <b>input</b>?.split('\\.')
: []<br>
tmpHierarchyListNew = []<br>
<br>
<!-- some processing skipped here . . . --><br>
<br>
return tmpHierarchyListNew.join(':')<br>
</code><br>
</script><br>
</expression><br>
<target><br>
<path>$user/extension/mycustomer:ouPath</path><br>
</target><br>
</inbound><br>
</attribute><br>
<br>
I do not use XPath in expressions unless absolutely necessary
because the debugging is quite _challenging_ ;) and it's lot
easier to debug Groovy statements.<br>
<br>
Regards,<br>
Ivan<br>
<br>
<div class="moz-cite-prefix">On 01/02/2014 02:50 PM, Deepak
Natarajan wrote:<br>
</div>
<br>
<div>-- <br>
Ing. Ivan Noris<br>
Consultant<br>
Evolveum, s.r.o<br>
___________________________________________________<br>
"Semper cautus - semper paratus - 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:part5.08050008.06090009@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">January
2, 2014 at 3:50 PM</span></font></div>
</div>
</div>
<div style="color:#888888;margin-left:24px;margin-right:24px;"
__pbrmquotes="true" class="__pbConvBody">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<br>
Hi -<br>
<br>
I'm struggling with a simple evaluation (I've removed
namespace declarations for readability) :<br>
<br>
<attribute><br>
<ref><span style="font-weight:
bold;">ri:orgdesc</span></ref><br>
<inbound><br>
<expression><br>
<script><br>
<language><a
moz-do-not-send="true" href="http://www.w3.org/TR/xpath/"
class="moz-txt-link-freetext">http://www.w3.org/TR/xpath/</a></language><br>
<code ...><br>
tokenize($account/attributes/ri:orgdesc,"/")[last()]<br>
</code><br>
</script><br>
</expression><br>
<target><br>
<path>$user/extension/apos:aposUnitAttributes</path><br>
</target><br>
</inbound><br>
</attribute><br>
<br>
I've tried everything, but the variable passed to the XPath
tokenize function is always nil (I know the function works
correctly, since I use it elsewhere, and using a literal
string above produces the correct results)<br>
<br>
I've tried including a <source> before the expression
with an explicit <name> but that doesn't seem to work
either.<br>
<br>
Thanks for any input! - I'm using build <span>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
Version: 2.3-SNAPSHOT, describe: git-v2.3devel-383-g6ef8f72
</span><br>
<br>
BR/Deepak<br>
<br>
</div>
</blockquote>
<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>