Terrasoft.SysValue.CURRENT_USER.value equivalent in c#

Hi Community,

This code below gets the Guid of the current user in client side code

Terrasoft.SysValue.CURRENT_USER.value

How about in script task, using C# code what is its equivalent?

 

 

Like 0

Like

4 comments

In a script task you have access to UserConnection. This exposes a  CurrentUser property (which provides an object of type SysUserInfo). 

var currentUser = UserConnection.CurrentUser;
var userId = currentUser.Id;
var userName = currentUser.Name;

BTW If this was code in a source code schema/configuration service, you'd need to get the UserConnection via the AppConnection first:

var appConnection = HttpContext.Current.Application["AppConnection"] as AppConnection;
var currentUser = appConnection.SystemUserConnection.CurrentUser;

 

Ryan Farley,

Thanks Ryan,

Is there any documentation about CurrentUser. I want to know everything about its properties and attributes for future use.

Thanks.

Fulgen Ninofranco,

I don't know of any documentation, it is in Terrasoft.Core.dll, however, the SysUserInfo object inherits from the SysAdminUnit object. This object you can see in the configuration. Search for SysAdminUnit in the configuration and you'll see what is available in the SysUserInfo. The SysUserInfo object itself only adds 5 additional properties for TimeZone, PageRowsCounr, Culture, ClientIP, and DateTimeFormatCode.

Dear Fulgen,

Please use the example mentioned by Ryan, it covers the way you work with UserConnection in Script Task. 

var currentUser = UserConnection.CurrentUser;

For more information on all .Net classes used in the system please see this article:

https://academy.bpmonline.com/api/netcoreapi/7.13.0/index.html#GeneralS…

Also, as for examples of UserConnection usage in web services you can check the examples here:

https://academy.bpmonline.com/documents/technic-sdk/7-13/how-create-cus…

 Regards,

Anastasia

Show all comments