I am currently facing a problem managing my vendors in Epicor. Several of them have been registered two or more times, so I am looking for a way to prevent this situation.
The idea is for a vendor to be unique, considering the fields Company, TaxPayerID, and CurrencyCode
Create a BPM (Business Process Management) as follows:
the custom code is:
bool vExist = false;
foreach (var ttVendor_Recs in (from ttVendor_Row in ttVendor where ttVendor_Row.RowMod == IceRow.ROWSTATE_ADDED
select ttVendor_Row))
{
var ttVendorRow = ttVendor_Recs;
if (ttVendor_Recs != null)
{
var Vendor_Recs = (from Vendor_Row in Db.Vendor
where Vendor_Row.Company == Session.CompanyID && Vendor_Row.TaxPayerID == vTaxPayerID && Vendor_Row.CurrencyCode == vCurrencyCode
select Vendor_Row).FirstOrDefault();
if (Vendor_Recs == null)
{
// Epicor.Customization.Bpm.InfoMessage.Publish("No Records");
vExist = false;
}
else
{
vExist = true;
}
}
}
The exception should be triggered, but it is firing when a record is added, updated, or deleted.
How can I prevent this and ensure that my records are not duplicated?
Am I on the right track to execute this BPM, or am I completely wrong in what I’m doing?