[midPoint] fire-and-forget action to update attribute in resource
Pavol Mederly
mederly at evolveum.com
Mon Feb 16 16:41:58 CET 2026
Hello Markus,
I'd prefer direct creation of the delta, avoiding cloning and diffing, like
1. If you know the resource (ResourceType), object class name, and
shadow OID
Resource.of(...)
.deltaFor(objectClassName)
.item(ShadowType.F_ATTRIBUTES.append(attrName))
.replace(value)
.asObjectDelta(shadowOid);
Resource is in com.evolveum.midpoint.schema.util package.
(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:
var objectDefinition = ShadowUtil.getResourceObjectDefinition(shadow)
var delta = PrismContext.get().deltaFor(ShadowType.class, new
Resource.ResourceItemDefinitionResolver(objectDefinition))
.item(ShadowType.F_ATTRIBUTES.append(attrName))
.replace(value)
.asObjectDelta(shadowOid);
This second variant is not tested, but it should work.
Note that after
https://github.com/Evolveum/midpoint/commit/177c011fdbc74b45615d103c1bd0451c29524ffc it
could be written like this
var objectDefinition = ShadowUtil.getResourceObjectDefinition(shadow)
var delta = objectDefinition.deltaFor()
.item(ShadowType.F_ATTRIBUTES.append(attrName))
.replace(value)
.asObjectDelta(shadowOid);
Best regards,
--
Pavol Mederly
Interim Chief Product Officer
evolveum.com
On 09/02/2026 14:53, Markus Calmius via midPoint wrote:
> Hi Pavol,
>
> thank you for the pointer.
>
> It looks like it's working.
> Ended up doing it like this... not sure whether or not there are
> better ways though
>
> shadowBefore = shadow.clone()
> shadowPrism = shadow.asPrismObject() ipath =
> ItemPath.create(ShadowType.F_ATTRIBUTES, attrQname)
> shadowPrism.findOrCreateProperty(ipath).addRealValue(setAttrValue)
> delta = shadowBefore.asPrismObject().diff(shadowPrism)
> midpoint.executeChanges(delta)
> Kind regards,
> Markus
> On Saturday, 7 February 2026 at 18:40, Pavol Mederly via midPoint
> <midpoint at lists.evolveum.com> wrote:
>>
>> Hi Markus,
>>
>> 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".
>>
>> Best regards,
>>
>> --
>> Pavol Mederly
>> Interim Chief Product Officer
>> evolveum.com
>> On 23/01/2026 13:12, Markus Calmius via midPoint wrote:
>>> Hi,
>>> 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?
>>> 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.
>>>
>>> Kind regards,
>>>
>>> Markus
>>>
>>> _______________________________________________
>>> midPoint mailing list
>>> midPoint at lists.evolveum.com
>>> https://lists.evolveum.com/mailman/listinfo/midpoint
>
>
> _______________________________________________
> midPoint mailing list
> midPoint at lists.evolveum.com
> https://lists.evolveum.com/mailman/listinfo/midpoint
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.evolveum.com/pipermail/midpoint/attachments/20260216/52cda2cf/attachment.htm>
More information about the midPoint
mailing list