In my code below, the commented out loggedUserRow line uses an obsolete method. I tried to implement the ICurrentUserInformationProvider to get the User ID. When the code runs, the _currentUserInformationProvider variable is null. I’m not sure what I need to do to instantiate the variable. This is probably a c# thing. I tried a bunch of things not shown here, but I couldn’t figure out how to implement that interface. Â
public ICurrentUserInformationProvider _currentUserInformationProvider { get; set; }
#region Events
protected virtual void _(Events.FieldUpdated<SOLine, SOLine.inventoryID> e)
{
if (e.Row == null)
{
return;
}
SOLine lineRow = (SOLine)e.Row;
//Users loggedUserRow = Users.PK.Find(this.Base, PXAccess.GetUserID());
System.Guid? u = _currentUserInformationProvider.GetUserId();
Users loggedUserRow = Users.PK.Find(this.Base, u.Value);
if (loggedUserRow != null)
{
UsersSSGExt loggedUserExtRow = this.Base.Cachesstypeof(Users)].GetExtension<UsersSSGExt>(loggedUserRow);
if (loggedUserExtRow != null
&& loggedUserExtRow.UsrSSGDefaultWHS != null)
{
lineRow.SiteID = loggedUserExtRow.UsrSSGDefaultWHS;
}
}
}
#endregion
Â