Skip to main content

Hi 

We have requirement to insert the record in the Multiple Production Clock Entry screen from the other custom action. When i try to create the clock entry we are getting the below issue.


Here is the code i tried to insert the record, could you please help me.

public PXAction<POClockINFilter> ClockIN;
PXUIField(DisplayName = "Clock IN", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
PXButton(CommitChanges = true)]
public virtual IEnumerable clockIN(PXAdapter adapter)
{
MultipleProductionClockEntry ProdClockEntrtyGraph = PXGraph.CreateInstance<MultipleProductionClockEntry>();
AMClockItem aMClockItem = (AMClockItem)ProdClockEntrtyGraph.Document.Cache.Insert();
aMClockItem.EmployeeID = 2892;

AMClockTran newTran = (AMClockTran)ProdClockEntrtyGraph.Transactions.Cache.Insert();

newTran.ProdOrdID = "AM000048";
newTran.OperationID = 2;
ProdClockEntrtyGraph.Transactions.Cache.Update(newTran);

ProdClockEntrtyGraph.Save.Press();


return adapter.Get();
}

 

@mounikaka96  Please try below code.

 

public PXAction<SOOrder> ClockIN;
/PXUIField(DisplayName = "Clock IN", MapEnableRights = PXCacheRights.Select, MapViewRights = PXCacheRights.Select)]
/PXButton(CommitChanges = true)]
public virtual IEnumerable clockIN(PXAdapter adapter)
{
MultipleProductionClockEntry ProdClockEntrtyGraph = PXGraph.CreateInstance<MultipleProductionClockEntry>();
var currentClockItm = ProdClockEntrtyGraph.Document.Select(2892);
if (((AMClockItem)currentClockItm) != null)
{
ProdClockEntrtyGraph. Document.Current = currentClockItm;
}
else
{
ProdClockEntrtyGraph.Document.Current = (AMClockItem)ProdClockEntrtyGraph.Document.Cache.Insert();
ProdClockEntrtyGraph.Document.Current.EmployeeID = 2892;
}


AMClockTran newTran = (AMClockTran)ProdClockEntrtyGraph.Transactions.Cache.Insert();
newTran.EmployeeID = 2892;
ProdClockEntrtyGraph.Transactions.Cache.Update(newTran);
newTran.OrderType = "RO";
newTran.ProdOrdID = "AM000048";
ProdClockEntrtyGraph.Transactions.Cache.Update(newTran);
newTran.OperationID = 2;
newTran.WcID = "WC10";
newTran.Status = ClockTranStatus.ClockedIn;
newTran.Selected = true;
newTran.AllowMultiClockEntry = AMWC.PK.Find(Base, "WC10")?.AllowMultiClockEntry;

newTran.BaseQtyScrapped = 0;
// ProdClockEntrtyGraph.Transactions.Cache.Update(newTran);

ProdClockEntrtyGraph.Save.Press();


return adapter.Get();
}

 


Reply