Entities actions as functions

Greetings,


After modeling an entity (say: Foo), only one of the generated entity functions (GetFoo, input: Foo Identifier, output: Foo record) can be called as a function. Why not the others. For example, CreateFoo, input: Foo record, output: Foo Identifier) cannot be called as a function. In this case, how is it possible, in a server logic flow, to receive the identifier of the newly created Foo record. I expected to be able to simply use CreateFoo in an assignment such as: FooId = CreateFoo(FooRecord).


Thanks!

JP

Solution

Hi Jean-Paul,

Every client or server action  can have 0, 1 or more output parameters.

Only a client or server action with exactly 1 output parameter can be marked as a function using the Function property.

Only a client or server action marked as Function can be used in an expression or assignment.

So you could indeed argue why OutSystems decided not make the CRUD server actions of an entity all as functions (except for the delete which has no output parameter). Probably only an OutSystems engineer can explain the reasoning behind it.

However you can stil easily use one or any of the output parameters of a server action by first calling the server action in your flow, after that all output parameters are available. This makes the code very visual and easy to read. 

Also when doing analysis like doing a find usage or find uage all modules, it helps not to have all the server action calls in assignments.

Regards,

Daniel

Solution

Daniël Kuhlmann wrote:

Hi Jean-Paul,

Every client or server action  can have 0, 1 or more output parameters.

Only a client or server action with exactly 1 output parameter can be marked as a function using the Function property.

Only a client or server action marked as Function can be used in an expression or assignment.

So you could indeed argue why OutSystems decided not make the CRUD server actions of an entity all as functions (except for the delete which has no output parameter). Probably only an OutSystems engineer can explain the reasoning behind it.

However you can stil easily use one or any of the output parameters of a server action by first calling the server action in your flow, after that all output parameters are available. This makes the code very visual and easy to read. 

Also when doing analysis like doing a find usage or find uage all modules, it helps not to have all the server action calls in assignments.

Regards,

Daniel

Thank you Daniel for your note!

I will mark it as "Solution" once we know the reason why some of these CRUD server actions were not marked as functions, as this would have provided more consistency and flexibility. 

Best,

JP


Hi,

My gues is that it is not done to promote the code to be more visual, and that not all functionallity is 'hidden' in assign nodes.

Regards,

Daniel

Hi,

Agree with Daniel.  

And also there is this idea that functions should not have side effects other than returning the result.  Altering the state of things in permanent storage like in a database sure counts as a side effect.  

So that might have been on the mind of OS engineers, maybe.

Dorine