Can you help me on how can I get the current user (username) then assign it to a variable?
Best answer by Vignesh Ponnusamy
View originalCan you help me on how can I get the current user (username) then assign it to a variable?
Best answer by Vignesh Ponnusamy
View originalHi
You can user InjectDependency attribute and declare ICurrentUserInformationProvider then using which you can get the username. Below is an example for reference,
public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
{
#region Event Handlers
[InjectDependency]
private ICurrentUserInformationProvider _currentUserInformationProvider { get; set; }
protected void SOOrder_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected baseHandler)
{
var row = (SOOrder)e.Row;
bool flag = false;
var curUser = _currentUserInformationProvider.GetUserName();
baseHandler?.Invoke(cache, e);
}
#endregion
}
Hope that helps.! Good Luck,
I will try this thank you so much :)
Hi
I don’t think so, it just an alternate way to get the username. In fact, ICurrentUserInformationProvider is an interface which makes us need additional line of codes get the necessary information.
Thanks for bringing this up.
Alternatively, you can also try something like below
var curUserName = Base.Accessinfo.UserName;
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.