What's happening with ODATA?

  • you can set Date/Time in a trigger of DB server.
  • you can do it manually in DAService events like OnBeforeProcessDeltas
  • create BP.OnBeforeProcessChange event and assign Now to required field. this event should be assigned to specific BP in the DAService.OnBusinessProcessorAutoCreated event

Ok thanks.

Regards the streamer, I’m not entirely sure how these work. I just use a Bin2DataStreamer for all my services and it works fine so I left it alone. As this is a binary protocol, I presumed it was only used for communication from my Delphi client and that any “text based” client such as XML/JSON/REST/ODATA/etc would use something else.

Like I said, I’m not really sure how streamers work or how they affect things. I tried swapping the Bin2 for a JSON one as an experiment but functionality was identical for the ODATA calls.

This is basically what I’m doing now - I have design-time BP components with OnBeforeProcessChange handlers. In these I update modified date values and also sometimes change other values in response to user changes. The problem is that, if these values weren’t supplied as part of the JSON body in the PUT call then the corresponding strongly-typed class properties don’t work, so I can’t just do “ModifiedDate := Now” or whatever.

Inside these handlers, how can I change these values?

try to use DAService.OnBeforeProcessDeltas event.
here you can add a new field to delta and set it’s value in related delta changes

Ok I understand what you mean but, if I’m honest, I really dislike that.

My current solution is nice and elegant. Within each BP’s BeforeProcessChange handler I can not only do validation but also set or change any field value before the change is committed to the database, including fields not set by the client, all using the robust, strongly-typed class properties.

Giving that up in favour of messing about with the deltas in the service handler just to get ODATA working isn’t something I really want to do to be honest.

another solution: you can modify user’s request in HTTPServer.OnCustomResponseEvent event and add missing ModifiedDate field to request body and pass request to OData dispatcher.

see more at Using OnCustomResponseEvent in a ROSDK Server snippet.

I’ve actually just tried something else which seems to work.

In the BP’s OnBeforeProcessDelta, checking if the field is present and, if not, adding it, like this:

if (aDelta.IndexOfLoggedField(‘Modified’) < 0) then
aDelta.AddFieldName(‘Modified’,datDateTime);

I can then use the existing strongly-typed class properties in the BeforeProcessChange handler as before.

It seems to work, is there any downside or problem with this approach?

not yet. it should work as expected