here’s what i’m trying to achieve. I want, when a new record in Sales orders is created, if the SalesPersonID is not filled, if it ends up null, It should, by default, be the same as the Current user’s ID. how can I achieve this? can someone provide the code or an example? and where would I put it?
Put this is a Graph Extension of SOOrderEntry:
protected virtual void _(Events.FieldDefaulting<SOLine, SOLine.salesPersonID> e, PXFieldDefaulting b)
{
SOLine row = e.Row;
if (row is null) return;
// Execute regular defaulting logic first
b?.Invoke(e.Cache, e.Args);
// If the SalesPersonID is still null, default to the current user's SalesPersonID
if (row.SalesPersonID == null)
{
SalesPerson currentSalesPerson = SelectFrom<SalesPerson>.
InnerJoin<EPEmployee>.
On<EPEmployee.FK.SalesPerson>.
InnerJoin<Users>.
On<EPEmployee.FK.User>.
Where<Users.pKID.IsEqual<AccessInfo.userID.FromCurrent>>.View.Select(e.Cache.Graph);
e.NewValue = currentSalesPerson?.SalesPersonID;
e.Cancel = true;
}
}
alot of graphs with soorderentry show up when i search or the graph. can you be specific with whcih one?
Reply
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.