Skip to main content

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

 

Hi Joe,

  I did a search through the Acumatica code for ICurrentUserInformationProvider and everywhere it was declared, it had the InjectDependency] attribute:

 ÂInjectDependency]

  private ICurrentUserInformationProvider _currentUserInformationProvider { get; set; }


If your declaration is missing that, could you add it and try again?


@Django Thanks for taking the time to dig that up.  It solved the error.

 

THANK YOU.


Reply