Reputation: 909
I'd like to add some custom code to the process of the Release Payments screen. If I create a customization project and add a Graph extension to the CODE section, I can't find any method with a name similar to 'Release Payments' to override in the list to select from (even though it exists as public in the BLC):
and if I try to manually code the override, I get an error that it can't find that method.
So basically, my question is, how do I intercept the process on the Release Payments screen?
Upvotes: 0
Views: 484
Reputation: 7706
I have had success with overriding the ARReleaseProcess.ReleaseDocProc
like below. All the AR documents (invoices, payments, etc.) call the ARReleaseProcess.ReleaseDocProc
during the release and that function does the main process. The below code is basically calling what that function was supposed to do and adding the delegate for when the release is completed.
public class ARReleaseProcessExt: PXGraphExtension<ARReleaseProcess>
{
public static bool IsActive()
{
return true;
}
public void OnReleaseComplete(ARRegister doc)
{
try
{
if (doc!=null && doc.DocType== ARDocType.Payment)
{
///ADD your code here
}
}
catch(Exception exc)
{
/// handler errors.
}
}
#region ReleaseDocProc
public delegate List<ARRegister> ReleaseDocProcDelegate(JournalEntry je, ARRegister ardoc, List<Batch> pmBatchList, ARDocumentRelease.ARMassProcessReleaseTransactionScopeDelegate onreleasecomplete);
[PXOverride]
public List<ARRegister> ReleaseDocProc(JournalEntry je, ARRegister ardoc, List<Batch> pmBatchList, ARDocumentRelease.ARMassProcessReleaseTransactionScopeDelegate onreleasecomplete, ReleaseDocProcDelegate del)
{
onreleasecomplete += OnReleaseComplete;
return del(je, ardoc, pmBatchList, onreleasecomplete);
}
#endregion
}
The override is a little different in case of AP module as the signature of the function is different there.
public class APReleaseProcess_Extension : PXGraphExtension<PX.Objects.AP.APReleaseProcess>
{
#region Event Handlers
public delegate List<APRegister> ReleaseDocProcDelegate(JournalEntry je, APRegister doc, Boolean isPrebooking, ref List<INRegister> inDocs);
[PXOverride]
public List<APRegister> ReleaseDocProc(JournalEntry je, APRegister doc, Boolean isPrebooking, ref List<INRegister> inDocs, ReleaseDocProcDelegate baseMethod)
{
var retVal = baseMethod(je,doc,isPrebooking,ref inDocs);
//Your code goes here.
PXTrace.WriteInformation("My override worked!");
return retVal;
}
#endregion
}
Upvotes: 0