Can you help me on how can I get the current user (username) then assign it to a variable?
Answer
Get Current user
Best answer by Vignesh Ponnusamy
Hi
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,
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.