Skip to main content

Hi Team,

I have 2 customized fields(“COO, Date Code”) in LineDetails on Labor Screen, upon release i want to insert these field values to LineDetails in Receipt. I’m using the below code to do so, but it is not insert the fields in Receipt. could you please help me on this.

 

 

namespace PX.Objects.AM
{
    public class LaborEntry_Extension : PXGraphExtension<LaborEntry>
    {
        #region Event Handlers
        public delegate IEnumerable ReleaseDelegate(PXAdapter adapter);
        pPXOverride]
        public IEnumerable Release(PXAdapter adapter, ReleaseDelegate baseMethod)
        {
            var amtransplit = Base.splits.Select().FirstTableItems.ToList();
            amtransplit.ForEach(f =>
            {
                f.ExpireDate = DateTime.Now;
                Base.splits.Update(f);
                Base.Save.Press();
            });

            baseMethod(adapter);
            PXLongOperation.WaitCompletion(Base.UID);
            var amheader = Base.batch.Current;
            if (amheader != null)
            {
                
                var inreceiptGraph = PXGraph.CreateInstance<INReceiptEntry>();

                var batchHeader = PXSelect<INRegister, Where<INRegister.docType, Equal<INDocType.receipt>, And<INRegister.srcRefNbr, Equal<Required<INRegister.srcRefNbr>>>>>.Select(Base, amheader.BatNbr).FirstTableItems.FirstOrDefault();   
                if (batchHeader != null)
                {
                    inreceiptGraph.receipt.Current = batchHeader;
                    amtransplit.ForEach(f =>
                    {
                        var amsplitExt = f.GetExtension<AMMTranSplitExt>();
                        var splits = PXSelect<INTranSplit, Where<INTranSplit.docType, Equal<INDocType.receipt>, And<INTranSplit.refNbr, Equal<Required<INTran.refNbr>>, And<INTranSplit.lineNbr, Equal<Required<INTran.lineNbr>>>>>>.Select(Base, batchHeader.RefNbr, f.LineNbr).FirstTableItems.FirstOrDefault();

                        if (splits != null)
                        {
                            var intranExt = splits.GetExtension<INTranSplitExt>();
                            intranExt.UsrCOO = amsplitExt.UsrCOO;
                            intranExt.UsrDateCode = amsplitExt.UsrDateCode;
                            inreceiptGraph.splits.Update(splits);
                            inreceiptGraph.Save.Press();
                        }
                    });
                }
            }
            return adapter.Get();
        }
        #endregion
    }
}

 

Hi @ramya15  

Hope you are doing well!

In the RELEASE action, basemethod should be invoked at last, because once basemethod is invoked then document will not available to insert/update the values.

 

You can have an INTran insertion code before the basemethod and verify.

 


Hi @Naveen Boga,

Thank you so much. It’s working.

 

Regards,

Ramya


Reply