Created
February 24, 2018 04:59
-
-
Save smarenich/25fdbdc2c07327994843cc7453d7bd13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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