Use Object data type in Service Action

Hello,


I have a service module that exposes the functionality of auditing changes in the OutSystems factory. Until now, I've exposed Server Actions to serve this purpose and it allowed passing objects as input parameters, but when I try to convert the existing actions to service actions I'm not able to pass input parameters of Object type anymore.

Do you have an idea of how I can overcome this? (note that I'm using RecordDifferences action from Human Readable Change history in order to retrieve the record changes)


Regards,

Bogdan

Hi Daniel,


I ended up exposing a REST API that handles the audit for any modules that might've had cyclic dependencies. And instead of passing the Objects as parameters I called the RecordDifferences action in the specific module and sent to the REST API only the text representing record Changes + other relevant information.


Hope this helps your case as well.


Kind regards,

Bogdan

Champion

Hi Bogdan,


Can you share sample oml of this ?

Also, do you use this function to convert to object ? 

ToObject()

Here are some extra details, in case I was not clear enough:

  • I have a library module for Audit purposes. It has a server action AuditLog_Create that receives as input parameters 2 objects (original and changed). In this action I use RecordDifferences action from the Human Readable Change History component to compute the changes and store then in my own DB table.
  • The issue is related to the fact that Audit_CS module already has references to another module in our factory, but I also have the requirement to audit changes in that core module. I have already overcome this by creating a REST WS that saves the audit changes
  • My only question remains how serialize/deserialize objects dynamically and pass them via WS or Service Actions in order to avoid tightly coupled modules? :)

Regards,

Bogdan

mvp_badge
MVP

The reason you cannot use the Object data type is that under the hood the Service action is a REST API endpoint on the environment localhost. Rest API do not support that data type for a request parameter. You need to serialize the data.

Hi Daniel,


Thanks for the explanation. I was aware Service Actions give you the loosely coupled abilities since the underlying communication is done via REST APIs, but the thing is that even if I serialize the object, it's difficult to deserialize it dynamically in when processing the request. I'm passing entity records as serialized objects to the service action, but I cannot reference the entity itself in my module since it will again create cyclic dependencies.

I was wondering if there is a smart way to do it, since in the end the RecordDifferences action is based on objects, not on entity records specifically.


Regards,

Bogdan

mvp_badge
MVP

Honestly, don't think there is, I think you should question yourself what the benefits are for you to use a service action here over a server action.

Hi, I'm wondering if you found a solution to this issue. I'm also trying to pass objects to a service action which calls RecordDifferences, and don't want to reference the entities in the service module. Any help would be appreciated.

Hi Daniel,


I ended up exposing a REST API that handles the audit for any modules that might've had cyclic dependencies. And instead of passing the Objects as parameters I called the RecordDifferences action in the specific module and sent to the REST API only the text representing record Changes + other relevant information.


Hope this helps your case as well.


Kind regards,

Bogdan

Thanks for your reply.

I thought about calling RecordDifferences in the specific modules as well, but wanted to avoid having to reference the DiffEntityDataToText module in all those modules. I guess I'll write some common server action to do the RecordDifferences call, and then do the service action as you described above.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.