Current user variables are very useful in building multiuser applications.

For example it could be a current user id in Row Level Security or a user department (country, company id, etc.) for use in some business logic Queries.

Here is a quick tutorial.

Step 1.

Create a Server Context and name it ServerContext.

Step 2.

Create a variable in ServerContext named CurrentUserId with type int.

At this point you are ready to use it in any Queries you want (for configuring).

Step 3.

Export application with source code.

Step 4.

Replace \Sources\[your application name].WebAPI\Contexts\ServerContext.cs file contents with:

using CCService.WebAPI.Contracts.Contexts;

using CCService.WebAPI.Contracts;

namespace CCService.WebAPI.Contexts


   public class ServerContext : IServerContext


       private readonly ISecurityService _securityService;

       public ServerContext(ISecurityService securityService)


           _securityService = securityService;


       public int CurrentUserId


           get { return _securityService.CurrentUser.Id; }




Build and run your application. If you configured any logic in Queries using CurrentUserId it should work now.

Don't forget to Extract your custom code for later use.

Created with the Personal Edition of HelpNDoc: Easily create PDF Help documents