[midPoint] Why does script in schemaHandling execute twice?
Markus Calmius
markus.calmius at proton.ch
Mon May 13 10:35:48 CEST 2024
Hi,
I am not doing this in the schemahandling, but in a object template, but maybe it will help.
Basically, I've created a check to be able to manually set the LDAP-uid (but not change it)
----
<expression>
<script>
<code>
import com.evolveum.midpoint.xml.ns._public.common.common_3.*
import com.evolveum.midpoint.schema.result.OperationResult
import com.evolveum.midpoint.schema.result.OperationResultStatus
/* extension attribute name is ldapUsername */
old_uid = basic.getExtensionPropertyValue(object, 'ldapUsername')
result = new OperationResult("LDAP uid");
result.setMessage("LDAP uid cannot be modified");
result.setStatus(OperationResultStatus.FATAL_ERROR)
if ( old_uid == null || old_uid == ''){
return null
}
if ( old_uid != input){
return result.createOperationResultType();
}
</code>
</script>
</expression>
Markus Calmius
Proton AG
On Saturday, 11 May 2024 at 12:00, midpoint-request at lists.evolveum.com <midpoint-request at lists.evolveum.com> wrote:
> Send midPoint mailing list submissions to
> midpoint at lists.evolveum.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.evolveum.com/mailman/listinfo/midpoint
> or, via email, send a message with subject or body 'help' to
> midpoint-request at lists.evolveum.com
>
> You can reach the person managing the list at
> midpoint-owner at lists.evolveum.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of midPoint digest..."
>
>
> Today's Topics:
>
> 1. Re: midPoint Digest, Vol 145, Issue 7 (Maxwell, Gary)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 10 May 2024 19:39:40 +0000
> From: "Maxwell, Gary" Maxwell_G at fortlewis.edu
>
> To: "midpoint at lists.evolveum.com" midpoint at lists.evolveum.com
>
> Subject: Re: [midPoint] midPoint Digest, Vol 145, Issue 7
> Message-ID:
> DM6PR03MB4523CCBD972C0BE1704C2DB195E72 at DM6PR03MB4523.namprd03.prod.outlook.com
>
>
> Content-Type: text/plain; charset="utf-8"
>
> Thank You Ivan for pointing me in the right direction.
>
> It explains why the expression and condition are evaluated twice. This leads me to the next question.
> The source for my variable is a $focus user attribute and the target is the same $focus user attribute. Therefore I set the output attribute depending upon the input variable. The script sees the correct input variable the first time it runs however sees the new value on the second time it runs.
>
> Is there a way to access the Midpoint user attribute value that only reflects the initial value before it is changed?
>
> I hope this makes sense.
> -Gary
>
>
>
> -----Original Message-----
> From: midPoint midpoint-bounces at lists.evolveum.com On Behalf Of midpoint-request at lists.evolveum.com
>
> Sent: Thursday, May 9, 2024 4:00 AM
> To: midpoint at lists.evolveum.com
> Subject: midPoint Digest, Vol 145, Issue 7
>
> Send midPoint mailing list submissions to
> midpoint at lists.evolveum.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
> https://lists.evolveum.com/mailman/listinfo/midpoint
> or, via email, send a message with subject or body 'help' to
> midpoint-request at lists.evolveum.com
>
> You can reach the person managing the list at
> midpoint-owner at lists.evolveum.com
>
> When replying, please edit your Subject line so it is more specific than "Re: Contents of midPoint digest..."
>
>
> Today's Topics:
>
> 1. Why does script in schemaHandling execute twice? (Maxwell, Gary)
> 2. Re: Why does script in schemaHandling execute twice? (Ivan Noris)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 8 May 2024 22:21:23 +0000
> From: "Maxwell, Gary" Maxwell_G at fortlewis.edu
>
> To: "midpoint at lists.evolveum.com" midpoint at lists.evolveum.com
>
> Subject: [midPoint] Why does script in schemaHandling execute twice?
> Message-ID:
> DM6PR03MB4523A119FF0BB05B763BB3A095E52 at DM6PR03MB4523.namprd03.prod.outlook.com
>
>
> Content-Type: text/plain; charset="utf-8"
>
> Can someone tell me why the following script executes twice? The first execution uses the existing isActive value, the second time uses the value I changed it to.
>
> <resource>
>
> <schemaHandling>
>
> <objectType>
>
> <attribute>
>
> <inbound>
>
> <source>
>
> <name>isActive</name>
>
> <path>$focus/extension/isActive</path>
>
> </source>
>
> <expression>
>
> <script>.
>
> <code>
>
> If (isActive == true)
> return false
> </code>
>
> </script>
>
> </expression>
>
> <target>
>
> <path>extension/isActive</path>
>
> </target>
>
> </inbound>
>
> </attribute>
>
> </objectType>
>
> </schemaHandling>
>
> </resource>
>
>
>
> ------------------------------
>
> Message: 2
> Date: Thu, 9 May 2024 09:55:56 +0200
> From: Ivan Noris ivan.noris at evolveum.com
>
> To: midpoint at lists.evolveum.com
> Subject: Re: [midPoint] Why does script in schemaHandling execute
> twice?
> Message-ID: 13e88d3c-c867-433f-a859-3f8fde6cea33 at evolveum.com
>
> Content-Type: text/plain; charset=UTF-8; format=flowed
>
> Hi,
>
> please refer to
> https://docs.evolveum.com/midpoint/reference/support-4.8/expressions/mappings/#why-are-the-expressions-and-conditions-evaluated-several-times
>
> Best regards,
>
> Ivan
>
> On 9. 5. 2024 0:21, Maxwell, Gary via midPoint wrote:
>
> > Can someone tell me why the following script executes twice? The first execution uses the existing isActive value, the second time uses the value I changed it to.
> >
> > <resource>
> > <schemaHandling>
> > <objectType>
> > <attribute>
> > <inbound>
> > <source>
> > <name>isActive</name>
> > <path>$focus/extension/isActive</path>
> > </source>
> > <expression>
> > <script>.
> > <code>
> > If (isActive == true)
> > return false
> > </code>
> > </script>
> > </expression>
> > <target>
> > <path>extension/isActive</path>
> > </target>
> > </inbound>
> > </attribute>
> > </objectType>
> > </schemaHandling>
> > </resource>
> >
> > _______________________________________________
> > midPoint mailing list
> > midPoint at lists.evolveum.com
> > https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> --
> Ivan Noris
> Expert Identity Engineer
> evolveum.com
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> ------------------------------
>
> End of midPoint Digest, Vol 145, Issue 7
> ****************************************
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> ------------------------------
>
> End of midPoint Digest, Vol 145, Issue 9
> ****************************************
More information about the midPoint
mailing list