Function Exception

Still Struggling - no hair left to pull out
Function using strictly widgets
step 1 GetDatasetForTree in the BomSearch BO
step 2 GetaNewUD20 in the UD20 BO
step 3 Update Table by Query to map columns from BomSearch.PartMtl table to UD20 columns
step 4 Update UD20 in the UD20 BO

error message caught in the try-catch block in the UI calling the function:
“Ice.Common.BusinessObjectException: The table BomSearch.PartMtl has more than one record
This is a duplicate entry of an existing record”

I am mapping userID to Key1
dBomSearchPartMtlRow.PartNum to Key2
dBomSearchPartMtlRow.RevisionNum to Key3
dBomSearchPartMtlRow.MtlPartNum to Key4
dBomSearchPartMtlRow.SysRowID.ToString() to Key5

Just as a guess, and I’m not familiar with what BomSearch.GetDatasetForTree returns. But it’s possible that a MoM contains multiple entries for the same subassembly. If so, then depending on Pull As Assembly/Plan As Assembly, I think that subassembly’s materials would be duplicated in the tree.

A
  B
    C
  B - different SysRowID from other B
    C - same SysRowID as other C

If you use code blocks instead of widgets, you can catch the exception and rethrow with more information about the values it’s trying to put in.

Do you have an effective date set? It looks like it takes an as of date? Try it in the BL tester (or swagger using rest) and see what it returns.

Sorted it out - the GetANewUd20 has a “blank” row when it is called. Updating UD20 when the Database already has a “blank” record was causing me grief. I remove the blank row from the UD20 tableset and I am able to write to the db now.

Thanks for the responses

If I understand what you’re saying, that’s how it’s supposed to work. GetANewUd20 should add a row to your tableset where RowMod == “A”. This row isn’t necessarily blank. Some built-in defaults might be populated, as well as any defaults set by BPMs. Find the added row, set your values on it, and call Update to save it.

svc.GetaNewUD20(ref ds);
var row = ds.UD20.Single(o => o.Added());
row.Key1 = id; // etc.
svc.Update(ref ds);

You mean you already had a row in your table where all the keys were all blank, and you were trying to save your tableset with an added row where the keys were also all blank? That would explain it.