<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Hello Markus,</p>
<p>I'd prefer direct creation of the delta, avoiding cloning and
diffing, like</p>
<p>1. If you know the resource (ResourceType), object class name,
and shadow OID</p>
<p><font face="monospace">Resource.of(...)<br>
.deltaFor(objectClassName)<br>
.item(ShadowType.F_ATTRIBUTES.append(attrName))<br>
.replace(value)<br>
.asObjectDelta(shadowOid);</font></p>
<p>Resource is in com.evolveum.midpoint.schema.util package.</p>
<p>(Or) 2. If you have the original shadow - which is probably your
situation - I am sorry but we don't have nicer API for this in
already released versions:</p>
<p><font face="monospace">var objectDefinition =
ShadowUtil.getResourceObjectDefinition(shadow)<br>
var delta = PrismContext.get().deltaFor(ShadowType.class, new
Resource.ResourceItemDefinitionResolver(objectDefinition))<br>
.item(ShadowType.F_ATTRIBUTES.append(attrName))<br>
.replace(value)<br>
.asObjectDelta(shadowOid);<br>
</font><br>
This second variant is not tested, but it should work. </p>
<p>Note that after <a moz-do-not-send="true"
href="https://github.com/Evolveum/midpoint/commit/177c011fdbc74b45615d103c1bd0451c29524ffc"
class="moz-txt-link-freetext">https://github.com/Evolveum/midpoint/commit/177c011fdbc74b45615d103c1bd0451c29524ffc</a> it
could be written like this</p>
<p><font face="monospace">var objectDefinition =
ShadowUtil.getResourceObjectDefinition(shadow)<br>
var delta = objectDefinition.deltaFor()<br>
.item(ShadowType.F_ATTRIBUTES.append(attrName))<br>
.replace(value)<br>
.asObjectDelta(shadowOid);</font></p>
<p>Best regards,</p>
<pre class="moz-signature" cols="72">--
Pavol Mederly
Interim Chief Product Officer
evolveum.com</pre>
<div class="moz-cite-prefix">On 09/02/2026 14:53, Markus Calmius via
midPoint wrote:<br>
</div>
<blockquote type="cite"
cite="mid:e-BfYGcRf7PQuqg65qch0V2L4hmb1hMVzOkbtNeTyfTN4-TiNDvx7Yp89kyBj7xD1nmCPe2E6Gk6iVpcsBhPHJWkToRWNEeNzxEffz6NXCw=@proton.ch">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div style="font-family: Arial, sans-serif; font-size: 14px;">Hi
Pavol,</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">thank
you for the pointer.</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">It
looks like it's working.</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">Ended
up doing it like this... not sure whether or not there are
better ways though</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;"><br>
</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">
<div
style="color: rgb(101, 123, 131); background-color: rgb(253, 246, 227);">
<pre
style="font-family:'JetBrains Mono',monospace;font-size:12.0pt"><span
style="background-color: rgb(238, 232, 213);">shadowBefore = shadow.clone()
</span>
<span style="background-color: rgb(238, 232, 213);">shadowPrism = shadow.asPrismObject()
</span><span style="background-color: rgb(238, 232, 213);">ipath = ItemPath.create(ShadowType.F_ATTRIBUTES, attrQname)
</span><span style="background-color: rgb(238, 232, 213);">shadowPrism.findOrCreateProperty(ipath).addRealValue(setAttrValue)
</span><span style="background-color: rgb(238, 232, 213);">delta = shadowBefore.asPrismObject().diff(shadowPrism)
</span><span style="background-color: rgb(238, 232, 213);">midpoint.executeChanges(delta)
</span></pre>
</div>
</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">Kind
regards,</div>
<div style="font-family: Arial, sans-serif; font-size: 14px;">Markus</div>
<div class="protonmail_quote"> On Saturday, 7 February 2026 at
18:40, Pavol Mederly via midPoint
<a class="moz-txt-link-rfc2396E" href="mailto:midpoint@lists.evolveum.com"><midpoint@lists.evolveum.com></a> wrote:<br>
<blockquote class="protonmail_quote" type="cite">
<p>Hi Markus,</p>
<p>certainly. All you need to do is to execute a change
against a shadow object, modifying specified attribute
directly. The property path to be used is composed from
"attributes" and the attribute name, e.g. "attributes/dn".</p>
<p>Best regards,</p>
<pre class="moz-signature" cols="72">--
Pavol Mederly
Interim Chief Product Officer
evolveum.com</pre>
<div class="moz-cite-prefix">On 23/01/2026 13:12, Markus
Calmius via midPoint wrote:<br>
</div>
<blockquote type="cite">
<div
style="font-family: Arial, sans-serif; font-size: 14px;">Hi,</div>
<div
style="font-family: Arial, sans-serif; font-size: 14px;"><span>Is
it possible to create a task or groovy script to modify
a particular attribute directly on a resource, in the
same way as when editing a user’s projection? </span><br>
<span>Even without an outbound mapping, the attribute is
updated on the resource. I would like to do this via a
task/script without defining an outbound mapping, so
that changes made by the resource are not overwritten by
midpoint during reconciliations.</span><br>
</div>
<div
style="font-family: Arial, sans-serif; font-size: 14px;"><br>
</div>
<div
style="font-family: Arial, sans-serif; font-size: 14px;">Kind
regards,</div>
<div
style="font-family: Arial, sans-serif; font-size: 14px;"><br>
</div>
<div
style="font-family: Arial, sans-serif; font-size: 14px;"
class="protonmail_signature_block">
<div class="protonmail_signature_block-user"> Markus</div>
<div
class="protonmail_signature_block-proton protonmail_signature_block-empty">
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated moz-txt-link-freetext"
href="mailto:midPoint@lists.evolveum.com"
rel="noreferrer nofollow noopener" moz-do-not-send="true">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext"
href="https://lists.evolveum.com/mailman/listinfo/midpoint"
target="_blank" rel="noreferrer nofollow noopener"
moz-do-not-send="true">https://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
</blockquote>
<br>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre wrap="" class="moz-quote-pre">_______________________________________________
midPoint mailing list
<a class="moz-txt-link-abbreviated" href="mailto:midPoint@lists.evolveum.com">midPoint@lists.evolveum.com</a>
<a class="moz-txt-link-freetext" href="https://lists.evolveum.com/mailman/listinfo/midpoint">https://lists.evolveum.com/mailman/listinfo/midpoint</a>
</pre>
</blockquote>
</body>
</html>