<div style="font-family: Arial, sans-serif; font-size: 14px;">Hi,</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">thanks again Patrik. Your example gave me enough clues to be able to successfully implement the "hook".</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Had a lot of debug-lines to figure out what was going on. And, well... the hook is definitely called a lot, so I think I'll take another look at the role-solution you included.</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;">Anyway, this is what I ended up with and seems to be working fine:</div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><span><hook></span><div><span> <name>Remove assignments from disabled users</name></span></div><div><span> <state>final</state></span></div><div><span> <focusType>c:UserType</focusType></span></div><div><span> <script></span></div><div><span> <code></span></div><div><span> import com.evolveum.midpoint.xml.ns._public.common.common_3.*</span></div><div><span> import com.evolveum.midpoint.prism.delta.builder.*</span></div><div><br></div><div><span> UserType user = (UserType) focus;</span></div><div><span> ActivationStatusType administrativeStatus = user.getActivation().getEffectiveStatus();</span></div><div><span> if (administrativeStatus == ActivationStatusType.DISABLED) {</span></div><div><span> ArrayList assignmentsToDelete = []</span></div><div><span> for (AssignmentType assign : user.getAssignment()) {</span></div><div><span> if (assign.getTargetRef().getType().toString().toLowerCase().contains('roletype') ){</span></div><div><span> AssignmentType removeAssignment = new AssignmentType()</span></div><div><span> <a target="_blank" rel="noreferrer nofollow noopener" href="http://removeAssignment.id">removeAssignment.id</a> = <a target="_blank" rel="noreferrer nofollow noopener" href="http://assign.id">assign.id</a></span></div><div><span> assignmentsToDelete.add(removeAssignment.asPrismContainerValue())</span></div><div><span> }</span></div><div><span> }</span></div><div><span> if (!assignmentsToDelete.empty){</span></div><div><span> <a target="_blank" rel="noreferrer nofollow noopener" href="http://log.info">log.info</a>("Assignments to delete because user is no longer ENABLED: " + assignmentsToDelete)</span></div><div><span> def delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).delete(assignmentsToDelete).asObjectDelta(user.oid)</span></div><div><span> midpoint.modifyObject(delta)</span></div><div><span> }</span></div><div><span> }</span></div><div><span> </code></span></div><div><span> </script></span></div><div><span></hook></span></div><span></span><br></div><div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div>
<div class="protonmail_signature_block" style="font-family: Arial, sans-serif; font-size: 14px;">
<div class="protonmail_signature_block-user">
Markus Calmius<br>Proton AG
</div>
<div class="protonmail_signature_block-proton protonmail_signature_block-empty">
</div>
</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;"><br></div><div class="protonmail_quote">
------- Original Message -------<br>
On Thursday, October 12th, 2023 at 14:48, Patrik Sidler <patrik.sidler@itconcepts.ch> wrote:<br><br>
<blockquote class="protonmail_quote" type="cite">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US">Hi Markus,</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US">In our Environment, every user is either internal, external or disabled. We have created an Role for every Type of user.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US">The Role for Internal and External Employees induces the ArcheType and assigns a policy, that removes all assigned Roles if the Users
moves from internal/external to disabled.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US">Here is the Role we assign to Internal Employees:</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"><role xmlns=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/common/common-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:c=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/common/common-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:icfs=<a href="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:org=<a href="http://midpoint.evolveum.com/xml/ns/public/common/org-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/common/org-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:q=<a href="http://prism.evolveum.com/xml/ns/public/query-3" rel="noreferrer nofollow noopener" target="_blank">http://prism.evolveum.com/xml/ns/public/query-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:ri=<a href="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/resource/instance-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:t=<a href="http://prism.evolveum.com/xml/ns/public/types-3" rel="noreferrer nofollow noopener" target="_blank">http://prism.evolveum.com/xml/ns/public/types-3</a></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> xmlns:xsi=<a href="http://www.w3.org/2001/XMLSchema-instance" rel="noreferrer nofollow noopener" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <name>Role for Internal Employee</name></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <description>This role is assigned to all enabled internal Employees</description></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <displayName> Role Internal Employee</displayName></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <indestructible>true</indestructible></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <requestable>false</requestable></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <inducement id="3"></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <!--assign ArcheType for Internal Employee--></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <targetRef oid="333c8ef8-f58a-4550-8a31-b68e3a4c320a" relation="org:default" type="c:RoleType"/></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </inducement></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <assignment></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <policyRule></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <name>This assignment is to remove all assignments expect "Archetype Disabled Employee" and "Role Disabled Employee" </name></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <policyConstraints></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <assignment></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <operation>delete</operation></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </assignment></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </policyConstraints></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <policyActions></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <scriptExecution></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <executeScript xmlns:s=<a href="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/model/scripting-3</a>></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <s:pipeline list="true"></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <s:action></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <s:type>execute-script</s:type></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <s:parameter xmlns:qn63=<a href="http://midpoint.evolveum.com/xml/ns/public/common/common-3" rel="noreferrer nofollow noopener" target="_blank">http://midpoint.evolveum.com/xml/ns/public/common/common-3</a>></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <s:name>script</s:name></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <c:value xsi:type="c:ScriptExpressionEvaluatorType"></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <c:code></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> import com.evolveum.midpoint.xml.ns._public.common.common_3.*</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> import com.evolveum.midpoint.prism.delta.builder.*</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> import com.evolveum.midpoint.model.api.*</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> import static com.evolveum.midpoint.schema.constants.SchemaConstants.C_ORG_TYPE</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> import javax.xml.namespace.QName</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> log.info("Check if Assignments to delete because user is no longer an Internal Employee")</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> def assignmentsToDelete = []</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> user = midpoint.getObject(UserType.class, input.oid)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> for (a in user.assignment) {</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <!-- check if assigned role is "Role Disabled Employee" or "Archetype Disabled Employee" --></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> if (a.targetRef?.oid != "b72686bd-dcbd-4e9a-a5bb-15988b6a9a26" ||
</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> a.targetRef?.oid != "78c3c3a9-6f8a-4876-9a21-b9a70ec1b8b1") {</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> def removeAssignment = new AssignmentType()</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> removeAssignment.id = a.id</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> assignmentsToDelete.add(removeAssignment.asPrismContainerValue())</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> }</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> }</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> if (!assignmentsToDelete.empty) {</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> log.info("Assignments to delete because user is no longer InternalEmployee: " + assignmentsToDelete)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> def delta = prismContext.deltaFor(UserType.class).item(UserType.F_ASSIGNMENT).delete(assignmentsToDelete).asObjectDelta(user.oid)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> midpoint.modifyObject(delta)</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> }</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </c:code></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </c:value></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </s:parameter></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </s:action></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </s:pipeline></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </executeScript></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </scriptExecution></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </policyActions></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </policyRule></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <activation></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> <effectiveStatus>enabled</effectiveStatus></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </activation></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"> </assignment></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New";mso-fareast-language:EN-US" lang="EN-US"></role></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US">Maybe this code will help to solve your problem.</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US" lang="EN-US"> </span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#4B4040;mso-ligatures:standardcontextual;mso-fareast-language:EN-US">Best Regards</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#4B4040;mso-ligatures:standardcontextual;mso-fareast-language:EN-US">Patrik</span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Verdana",sans-serif;mso-fareast-language:EN-US"> </span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="DE">Von:</span></b><span lang="DE"> midPoint <midpoint-bounces@lists.evolveum.com>
<b>Im Auftrag von </b>Markus Calmius via midPoint<br>
<b>Gesendet:</b> Donnerstag, 12. </span><span lang="EN-US">Oktober 2023 11:59<br>
<b>An:</b> midPoint General Discussion <midpoint@lists.evolveum.com><br>
<b>Cc:</b> Markus Calmius <markus.calmius@proton.ch><br>
<b>Betreff:</b> [midPoint] automatically unassign all roles on disable</span></p>
</div>
<p class="MsoNormal"><span lang="EN-US"> </span></p>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">Hi,</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">I am trying to figure out how to make sure all roles are unassigned when a user is removed or disabled from HR. </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">I've found: </span><a target="_blank" href="https://docs.evolveum.com/midpoint/reference/concepts/clockwork/scripting-hooks/" rel="noreferrer nofollow noopener"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">https://docs.evolveum.com/midpoint/reference/concepts/clockwork/scripting-hooks/</span></a><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> which
contain Example 1 that should do the trick.</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">Although, it doesn't quite work on 4.7.2 it seems, I get: "Expression error: Groovy Evaluation Failed: No such property: ContainerDelta for class: (new)_"</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">Two questions:</span></p>
</div>
<div>
<ol type="1" start="1">
<li style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;list-style-type:"1. "" class="MsoNormal">
<span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">is there an easier way?</span></li><li style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;mso-list:l0 level1 lfo3;list-style-type:"2. "" class="MsoNormal">
<span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">trying to figure out what is wrong is not super easy, it's been years since I actually coded. Any guidance is greatly appreciated. I assume the <span style="color:black;background:white">createModificationDelete
has changed some input parameters </span></span></li></ol>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">I'm testing the script in the query playground with one disabled user. </span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"><expression></span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> <script></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"><code></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> import com.evolveum.midpoint.xml.ns._public.common.common_3.*;</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> import com.evolveum.midpoint.prism.*;</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> UserType user = (UserType) midpoint.searchObjectByName(UserType.class, '<redacted username>');</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> ActivationStatusType administrativeStatus = user.getActivation().getEffectiveStatus();</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> if (administrativeStatus == ActivationStatusType.DISABLED) {</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> for (AssignmentType assign : user.getAssignment()) {</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> changed = false;</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> assignmentDelta = ContainerDelta.createModificationDelete(UserType.F_ASSIGNMENT, UserType.class, prismContext, assign.clone());</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> modelContext.getFocusContext().swallowToSecondaryDelta(assignmentDelta);</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> changed = true;</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> }</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> if (changed) {</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> modelContext.rot(); // this makes Projector to recompute the model context</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> }</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> }</span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"></code></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"></script></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"></expression></span></p>
</div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US"> </span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif" lang="EN-US">Thanks in Advance</span></p>
</div>
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.5pt;font-family:"Arial",sans-serif">Markus</span></p>
</div>
</div>
</div>
</blockquote><br>
</div>