[midPoint] set orgRef of to an existing assignment using xml/groovy code

Pálos Gustáv gustav.palos at gmail.com
Thu Jan 27 05:05:36 CET 2022


Hi,

try something like this for example in object template:

<mapping>
	<name>Mapping User to Org by script</name>
	<source>
		<path>organizationalUnit</path>
	</source>
	
	<expression>
		<script>
			<code><![CDATA[
				import java.text.SimpleDateFormat;
				import com.evolveum.midpoint.xml.ns._public.common.common_3.AssignmentType;
				import com.evolveum.midpoint.xml.ns._public.common.common_3.ObjectReferenceType;
				import com.evolveum.midpoint.xml.ns._public.common.common_3.OrgType;
				import com.evolveum.midpoint.schema.constants.SchemaConstants;
				import java.util.ArrayList;

				private AssignmentType createAssignment(String oid) {
					ObjectReferenceType orgRef = new ObjectReferenceType();
					orgRef.setOid(oid)
					orgRef.setRelation(SchemaConstants.ORG_DEFAULT)
					orgRef.setType(OrgType.COMPLEX_TYPE);

					AssignmentType assignment = new AssignmentType();
					assignment.setTargetRef(orgRef);
					return assignment;
				}

				ArrayList<AssignmentType> assignmentList = new ArrayList();

				org = midpoint.getOrgByName(organizationalUnit);
				if (org != null) {
					assignmentList.add(createAssignment(org?.oid));
				}

				return assignmentList;
				]]></code>
		</script>
	</expression>

	<target>
		<path>assignment</path>
	</target>
</mapping>

but similar things you can do also over assignmentTargetSearch


st 26. 1. 2022 o 18:44 Hsin-Fang Hsu via midPoint <
midpoint at lists.evolveum.com> napísal(a):

> Hi,
>
>
>
> Does anyone know how to set the orgRef of an assignment in xml?
>
>
>
> This is what I tried. But apparently it’s just read the assignment but
> won’t update it.
>
>
>
> Many thanks for your help in advance!
>
>
>
> Best regards,
>
> Hsin-Fang
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
>


-- 
s pozdravom

Gustáv Pálos
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220127/60cfd2c4/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 15183 bytes
Desc: not available
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20220127/60cfd2c4/attachment-0001.png>


More information about the midPoint mailing list