I created an POST BPM for an email alert to notify our cost accountant when a mfg-stk transaction has $0 material cost (so she can chase down the outlaws!).
The BPM seems to fire properly, but the added fields in the email template either get repeated, or donāt show at all.
If I chose āAdded Recordsā and āUpdated Recordsā (like we have on all our other BPM Email Alerts), then I donāt get anything at all. If I have āUnchanged Recordsā only, then it shows the field twice.
It was a field query - When I click on the Subject line in the Design Email Template, then click the Insert button, table query doesnāt appear as an option. Weāre on 10.2.300.12, if that changes anything.
I thought maybe copy and pasting the from the subject to the body may have caused it, so I deleted the āinsertsā in the subject, and left it in the body. That messed it up even more! I think Iāll delete the widget and start overā¦
Edit - Tested again, no changeā¦ still showed up twice or not at all.
Usually, when I want to do an email alert that has data, I collect the data in call contexts in a pre, then use those contexts in the post email widget. You could try that and see if that helps.
If I donāt have āUnchangedā checked, then the data fields donāt show up in the email at all.
Darren, it acts the same as the email. If Added and Updated is checked, then nothing. If Unchanged is checked, then double.
Aaron - Thanks. Iāll give that a try. Iād like to learn why my method isnāt working in this case, when we have other BPMās that are nearly identical and it does show the fields properly (in the pop-up msg or email).
FWIW - Iāve occasionally seen multiple values(separated by a comma) for a table query during development. I was told this is when the data set has multiple records. Or in some cases, one value was the existing value, and the other was the new value. I donāt recall exactly what I did in those circumstances, but I was able to resolve it rather without doing anything special
How the added vs unchanged is handled is per BO and a lot of time per call. Some calls esp in the Job area take two records a changed and unchanged record. Other time that is not the case and you just have the changed. Itās seemingly random and likely due to two different camps in Epicor development at different points of time in how dirty rows should be handled. Ever try to use a data directive with āwhere field changedā and it doesnāt work? Thatās one of those cases it needs the old and dirty record and both were not supplied. That can happen with custom code and sometimes even Epicor native doesnāt pass the clean and dirty.
I made a Pre-BPM per Calvinās suggestion, and it worked like a charm. Thanks!
Not quite sure why, but I bet youāre (Josh) onto something. My thinking was that the Post made more sense, since I wanted an alert after the BO did itās thing and the transaction was finalā¦
Sometime you just need a pair that work together. They (Epicor) teach some BPMās like that in their extended ed. You could wait to fire off the e-mail so in your pre, just save the data, then enable the post and use the same criteria to send it with the post. (But only if your pre-proc solution doesnāt work on itās own)
Since in 10 the Newtonsoft library is available native, sometimes Iāll convert an entire dataset into a serialized string, pass it through Call Context to post process, de-serialize and process from there. I will Log.WriteEntry serialized data too if I want to see more of a dataset for debugging BPMs it works nice.
using(CustShipSvcContract csSvc = Ice.Assemblies.ServiceRenderer.GetService<CustShipSvcContract>(Db))
{
CustShipTableset csts = new CustShipTableset();
csSvc.GetByID(ref csts, 85312);
Ice.Diagnostics.Log.WriteEntry($"{Newtonsoft.Json.JsonConvert.SerializeObject(csts)}");
// Use this URL to format the data back to something readable https://jsonformatter.curiousconcept.com/
}