When I add a "Check<...>Role" Action the default expression is for example: 

SyntaxEditor Code Snippet


This is a valid expression but for me the statement "UserId:" doesn't ring any bells nor can I find any information about it. Normally I would replace it with GetUserId() but I do wonder what this expression means, what the result is and if there are more expressions like this?



When you add a server action that has optional parameters, those are indicated in the expression by the name of the parameter followed by :

You can leave them or delete. Doesn't matter. 

In this particular case, if you provide a user Identifier, the function will check the user you provided., otherwise it will check the actual user (logged in). 



Ok, So it's a stub.  But how is then the default value defined? In this case, why is it using the identifier of the currently logged in user (as you mentioned) and not NullIdentifier? I would find the latter, for an optional, more logical.   

Hi Vincent,

Optional parameters of an Action that are not provided when the action is called, will actually be initialized with whatever is their default value, which then your logic (in this case the CheckAdministratorRole action) can check. In this case, the action's behaviour could easily be implemented as  if UserId is NullIdentifier() then assign GetUserId() to UserId

Hi Vincent,

Most (if not all) of the built-in actions in OutSystems that will require an optional UserId will use, internally, the Id returned by GetUserId().

The reason (I think) is to accelerate the process. I almost never used Check<role>Role() to check a specific user other than the one logged in (or anonymous if not logged in). SO, it is easier to use CheckManagerRole() than CheckManagerRole(GetUserId()).

As for other parameters, the default value will depend on the implementation. Usually, it will be indicated in the description of the parameter what is the default value. If you don't define a default value for an optional input parameter in an action, the DataType default value will be used.


Hi Jorge and Eduardo,

Good to know that this is the default behavior of this specific function. I would have suspected that the selection the current user would be visible in the "default value" property but anything can happen in the action underneath, it depends on the implementation I guess :)

Default values must be literals. So you can't use GetUserId() there. But you are right that the description could include this information, and it doesn't.