Add transient field to GET_DOCUMENT response

I have a testcase where I try to set a transient field inside of the DocumentAfterLoadEvent Event Listener.
From check for doc.getDocument().getEntities all looks fine, transient field is added.

package com.mgmtp.a12.template.server.print;

import com.mgmtp.a12.dataservices.document.events.DocumentAfterLoadEvent;
import lombok.RequiredArgsConstructor;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
// I know this is internal but really don't know any simple alternative
import com.mgmtp.a12.dataservices.utils.internal.DocumentUtils;
@Component
@RequiredArgsConstructor
public class TransientTestlistener {
    private final DocumentUtils documentUtils;
    @EventListener
    public void transientTest(DocumentAfterLoadEvent event) {
        documentUtils.setSingleValue(event.getDocument(), "/Person/PersonalData/transientBoolean", new int[] {1,1,1}, false);
    }
}

But when having a look into the response body it is not added.

Is there any document load listener that I can utilize to add a transient field on GET_DOCUMENT rpc request, or any other approach recommended?

After a short consultation of means of transient I belive the documentation left a little bit to much space for interpretation what it means to “persist” in a12 modelling sense docs.geta12.com - SME - transient (at least for most not java developers :grinning:).

From my point i would never see the response from rpc call as persistence but kernel serialization does.

So any recommendation at all?

Otherwise I can only see the option of using a none transient field and then clearing it on
DocumentBeforeUpdateEvent.

Hello,

I see no good solution for you. One is to reimplement the GET_DOCUMENT_OPERATION using a different kernel configuration, and the second one is to listen to the GetDocumentAfterEvent and add the field there, but the caveat is that the document is already serialized there, so you have to deserialize it in your event and then serialize back with your field.

The transient fields are completely ignored by Data Services Server.

The question is, whether this is the proper behavior or whether the server should distinguish between serialization on save and serialization to server regarding transient fields.

But I’m not the one who can decide this design point. If you think transiency should be handled differently, please create an overall A12 ticket.

thanks for you response :slight_smile:

GetDocumentAfterEvent at least sounds promising as workarround … so in that sense i can now see i have to understand GetDocumentAfterEvent as GetDocument before rpc response :grimacing:

that fits for me :+1: