New entity manipulation in middleware service

Hello,
I’m still not 100% sure what the ideal solution is when manipulating new entities with a middleware service. E.g. we have user 1..n document composition, where the document entity can be manipulated via a middleware service.

When I insert a new company entity (CompanyEdit) and then add a new document entity (now I am in DocumentEdit) and here I have a function that will call the middleware service to manipulate the document entity I will have to persist the document entity first.

The service now sets some fields in the document entity, persists the result and returns. Now I have to reload the entity in the edit screen.

It is even trickier, if I need the newly created company entity in the service call, because then I’d also have to persist the company entity, before I invoke the service call.

So, what’s the best way of dealing with new entities (also nested new entities as outlined in my short example) in a middleware service?

Hi,
I’m not sure what do you mean by “manipulating”, but in order to pass the “new” entity to the middleware service - it doesn’t need to be persisted beforehand.

Hi @AlexBudarov, thanks for answering. “Manipulating” was too broad probably. In this particular use case I use the reporting addon to create a document in the middleware. I have a report with a view configured, so the reporting engine reloads the submitted entity from the database.