We use Creatio 7.18.
I am trying to setup a FastReport as part of which I am trying to populate a table with Reportees of the current user.
I used below to get current user id, but it returns “Supervisor” user (reference - https://community.creatio.com/questions/terrasoftsysvaluecurrentuservalue-equivalent-c).
Can anyone help with the correct way to get Current user Id in Source Code for Data Provider class to setup FastReport?
var appConnection = HttpContext.Current.Application["AppConnection"] as AppConnection;
var currentUser = appConnection.SystemUserConnection.CurrentUser;
var userId = currentUser.Id;
Like
App connection always returns "Supervisor" since this user is a system operations user. If you need to get the current user who manually triggered report generation and the custom code you need to use the same approach but with using UserConnection instead of appConnection (as Ryan described in his first example):
var currentUser = UserConnection.CurrentUser; var userId = currentUser.Id; var userName = currentUser.Name;
Or maybe I didn't understand the required result:)
Oleg Drobina,
My bad! I misunderstood his statement. Since I was trying it out in a source code schema and not a script task, I only tried using the 2nd method. The 1st method correctly returns the required information. Thanks for pointing that out, Oleg!