To group emails together by company when sending invoices, I’ve broken by customer ID. I originally would break by invoice number which will send one invoice per email and include the invoice number in the subject and PDF file name.
When breaking by customer ID, inserting the invoice number into an email containing multiple invoices will only take the first invoice number of them all, which makes sense, but I want to grab each invoice number and put them in the email body.
Initially I thought using a BPM call context data table would work, but that doesn’t exist here. Do I have to insert those values into some unused UD table and then add a view to the table lookup in the breaking/routing designer? Any other more straightforward methods?
This may be limited by the way AR Invoices print. If your group had 5 invoices, the group print combines them into a single report, Instead of sending as 5 individual reports. The data in the dataset is first grouped by invoice.
You may need a Custom Code block in the B/R flow, to extract all the Invoice Nums in the data set, and assign them to a variable. Then insert that variable into the body.
If you’re going to use any custom code, might as well do it all (except the first break) in code. Then you could even build a nice looking HTML based email.
I did one for shipping notices like this. It builds the email body to include:
The issue is that there isn’t an option to insert custom code into the B/R designer. Are you using a BPM to do this? I need to change the subject line and body depending on if there are multiple invoices or just one.
Having a conditional to check the the number of invoices within each grouping by customer ID would be ideal here.
I was incorrect… there is no Custom Code block in a B/R.
The Shipping Notices emails I did use a BPM (actually a Data Directive) to create the email. And not in the B/R flow. The email that is created doesn’t even have an attachment.
I’ve looked long and hard for how to get the best of both (customizing the body of the email to be HTML, AND attach a PDF of the printed form) - but no luck.
Routing does have some very noticeable shortfalls compared to BPMs, sadly.
One way we’ve overcome some situations is to use a BPM prior to routing which inserts needed data into a UD field in the tables already used in the document routing, but it is a bit messy. Probably a better way to go than using up a UD table, though.
We used an in-transaction data directive on the InvcHead table, but not to do anything particularly complicated in our case. We’ve added a couple of UD fields to that table, and the check to populate them happens in this directive when the “Posted” field changes from false to true.
We can then use the data in that UD field as we wish in the routing.
If I’m reading you right, have a long text UD field and the BPM would loop for each Invoice # and add it to the field. UD = UD + ", " + InvNum(as string) type thing? Then APR could reference that in the email?
Basically, that’s it, yes. Each invoice head record would have the complete list stored within it. A bit redundant, but it does solve the problem.
We do something like this for sales order acknowledgements so the email text is customised for each one. For invoices we only do more basic things like storing the email address it’s going to (because Finance demand to be able to see where it went in the record).