Querying open order total in BPM

Dabbling in BPM - looking for some guidance from you more experienced folk.

I have a BPM set up to send an email when a customer is placed on credit hold. I would like to include in the same email the total value of open orders for that same customer when the alert goes out.

Ideas on the best way to accomplish this? It looks like custom code is required here.

Wouldn’t you like to know the total of open invoices as well?

Might be easiest looking at the the GLBCustCredit table to do this.

  • An intrans
  • Condition if credit hold changes from any to true.
    *Grab the custnum, store in a bpm data field.
  • Call a standard BPM.

In the Standard

  • Condition "called by the in trans bpm
  • Do a DB loolkup in custom code something like
decimal CustNum;

CustNum = callContextBpmData.Number01;

    this.PublishInfoMessage($"{CustNum}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Customer", "Update");

var CustCredit = Db.GlbCustCred.Where(x => x.CustNum == CustNum && x.Company == Session.CompanyID && x.ExtCompany == Session.CompanyID).Select(x => new{ x.ARTotal, x.SOTotal}).FirstOrDefault();

if (CustCredit != null)
  {
    this.PublishInfoMessage($"ARTot: {CustCredit.ARTotal} SOTotal: {CustCredit.SOTotal}", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Customer", "Update");
  }
else
  {
    this.PublishInfoMessage($"Uh Oh GLBCustCredit Is Null!", Ice.Common.BusinessObjectMessageType.Information, Ice.Bpm.InfoMessageDisplayMode.Individual, "Customer", "Update");
}

Take the two values and use them in your email, and format as desired.

I made a a little example, and then realized you are on 10. and my example is in 2024.2
2024.2.6_GetCreditInfo.bpm (36.2 KB)

There are probably other ways. to do this like a method directive.

2 Likes

I like @Hally 's idea and it is certainly one way to do it that is pretty straightforward.

Another idea you might consider that would leverage existing Epicor features/reports:
Use the AutoPrint widget in the Standard Directive and output to email. You can select an AR Aging report filtered to that customer and/or a Sales Order Backlog report filtered to that customer. The only “downside” of emailing using this method is that it’s a simplified email formatting window where you can only directly specify the fields.

Bonus:
If you use Advanced Print Routing (APR), you can select a report style with a routing and then you can do APR things with the email if you want… In the AutoPrint widget you could set it to AutoPreview and then in the routing send the email so it doesn’t pop up to the user that triggered the BPM. Let me know if you have any interest in this route (haha pun intended). I will do some testing.

2 Likes

Thank you - I am on an updated version, unsure how to update that here.

Click your avatar at the top right
Then click the little person icon (see Below)
image

Then click Preferences then Profile and scroll down you will see the version option. You can update there.

Hi
You can do this using a combination of pre and post Method Directives on the Customer.Update Method/BO

Create a pre-processing directive with the folowing condition:
The ds.Customer.CreditHold field has been changed from False to Other
Then add a Set BPM Data Field widget
Set the callContextBpmData.Number01 field of the BPM Data to the ds.CustomerRow.TotOrderCredit expression
Then add an Enable Post Processing Directive widget

Now create a Post-Processing Directive with the following condition:
This directive has been enabled from the XXXX directive
where XXXX is the name you gave your pre-processing directive
Then add a Send Email widget where you can incorporate not only the standard dataset fields (customer id, name etc. but also the callContextBPM data value)

As per a previous post, if you want to include the open invoice value as well as the open order value then you can populate callContextBpmData.Number02 with ds.CustomerRow.TotInvoiceCredit so that this value can be included in the email as well.

If you are using Global Credit (i.e. shared credit across multiple companies for the same customer) then you will probably need to tweak the above to use the Glb prefixed fields

You’re awesome

1 Like