Sales Order Detail - Lookup Vendor Id and Name When Part Number is Chosen

I would like to customize our Sales Order Detail tab so that when a Part is selected, the system looks up the vendor id and name and populate them into applicable custom fields:

2019-09-06%2011_42_35-Window

However, there doesn’t appear to be a link between part numbers and vendors - any ideas on how I could go about looking up the Vendor Name and Id when a part number is selected?

I would think maybe a BPM on whatever the method is that changes the part Number and then you could perform a lookup to a BAQ that returns back the Vendor Name and passes it to your custom field(s) would be appropriate.

Hi Jeff,

You might already be aware of this, but in case not, if you setup the part as buy to order in part master and put vendor on it, the data will automatically populate on the sales order release.

Nancy

1 Like

I don’t think that will auto-populate on the Order, until the PO is placed.

You can enter a supplier if you want. But I think that is just to aid purchasing suggestions.

Thank you all. Yes, despite the Buy To Order “feature” they strongly desired a standalone feature on the Order Detail tab.

I ended up going with a UI customization and a BAQ:

Customization Script:

private void OrderDtl_AfterFieldChange(object sender, DataColumnChangeEventArgs args)
{
	switch (args.Column.ColumnName)
	{
		case "PartNum":
			try
			{
				string partNumValue = Convert.ToString(args.ProposedValue);
				if(partNumValue == "") return;
				
				DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
				dqa.BOConnect();
				QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("GetVendorInfoByPartNumber");
				qeds.ExecutionParameter.Clear();
				qeds.ExecutionParameter.AddExecutionParameterRow("PartNumValue", partNumValue, "nvarchar", false, Guid.NewGuid(), "A");
				dqa.ExecuteByID("GetVendorInfoByPartNumber", qeds);

				string vendorNumValue = "";
				string vendorNameValue = "";

				if(dqa.QueryResults.Tables["Results"].Rows.Count > 0)
				{
					vendorNumValue = dqa.QueryResults.Tables[0].Rows[0][0].ToString(); // VendorNum
					vendorNameValue = (string)dqa.QueryResults.Tables[0].Rows[0][1];  // VendorName
				}

				EpiDataView edvOrderHed = (EpiDataView)oTrans.EpiDataViews["OrderDtl"];	
				edvOrderHed.dataView[edvOrderHed.Row]["SupplierName_c"] = vendorNameValue;
				edvOrderHed.dataView[edvOrderHed.Row]["SupplierId_c"] = vendorNumValue;
			} catch(System.Exception ex) {
				ExceptionBox.Show(ex);
			}
			break;
	}
}

BAQ:

select top (1)  
	[VendPart].[VendorNum] as [VendPart_VendorNum],
	[Vendor].[Name] as [Vendor_Name]
from Erp.VendPart as VendPart
inner join Erp.Vendor as Vendor on 
	VendPart.Company = Vendor.Company
And
	VendPart.VendorNum = Vendor.VendorNum
 where (VendPart.PartNum = @PartNumValue)

Working like a champ - so far. :wink:

1 Like

Hi Calvin,

I thought dohp (homer simpson) and then checked. It does indeed populate without running suggestions, nor mrp. I do have generate PO suggs checked on the part / site but I didn’t run it and get this:

Nancy

All you did was enter the part (after setting it up as BTO, and adding an approved vendor and vend Partnum) on the SO Line?

When I do that the part does create the release as BTO, but the supplier fields (ID and name) remain unchanged.

I even tried with the Part as Qty-Bearing and not Qty-Bearing

Yep, I just entered the part on the sales order line and got the vendor info. One difference on mine, I have vendor in the Part / Site field per below:

2 Likes

Adding it to the Part\Site\Detail is the key.

Turns out you don’t need to add the vendor as an approved vendor for the part. Just need the Part to be BTO, and set the supplier on the site.

Works, regardless of the Qty Bearing field. Although that will affect the PartTran Type
BTO && QtyBearing := PUR-STK
while
BTO && NOT QtyBearing := PUR-UKN

1 Like