Prevent Sales Order without Valid Part Number

We booked, shipped and invoiced a sales order with a valid part number. It wreaked some havoc. Is there a setting in Company Configuration that would require a valid part number in sales order entry?

I looked all over to no avail.

Thanks in advance,

Randy Weber

I don’t know of any setting out of the box that would do this.

You could easily address this through a BPM on the ChangePartNum or ChangeRevisionNUm method.

2 Likes

there is not. Epicor will allow you to add a part on the fly in the sales
order, make it direct or purchase it direct to the order, ship it and
invoice it

If you do not want that to happen you will have to write a simple BPM when
the part is not part of your part master to pop up a notice to the user and
not allow them to enter the order line until a valid part number is entered

Mark Wagner
Sr. Partner

Capstone Alliance Partners 888.597.2227 Ext. 71
<888.597.2227%20Ext.%20714>2 | 904.412.6847 mwagner@capstoneap.com (cell)

1 Like

i used a method directive, salesorder.masterupdate

here’s the code i wrote. you can remove the part revision portion. you can modify to check the part table.

Erp.Tables.Part Part;
Erp.Tables.PartRev PartRev;
Erp.Tables.Company Company;

// check if they are adding a line
foreach (var ttOrderDtl_iterator in (from ttOrderDtl_Row in ttOrderDtl
where string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_ADDED, StringComparison.OrdinalIgnoreCase)
|| string.Equals(ttOrderDtl_Row.RowMod, IceRow.ROWSTATE_UPDATED, StringComparison.OrdinalIgnoreCase)
select ttOrderDtl_Row))
{

var ttOrderDtlRow = ttOrderDtl_iterator;

PartRev = (from PartRev_Row in Db.PartRev
        where string.Compare(ttOrderDtlRow.Company, PartRev_Row.Company, true) == 0 
					&& string.Compare(ttOrderDtlRow.PartNum, PartRev_Row.PartNum, true) == 0
					&& string.Compare(ttOrderDtlRow.RevisionNum,PartRev_Row.RevisionNum, true) == 0
        select PartRev_Row).FirstOrDefault();

	if (PartRev == null)
{
		CallContext.Current.ExceptionManager.AddBLException("Error: The part number and revision does not exist.");
	}

}

2 Likes

I tried the code and I get a CS0103 The name ttOrderDtl does not exist in the current context.
I will try to debug it, but if I could get pointers on what to fix to make it work I would appreciate it.
Thank you!

What version of Epicor are you on? That might be the issue. Please create a new thread as this one is a bit old to resurrect.

Kinetic 2023.2.11

try ds.OrderDtl

1 Like

thank you
Seems I have to use Db in our coding. I will debug trying to compare what was coded for other methods. At least the code provided in this thread will get me started.

db is the database itself.

ds is the dataset from the client.

So here is my final code that seems to be working fine after a few tests :

foreach (var sod in ds.OrderDtl.Where(od => od.RowMod == "A" || od.RowMod == "U")) 
{
    // VĂ©rifier si le PartNum dans OrderDtl est valide
    var part = Db.Part.Where(p => p.Company == sod.Company && p.PartNum == sod.PartNum)
                      .FirstOrDefault();

    // Si aucun PartNum correspondant n'est trouvé, lance une exception
    if (part == null) 
    {
        throw new Ice.BLException($"Le numéro de pièce '{sod.PartNum}' est invalide.");
    }
}

You can make the query an .Any so sql will return just a bool rather than the part record.

/* check part exists */

foreach (var sod in ds.OrderDtl.Where(od => od.Added() || od.Updated()))
{
    // VĂ©rifier si le PartNum dans OrderDtl est valide
    bool partExists = Db.Part.Any(p => p.Company == sod.Company && p.PartNum == sod.PartNum);
    
    // Si aucun PartNum correspondant n'est trouvé, lance une exception
    if (partExists == false) 
    {
        throw new Ice.BLException($"Le numéro de pièce {sod.PartNum} est invalide.");
    }
}

I formatted your code with ticks for readability

Thank you
I will try this out.