Abstract record variable?
Question
Application Type
Reactive
Service Studio Version
11.12.0 (Build 48324)
Platform Version
11.11.3.31860

Hi

I'm designing a Server Action that needs to manipulate different Entity Objects. For example: Entity A has 3 attributes, Entity B has 10 attributes. I need to be able to pass either of this Entity Objects to this Action through a single input variable ("abstract record variable").

Creating an Action for each Entity type is not an option.

Is this possible in OutSystems Reactive App?

Hi Gleb,

For this you can create a structure with 13 attributes and assign the variable datatype to structure.

after assigning the variable data type to structure, you will get all the attributes into one variable. You can pass the value to the variable when using server action.

Thanks, Aadhavan S

Thanks Aadhavan, this works for me.

Follow-up question: Can I make an abstract Aggregate?

All my entities have their ID attribute as Text type, so if I pass a text variable into this action, can I use it to aggregate data without specifying an entity?

If aggregate won't work, can I use SQL for this task?

Hi Gleb,

All my entities have their ID attribute as Text type, so if I pass a text variable into this action, can I use it to aggregate data without specifying an entity? -  Yes you can pass the value and use it to aggregate (Remenber text values are case sensitive).

If aggregate won't work, can I use SQL for this task? - Yes you can use this to either aggregate or advanced SQL.

But aggregate requires me to "Select Source" and I have to select an entity there? In my case the entity is unknown

You can use Advanced SQL to manipulate the data.. where also you have to give table name and set the above-mentioned structure as an output parameter.

Hi Gleb,

As Outsystems is strongly typed, this is not obvious/straightforward.  Can you explain more about what exactly you want to achieve and why you think creating an action for each entity is not an option ?

What will you do inside that action ?

There are some things you could consider, such as ToObject(Entity) or serializing into JSON or XML,but there are lots of limitations of what you can and can not do after that.

If your entities have a lot in common, maybe you can have some sort of common structure you can map each entity to.

Dorine

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