Context: I am showing a main document in a form engine. The document model contains a binding (displayed as a dropdown selection) to a “sub” document.
I need to programmatically select a specific sub document and update the binding, then save then form (together with any other changes that the user might have made).
I can update a “normal” field in my parent document using documentService.updateEntityInstance(), but how do I update the link?
You might have a look at
RelationshipLinkService.relink(LinkDescriptor, Long)
It’s javadoc says:
Relinks an existing relationship link with a new descriptor.
That’s server side. I need it on the client side (in an open form, then save it with potentially other pending field changes).
Hi @stephen-warm-graph
RE (Relationship Engine) API is considered experimental, therefore most of them a being developed as a closed box and prevent external interaction from developer whenever possible as these can be prone to breaking changes.
Due to this fact, it is recommended to create a ticket describing in details what is your desired behavior you are looking for so we can use it as a motivation to improve the architecture of RE.
However, in case you are only looking for a Redux action (which can be monitor via the Redux devtools) when you add/remove/update a link…
So, let’s say you want to add a link, when interacting via a normal RE controls, it will result in these Redux actions
You could try to replicate this action by copy its payload as well as the action type and compose a similar Redux action (except modelGraph and modelsInScene as they are automatically added by Client). Therefore, for adding a link, you would only have to care about these 3 payload props:
- activityId: your detail scene activity reference
- instanceId: the binding UI instance reference
- candidate: which contains the document of type generated DM and a link descriptor.
Once this action is dispatched, RE will process the rest of the add link process and eventually be able to persist the change when you save the form. The other operation like update/delete a link will share the same process as well. The downside of this is, you are exposed to the internals of RE, and may prone to breaking changes. Therefore, I would still recommend filing an A12 ticket beforehand.