[midPoint] orderConstraint in archetypes

Yakov Revyakin yrevyakin at gmail.com
Wed Jul 30 19:36:15 CEST 2025


I have an archetype "unit" assigned to each node of my hierarchical org
structure. I assign org units to users considering that a user can be a
member (org:default) only in one org unit and a manager (org:manager) in
unbounded org units.
An inducement inside commands to set user attribute "costCenter" to
concatenation of assigned org unit name and assignment relation. Actually
assignment relations are limited by "org:default" in inducement
"orderConstraint", so I am waiting that "costCenter" will be set only if
the assignment relation is "org:default". As a user can be an ordinary
member only in one org unit I consider that costCenter as a single-valued
attribute satisfies my constraints.

<archetype xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
           xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
           oid="471206e4-1dfe-11eb-8429-534869969212" version="0">
    <name>unit</name>
    <inducement>
        <focusMappings>
            <mapping>
                <name>name</name>
                <strength>strong</strength>
                <expression>
                    <script>
                        <code>
                            return
assignmentPath.first().getTarget().getName().toString() +
                                    "-" +
assignmentPath.first().getRelation().getLocalPart()
                        </code>
                    </script>
                </expression>
                <target>
                    <path>costCenter</path>
                </target>
            </mapping>
        </focusMappings>
        <orderConstraint>
            <order>2</order>
            <relation>org:default</relation>
        </orderConstraint>
        <focusType>UserType</focusType>
    </inducement>
</archetype>

Org structure looks like on the picture
[image: image.png]
where test org

<org xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
     xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
     oid="462a4150-e058-4bac-8dd4-20d198985486" version="0" >
    <name>test</name>
    <assignment>
        <targetRef oid="471206e4-1dfe-11eb-8429-534869969212"
relation="org:default" type="ArchetypeType"/>
    </assignment>

</org>

and subtest org

<org xmlns="http://midpoint.evolveum.com/xml/ns/public/common/common-3"
     xmlns:org="http://midpoint.evolveum.com/xml/ns/public/common/org-3"
     oid="5ec4e94e-8c18-419c-84db-b7fde2be3c79" version="0" >
    <name>subtest</name>
    <assignment>
        <targetRef oid="471206e4-1dfe-11eb-8429-534869969212"
relation="org:default" type="ArchetypeType"/>
    </assignment>
    <assignment>
        <targetRef oid="462a4150-e058-4bac-8dd4-20d198985486"
relation="org:default" type="OrgType"/>
    </assignment>
</org>

When I assign "test" to a user with combinations of default and manager
relations I get expected behavior:
default: costCenter=test-default
manager: costCenter=<empty>
default, manager: costCenter=test-default

If I assign "subtest" to a user with combinations of default and manager
relations I get *unexpected* behavior:
default: costCenter=subtest-default
manager: costCenter=subtest-manager
default, manager: I get error "Strong mappings provided more than one value
for single-valued item costCenter: [subtest-manager, subtest-default]"

Actually I can't imagine what is wrong with such a simple task. I would be
glad to receive a justification for such behavior

Yakov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20250730/a1dfffb2/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 4760 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20250730/a1dfffb2/attachment.png>


More information about the midPoint mailing list