Automatically add a pricelist to a customer

Hi all,

I am trying to add a default pricelist “Dflt-Pricelist” to customers. Does anybody have any ideas of the simplest way to achieve this. I am not a programmer so do not have extensive knowledge of programming.

Thanks is advance for any help

I would do it with a Method Directive BPM.
First you need to determine at which point in the Customer Creation process you want to add the Price List. The best way to do this is to document the typical Customer Creation process and note when the user adds the Price List, that will get you closer to the correct Method to put the BPM on.
If you enable trace during this, it will give you all the Method calls and data passed during the process, which is were I got all the following method and argument specifics.
Otherwise you could use the Customer.Update method and set the criteria to ‘at least one new record is added’
I would start with attempting this:
A Post Method Directive not a Pre.
Then use the ‘Call Method’ widget and select Customer.GetNewCustomerPriceList and pass the CustNum and or ShipTo arguments
Then use another ‘Call Method’ widget and select Customer.ChangeListCode and pass the listCode value (your PriceList ID) and the table value (which would be ‘Customer’)

Not done this, not sure it would work, but for Low/NoCode, this is where I would start and work out the issues as I go.

1 Like

I do almost the exact same thing you’re saying and can confirm it works well. I used code instead of widgets though.

Hi Rick,

Thanks for the response. I tried your method but couldn’t get it to work but continued trying to get it to work but unfortunately so far no luck.

Hi TomAlexander,

Thanks for the response. I am capable of some programming but not to this level. It would be interesting to know how you did this.

@digimick1967
Can you provide some of the details of how your attempted to accomplish this?
Such as the Method you tried to use and maybe a screenshot of your BPM?

Maybe I am just weird, but I struggle using the widgets and am not even sure how to set them up right to mimic the code I have. Here is code that I think would work for your situation:

  1. Pre-processing method directive on Customer.Update. This just flags newly added customers so that the next BPM fires when it needs to.
foreach (var added_CustomerRow in ttCustomer.Where(c_a => c_a.Added()))
{
  this.callContextBpmData.Checkbox05 = true;
}
  1. Post-processing method directive on Customer.Update. This does the actual work of adding the price list(s). The bit at the end does a “refresh”
if (this.callContextBpmData.Checkbox05)
{
  this.callContextBpmData.Checkbox05 = false;
  int custNum = ttCustomer.Select(c => c.CustNum).FirstOrDefault();
  var dataSet = this.ds;
  var custSVC = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.CustomerSvcContract>(this.Db);
  using (custSVC)
  {
    custSVC.GetNewCustomerPriceLst(ref dataSet, custNum, "");
    custSVC.ChangeListCode("Dflt-Pricelist", "Customer", ref dataSet);
    custSVC.Update(ref dataSet);
     
    this.dsHolder.Attach(dataSet);
  }
}
1 Like

@digimick1967
Here is a screenshot of the working Method Directive.
It’s on Customer.Update, but you could put it on something else depending on WHEN you want the PriceList added.
All I did was run a trace on Adding a Price List and I documented which Methods were called and noted the Parameters that were passed, then we just replicate that in the BPM.

First we set a Variable to Todays Date to use in a Query to check to see if the Customer’s Est Date is NOT today and the Default Price List doesn’t already exist:

If there are zero rows returned from the query, we then call GetNewCustomerPriceList and pass appropriate parameters:

Then we call ChangeListCode and pass the appropriate parameters, specifying the PriceList Code and the tablename of ‘Customer’:
image

Then to save it all, we call Update:

In all the Method calls, for the Customer Tableset we just use the current DataSet when is the ‘var: ds’ in the dropdown.

Thank you very much for the time you have spent.
I did try this and it worked.
However, when I tried deleting the customer it crashed and through me out of Epicor so I tried to delete customer again with BPM disabled and this worked and I could not resolve the issue but thanks again for your help it has assisted me in the way I look at resolving problems in Epicor and is appreciated

Thank you very much for this, I’ll admit I first tried using the widgets method for ease but after several issues that I couldn’t resolve I came back to your code which worked immediately. Thank you so much :wink:

1 Like