[midPoint] searching by date in a task

Ashwill, Steven L sashwill at uillinois.edu
Wed Apr 30 15:47:40 CEST 2025


I think I found a solution to my filter issue but I still am curious about the logging.  This is what I ended up doing to filter:
activation/validTo lessOrEqual  `basic.addDuration(basic.currentDateTime(), "P21D")`
and activation/validTo greaterOrEqual  `basic.addDuration(basic.currentDateTime(), "P15D")`
and extension/lastPasswordExpirationNotification less `basic.addDuration(basic.currentDateTime(), "-P21D")`

_____________________________________________
From: Ashwill, Steven L
Sent: Wednesday, April 30, 2025 7:39 AM
To: midpoint at lists.evolveum.com
Subject: searching by date in a task


This task(below)I have running in 4.8.7 works, however I need to be able to change the dates in the search objects.  I can't figure out how to put a scripting section in for the filter.  Also, It creates a lot of logging in the task, is there a way to turn that off?

<task xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:c="http://midpoint.evolveum.com/xml/ns/public/common/common-3" xmlns:icfs="http://midpoint.evolveum.com/xml/ns/public/connector/icf-1/resource-schema-3" xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3" xmlns:q="http://prism.evolveum.com/xml/ns/public/query-3" xmlns:ri="http://midpoint.evolveum.com/xml/ns/public/resource/instance-3" xmlns:t="http://prism.evolveum.com/xml/ns/public/types-3" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" oid="c784c44a-e457-4b61-b261-524f140d20e0" version="729">
    <name>Set PasswordResetNotification value</name>
  <assignment id="4">
        <metadata>
            <requestTimestamp>2025-04-29T13:09:41.930-05:00</requestTimestamp>
            <requestorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType">
                <!-- administrator -->
            </requestorRef>
            <createTimestamp>2025-04-29T13:09:42.036-05:00</createTimestamp>
            <creatorRef oid="00000000-0000-0000-0000-000000000002" relation="org:default" type="c:UserType">
                <!-- administrator -->
            </creatorRef>
            <createChannel>http://midpoint.evolveum.com/xml/ns/public/common/channels-3#rest</createChannel>
        </metadata>
        <targetRef oid="00000000-0000-0000-0000-000000000509" relation="org:default" type="c:ArchetypeType">
            <!-- Iterative bulk action task -->
        </targetRef>
        <activation>
            <effectiveStatus>enabled</effectiveStatus>
        </activation>
    </assignment>
    <iteration>0</iteration>
    <iterationToken/>
    <archetypeRef oid="00000000-0000-0000-0000-000000000509" relation="org:default" type="c:ArchetypeType">
        <!-- Iterative bulk action task -->
    </archetypeRef>
    <roleMembershipRef oid="00000000-0000-0000-0000-000000000509" relation="org:default" type="c:ArchetypeType">
        <!-- Iterative bulk action task -->
        <_metadata>
            <storage>
                <createTimestamp>2025-04-29T13:03:51.267-05:00</createTimestamp>
            </storage>
            <provenance>
                <assignmentPath>
                    <sourceRef oid="c784c44a-e457-4b61-b261-524f140d20e0" relation="org:default" type="c:TaskType"/>
                    <segment>
                        <segmentOrder>1</segmentOrder>
                        <assignmentId>4</assignmentId>
                        <targetRef oid="00000000-0000-0000-0000-000000000509" relation="org:default" type="c:ArchetypeType"/>
                        <matchingOrder>true</matchingOrder>
                    </segment>
                </assignmentPath>
            </provenance>
        </_metadata>
    </roleMembershipRef>
    <taskIdentifier>1745930885838-1939-1</taskIdentifier>
    <ownerRef oid="88044814-4124-4383-b119-b93a80bc9bb9" relation="org:default" type="c:UserType">
        <!-- sashwill -->
    </ownerRef>
    <binding>loose</binding>
    <threadStopAction>reschedule</threadStopAction>
    <activity>
        <work>
            <iterativeScripting>
                <objects>
                    <type>UserType</type>
                    <query>
                        <q:filter>
                            <q:text>activation/validTo greaterOrEqual "2025-05-14" and activation/validTo less "2025-05-20"  and extension/lastPasswordExpirationNotification less "2025-04-08" </q:text>
                        </q:filter>
                    </query>
                </objects>
                <scriptExecutionRequest xmlns:s="http://midpoint.evolveum.com/xml/ns/public/model/scripting-3">
                    <s:action>
                        <s:type>execute-script</s:type>
                        <s:parameter>
                            <s:name>script</s:name>
                            <s:value xsi:type="c:ScriptExpressionEvaluatorType">
                                <code>
                                    import com.evolveum.midpoint.xml.ns._public.common.common_3.*
                                    import javax.xml.datatype.DatatypeFactory;
                                    import javax.xml.namespace.QName;
                                    import javax.xml.datatype.XMLGregorianCalendar;

                                    XMLGregorianCalendar xmldate = basic.currentDateTime() as XMLGregorianCalendar;


                                   def deltas = midpoint.deltaFor(UserType.class)
                                            .item(UserType.F_EXTENSION, new QName("http://illinois.edu/application", "lastPasswordExpirationNotification"))
                                            .replace(xmldate)
                                            .item(UserType.F_EXTENSION, new QName("http://illinois.edu/application", "sendPasswordResetNotification"))
                                            .replace(true)
                                            .asObjectDeltas(input.oid)
                                    midpoint.executeChanges(deltas, null)
                                </code>
                            </s:value>
                        </s:parameter>
                    </s:action>
                </scriptExecutionRequest>
            </iterativeScripting>
        </work>

    </activity>
   <affectedObjects>
        <activity id="1">
            <activityType>c:iterativeScripting</activityType>
            <objects>
                <type>c:UserType</type>
            </objects>
            <executionMode>full</executionMode>
            <predefinedConfigurationToUse>production</predefinedConfigurationToUse>
        </activity>
    </affectedObjects>
</task>


STEVEN L ASHWILL
Software Engineer Coordinator
Administrative Information Technology Services
University of Illinois at Urbana-Champaign
50 Gerty Drive | M/C 673
Champaign, IL 61820
217.265.6337 | sashwill at uillinois.edu<mailto:sashwill at uillinois.edu>
www.aits.uillinois.edu<http://www.aits.uillinois.edu>



Under the Illinois Freedom of Information Act any written communication to or from university employees regarding university business is a public record and may be subject to public disclosure.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20250430/1c9f7405/attachment-0001.htm>


More information about the midPoint mailing list