Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Linq;
using PX.Data;
using PX.Common;
using PX.Objects.AP.BQL;
using PX.Objects.CM;
using PX.Objects.Common;
using PX.Objects.GL;
using PX.Objects.CS;
using PX.Objects.CR;
using PX.Objects.PM;
using PX.Objects.TX;
using PX.Objects.CA;
using PX.Objects.IN;
using PX.Objects.PO;
using PX.Objects.DR;
using PX.Objects.AP.Overrides.APDocumentRelease;
using PX.Objects.Common.DataIntegrity;
using PX.Objects.Common.Exceptions;
using Amount = PX.Objects.AR.ARReleaseProcess.Amount;
using PX.Objects;
using PX.Objects.AP;
namespace PX.Objects.AP
{
public class APReleaseProcess_Extension : PXGraphExtension<APReleaseProcess>
{
//View to save data
public PXSelect<AACustomTable> ViewForCustomTable;
#region Event Handlers
//Overriding Saving method to add our logic
public delegate void PersistDelegate();
[PXOverride]
public void Persist(PersistDelegate baseMethod)
{
baseMethod();
APRegister doc = Base.APDocument.Current;
//Check for document and released flag
if (doc != null && doc.Released == true &&
//Check for doc type.
(doc.DocType == APDocType.Invoice || doc.DocType == APDocType.CreditAdj || doc.DocType == APDocType.DebitAdj))
{
using (PXTransactionScope ts = new PXTransactionScope())
{
AACustomTable row = ViewForCustomTable.Insert();
row.TableValue = DateTime.Now.ToString();
ViewForCustomTable.Update(row);
//Manually Saving as base code will not call base graph persis.
ViewForCustomTable.Cache.Persist(PXDBOperation.Insert);
ViewForCustomTable.Cache.Persist(PXDBOperation.Update);
ts.Complete(Base);
}
}
//Triggering after save events.
ViewForCustomTable.Cache.Persisted(false);
}
#endregion
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.