Where is the the best place to put own code to manipulate the attached invoice PDF of an E-Mail before it gets send?
What about PX.Objects.CR.Extensions.ActivityDetailsExt.CreateNotificationProvider()?
How can i PXOverride it?
Pascal
Or is there way to customize PX.Objects.EP.NotificationGenerator?
Which is the graph which is used to perist CRSMEmail in NotificationGenerator.PersistMessages()
Hi
Not sure if it possible to override generic CreateNotificationProvider, but at least we can override SendNotification which calls CreateNotificationProvider.
public class ARInvoiceEntry_NotificationExt : PXGraphExtension<ARInvoiceEntry_ActivityDetailsExt, ARInvoiceEntry>
{
>PXOverride]
public virtual void SendNotification(string sourceType, string notifications, int? branchID, IDictionary<string, string> parameters, bool massProcess = false, IList<Guid?> attachments = null,
Action<string, string, int?, IDictionary<string, string>, bool, IList<Guid?>> baseMethod = null)
{
baseMethod(sourceType, notifications, branchID, parameters, massProcess, attachments);
}
}
Invoice PDF is created based on a report. So if you need to change some details inside PDF you would better change the report.
Thanks
I’ll do it this way for the time beeing:
public class ARInvoiceEntry_NotificationExt : PXGraphExtension<ARInvoiceEntry_ActivityDetailsExt, ARInvoiceEntry>
{
PXOverride]
public virtual void SendNotification(string sourceType, string notifications, int? branchID, IDictionary<string, string> parameters, bool massProcess = false, IList<Guid?> attachments = null,
Action<string, string, int?, IDictionary<string, string>, bool, IList<Guid?>> baseMethod = null)
{
var activityExt = Base.GetExtension<ARInvoiceEntry_ActivityDetailsExt>();
var sender = activityExt.CreateNotificationProvider<ARInvoice>(sourceType, notifications, branchID, parameters, attachments);
var inv = Base.Cacheshtypeof(ARInvoice)]?.Current;
if (inv != null)
{
List<FileInfo> _attachments = (List<FileInfo>) sender.GetType().BaseType
.GetField("_newAttachments", BindingFlags.NonPublic | BindingFlags.Instance)
.GetValue(sender);
foreach (FileInfo attm in _attachments)
{
// manipulate pdf here
}
}
if (!sender.Send().Any())
throw new PXException(PX.Objects.CR.Messages.EmailNotificationError);
}
}
The problem is, that i have to bypass the overridden method completely and copy the code it contains to my method. Would be great if the non generic CreateNotificationProvider would have been called in SendNotification<TTemplateEntityType>. Then we could override it, but today it is not used at all.
var mainDocRecipient = GetPrimaryRecipientFromContext(NotificationUtility, sourceType, bAccount, source);
I hope override this method will help to omit copying
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.