I am currently facing an issue with trying to POST a new customer using the REST API in Epicor /{currentCompany}/Erp.BO.CustomerSvc/Customers (Calls UpdateExt to create new item for the service). Normally, when a user creates a new customer on the front-end, they only need to input the first name and last name, and the system generates the CustID using a method directive (Erp.BO.Customer.GetNewCustomer). This directive has both pre and post processing to generate a unique CustID based on certain rules.
However, when I try to use the REST API to create a new customer, I get an error that the CustID is a required field. I have tried removing the CustID or setting it to “”, but I get errors.
I would like the system to generate a unique CustID automatically, just like it does when a user creates a new customer on the front-end, not the pre-defined field in the request. I found a custom method in the Swagger page called /{currentCompany}/Erp.BO.CustomerSvc/GetNewCustomer, but I am not sure how it works as all requests receive a successful response but no data is updated in the database.
If anyone has experience with using the REST API and method directive for generating CustID or other fields in Epicor, I would greatly appreciate any guidance or advice you can offer.
What helps me with these questions is to remember that my interface has to act like the client, which is using these same calls. The best way to see this is to do a trace first and log what the client does. How would you enter a customer at the client without entering the CustID? Out of the box, you can’t. However, you can utilize a BPM to generate one for you to satisfy the requirement. Once that is working, you now can make the correct REST calls in the right order to accomplish your goal.
Ok, that’s an ODATA method, You are probably going to want to call the Custom methods because
you obviously already have custom bpms that modify behavior.
That’s not standard out of the box behavior, and I’m not sure about 10, but in 11, There is no firstname or lastname fields in the dataset.
Anyway, you are going to first want to call the custom method GetNewCustomer with the same kind of dataset it expects. You can find it from a trace.
You probably won’t have to pass it a complete dataset, probably just the parts you need.
If all goes well you will get back a dataset with the skeleton of a new customer with your data from your custom methods on getnewcustomer.
You will have to trace from there, and fill out whatever else is required in that dataset, before calling update/updatext with it.
So the custom method I assumed and tried is not the correct one. I traced how custid is generated, and found the correct custom method, so I nested the requests and now working