How to use a function in expression in Mobile application

How to use a function in expression in Mobile application

  

Hi,

I have an expression where i need to populate the Username of an User by his Passing his ID as a parameter.

For this, 

  1. I created a server action(GetUserNameById_Server) to call user aggregate with a filter as User.Id=userid(parameter). 
  2. Then, I made a client action(GetUserNameById_Client) and called this (GetUserNameById_Server) action in it
  3. Made GetUserNameById_Client as function
  4. When i now try to call this GetUserNameById_Client function in Expression wizard, i am getting error.


Can anyone help me achieving this

Hi Venkata,

First, when you have questions about an error, always say what the error is. This will help tremendously in troubleshooting. However, in this case I know what the error is, it's something like "Invalid Client Function
'XXXX' cannot be used in 'XXXX' because server actions are not available in client functions. Change the 'Function' property of the action 'Action1' to 'No'." And it very clearly states what is the problem: "server actions are not available in client functions". There's a good, but complicated, technical reason for that (I forgot which, but was once told by an OutSystems engineer), but it is what it is: what you want is just not possible.


When trying to call a client function in view you can't call a client function with a server-side function in it.


What you could do:


  1. Add a Data Action in the Web block or Screen.
  2. Call the GetUserNameById_Server inside the DataAction
  3. Add an output parameter to the Data Action.
  4. Assigned the result of the GetUserNameById_Server in the created output parameter.
  5. Use the output parameter in your view or expression.