<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Verdana;
panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
color:black;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:#0B6CDA;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Vorformatiert Zchn";
margin:0cm;
font-size:10.0pt;
font-family:"Courier New";
color:black;}
span.HTMLVorformatiertZchn
{mso-style-name:"HTML Vorformatiert Zchn";
mso-style-priority:99;
mso-style-link:"HTML Vorformatiert";
font-family:Consolas;
color:black;}
span.E-MailFormatvorlage21
{mso-style-type:personal-reply;
font-family:"Verdana",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="DE-CH" link="#0B6CDA" vlink="#551A8B" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US">Hi Sven,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US">Thank you for your Code snippet. I have used it, but it did not worked for me because this query did not returned the
org managers for me.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US">But in the meantime, one of my colleagues (thank you Marie) has created a solution for me that works perfect for “Manager
Approval”.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<pre style="background:white"><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">role </span><span lang="EN-US" style="color:#174AD4">xmlns</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3"><span lang="EN-US">http://midpoint.evolveum.com/xml/ns/public/common/common-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">c</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3"><span lang="EN-US">http://midpoint.evolveum.com/xml/ns/public/common/common-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">icfs</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3"><span lang="EN-US">http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">org</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://midpoint.evolveum.com/xml/ns/public/common/org-3"><span lang="EN-US">http://midpoint.evolveum.com/xml/ns/public/common/org-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">q</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://prism.evolveum.com/xml/ns/public/query-3"><span lang="EN-US">http://prism.evolveum.com/xml/ns/public/query-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">ri</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3"><span lang="EN-US">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">xmlns:</span><span lang="EN-US" style="color:#871094">t</span><span lang="EN-US" style="color:#067D17">="</span><span style="color:#067D17"><a href="http://prism.evolveum.com/xml/ns/public/types-3"><span lang="EN-US">http://prism.evolveum.com/xml/ns/public/types-3</span></a></span><span lang="EN-US" style="color:#067D17">"<br> </span><span lang="EN-US" style="color:#174AD4">oid</span><span lang="EN-US" style="color:#067D17">="5a9ece69-86ca-4e29-8457-c080287dac35"</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">name</span><span lang="EN-US" style="color:#080808">>Manager Approval Metarole</</span><span lang="EN-US" style="color:#0033B3">name</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">description</span><span lang="EN-US" style="color:#080808">>Manager Approval is Metarole, used to find the manager that has to approve the request</</span><span lang="EN-US" style="color:#0033B3">description</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">displayName</span><span lang="EN-US" style="color:#080808">>Manager Approval Metarole</</span><span lang="EN-US" style="color:#0033B3">displayName</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">inducement </span><span lang="EN-US" style="color:#174AD4">id</span><span lang="EN-US" style="color:#067D17">="10"</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">policyRule</span><span lang="EN-US" style="color:#080808">><br></span><i><span lang="EN-US" style="color:#8C8C8C"> </span></i><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">policyConstraints</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">assignment </span><span lang="EN-US" style="color:#174AD4">id</span><span lang="EN-US" style="color:#067D17">="11"</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">operation</span><span lang="EN-US" style="color:#080808">>add</</span><span lang="EN-US" style="color:#0033B3">operation</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">assignment</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">policyConstraints</span><span lang="EN-US" style="color:#080808">><br></span><i><span lang="EN-US" style="color:#8C8C8C"> </span></i><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">policyActions</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">approval </span><span lang="EN-US" style="color:#174AD4">id</span><span lang="EN-US" style="color:#067D17">="12"</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">compositionStrategy</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">order</span><span lang="EN-US" style="color:#080808">>10</</span><span lang="EN-US" style="color:#0033B3">order</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">compositionStrategy</span><span lang="EN-US" style="color:#080808">><br></span><i><span lang="EN-US" style="color:#8C8C8C"> </span></i><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">approvalSchema</span><span lang="EN-US" style="color:#080808">><br></span><i><span lang="EN-US" style="color:#8C8C8C"> </span></i><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">stage </span><span lang="EN-US" style="color:#174AD4">id</span><span lang="EN-US" style="color:#067D17">="13"</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">name</span><span lang="EN-US" style="color:#080808">>Line managers</</span><span lang="EN-US" style="color:#0033B3">name</span><span lang="EN-US" style="color:#080808">><o:p></o:p></span></pre>
<pre style="background:white"><i><span lang="EN-US" style="color:#8C8C8C"> <!-- Autoapproval if requestor is manager of target user --><br> </span></i><span lang="EN-US" style="color:#080808"><</span><span lang="EN-US" style="color:#0033B3">automaticallyCompleted</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">script</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">code</span><span lang="EN-US" style="color:#080808">><span style="background:#EDFCED"><br> actorOid = actor.getOid()<br> managerOids = midpoint.getManagersOidsExceptUser(object)<br> for (managerOid in managerOids) {<br> if (managerOid == actorOid) {<br> return com.evolveum.midpoint.schema.constants.SchemaConstants.MODEL_APPROVAL_OUTCOME_APPROVE;<br> }<br> }<br> return null<br> </span></</span><span lang="EN-US" style="color:#0033B3">code</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">script</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">automaticallyCompleted</span><span lang="EN-US" style="color:#080808">><o:p></o:p></span></pre>
<pre style="background:white"><i><span lang="EN-US" style="color:#8C8C8C"> <!—Find all managers for approval --><br></span></i><span lang="EN-US" style="color:#080808"> <</span><span lang="EN-US" style="color:#0033B3">approverExpression</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">script</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">code</span><span lang="EN-US" style="color:#080808">><span style="background:#EDFCED">midpoint.getManagersOidsExceptUser(object)</span></</span><span lang="EN-US" style="color:#0033B3">code</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">script</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">approverExpression</span><span lang="EN-US" style="color:#080808">><br> <</span><span lang="EN-US" style="color:#0033B3">outcomeIfNoApprovers</span><span lang="EN-US" style="color:#080808">>reject</</span><span lang="EN-US" style="color:#0033B3">outcomeIfNoApprovers</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">stage</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">approvalSchema</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">approval</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">policyActions</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">policyRule</span><span lang="EN-US" style="color:#080808">><br> </</span><span lang="EN-US" style="color:#0033B3">inducement</span><span lang="EN-US" style="color:#080808">><br></</span><span lang="EN-US" style="color:#0033B3">role</span><span lang="EN-US" style="color:#080808">><o:p></o:p></span></pre>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div>
<p class="MsoNormal"><span lang="EN-US">Thanky you again for your help.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US">Regards Patrik<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:windowtext;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="color:windowtext">Von:</span></b><span lang="EN-US" style="color:windowtext"> midPoint <midpoint-bounces@lists.evolveum.com>
<b>Im Auftrag von </b>Sven Feyerabend via midPoint<br>
</span><b><span lang="DE" style="color:windowtext">Gesendet:</span></b><span lang="DE" style="color:windowtext"> Montag, 24. April 2023 14:13<br>
<b>An:</b> Patrik Sidler via midPoint <midpoint@lists.evolveum.com><br>
<b>Cc:</b> Sven Feyerabend <Sven.Feyerabend@stuvus.uni-stuttgart.de><br>
<b>Betreff:</b> Re: [midPoint] How to suppress manager approval of role, when the manager requests the role<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi Patrik,<o:p></o:p></p>
<p>I solved this by using a custom query and checking if the actor is also an approver:<o:p></o:p></p>
<p><o:p> </o:p></p>
<pre><approverExpression><o:p></o:p></pre>
<pre> <script><o:p></o:p></pre>
<pre> <code><o:p></o:p></pre>
<pre> import com.evolveum.midpoint.xml.ns._public.common.common_3.*;<o:p></o:p></pre>
<pre> import com.evolveum.midpoint.schema.constants.RelationTypes;<o:p></o:p></pre>
<pre> import com.evolveum.midpoint.schema.util.ObjectTypeUtil;<o:p></o:p></pre>
<pre> import java.util.stream.Collectors;<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> prismContext = midpoint.getPrismContext();<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> actorOid = actor.getOid();<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> approverQuery = prismContext.queryFor(UserType.class)<o:p></o:p></pre>
<pre> .ref(FocusType.F_PARENT_ORG_REF, OrgType.COMPLEX_TYPE, RelationTypes.MANAGER.getRelation(), target.getOid()).all()<o:p></o:p></pre>
<pre> .build();<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> List approvers = midpoint.searchObjects(UserType.class, approverQuery);<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> for(approver in approvers){<o:p></o:p></pre>
<pre> if(approver.getOid() == actorOid){<o:p></o:p></pre>
<pre> return null;<o:p></o:p></pre>
<pre> }<o:p></o:p></pre>
<pre> }<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> return approvers.stream().map(obj -> ObjectTypeUtil.createObjectRef(obj,prismContext)).collect(Collectors.toList());<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre> </code><o:p></o:p></pre>
<pre> </script><o:p></o:p></pre>
<pre></approverExpression><o:p></o:p></pre>
<p><o:p> </o:p></p>
<div>
<p class="MsoNormal">This may not be the best solution, but I didn't find a better one.<br>
So if someone knows a better way, feel free to correct me.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Kind Regards<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Sven<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Am 18.04.23 um 15:21 schrieb Patrik Sidler via midPoint:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<pre>Hi Community,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>I have an issue and do not know how to get this solved.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>We have several roles created that have a "Manager Approval" metarole assigned to it.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre><role oid="5a9ece69-86ca-4e29-8457-c080287dac35"><o:p></o:p></pre>
<pre> <name>Manager Approval Metarole</name><o:p></o:p></pre>
<pre> <inducement id="10"><o:p></o:p></pre>
<pre> <policyRule><o:p></o:p></pre>
<pre> <policyConstraints><o:p></o:p></pre>
<pre> <assignment id="11"><o:p></o:p></pre>
<pre> <operation>add</operation><o:p></o:p></pre>
<pre> </assignment><o:p></o:p></pre>
<pre> </policyConstraints><o:p></o:p></pre>
<pre> <policyActions><o:p></o:p></pre>
<pre> <approval id="12"><o:p></o:p></pre>
<pre> <compositionStrategy><o:p></o:p></pre>
<pre> <order>10</order><o:p></o:p></pre>
<pre> </compositionStrategy><o:p></o:p></pre>
<pre> <approvalSchema><o:p></o:p></pre>
<pre> <stage id="13"><o:p></o:p></pre>
<pre> <name>Line managers</name><o:p></o:p></pre>
<pre> <approverExpression><o:p></o:p></pre>
<pre> <script><o:p></o:p></pre>
<pre> <code>midpoint.getManagersOidsExceptUser(object)</code><o:p></o:p></pre>
<pre> </script><o:p></o:p></pre>
<pre> </approverExpression><o:p></o:p></pre>
<pre> <evaluationStrategy>firstDecides</evaluationStrategy><o:p></o:p></pre>
<pre> <outcomeIfNoApprovers>reject</outcomeIfNoApprovers><o:p></o:p></pre>
<pre> </stage><o:p></o:p></pre>
<pre> </approvalSchema><o:p></o:p></pre>
<pre> </approval><o:p></o:p></pre>
<pre> </policyActions><o:p></o:p></pre>
<pre> </policyRule><o:p></o:p></pre>
<pre> </inducement><o:p></o:p></pre>
<pre></role><o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Whenever one those roles are requested by someone, the manager of the person that receives the role has to approve the assignment.<o:p></o:p></pre>
<pre>So far so good.<o:p></o:p></pre>
<pre>But now, when my manager requests this role for me, he also has to approve this request.<o:p></o:p></pre>
<pre>How can I suppress this approval step when the requester and the approver are the same person?<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Thank you in advance for your help.<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Best regards,<o:p></o:p></pre>
<pre><o:p> </o:p></pre>
<pre>Patrik Sidler<o:p></o:p></pre>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>midPoint mailing list<o:p></o:p></pre>
<pre><a href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a><o:p></o:p></pre>
<pre><a href="https://lists.evolveum.com/mailman/listinfo/midpoint">https://lists.evolveum.com/mailman/listinfo/midpoint</a><o:p></o:p></pre>
</blockquote>
</div>
</body>
</html>