Help needed to update QuoteQty value in C#

Hi all,

I need to update the QuoteQty table in C# and I can’t seem to find a way to make it work correctly, so If anyone could help, it would be greatly appreciated !
Here’s the picture:
When quoting, People in the sales dept. sometimes have to input the price manually on the line, because the part has no price in it. An issue arise when the ShipTo ID is change, it triggers a recalculation of the quote, and all prices entered manually are lost.

I thought I could then just fix it this way:

  • In the Before Field change event on the ShipToNum field, take a copy of the QuoteQty table to store the current prices in a static datatable.
  • Then in the BeforeAdapter Update event, restore the prices to the QuoteQty dataview before saving to the database.

The first part is working, I can copy the data, but when I tried to restore it to the dataview, no matter how I try or where I place the code, I almost always get the same error " Cannot find the row in the database".
Here’s an example of what I tried: (vicQuoteQty is my datatable where I store original info)

foreach(DataRow qqtyRow in edvQuoteQty.dataView.Table.Rows)
{
string expression = “QuoteNum = " + qqtyRow[“QuoteNum”].ToString() + " AND QuoteLine = " + qqtyRow[“QuoteLine”].ToString() + " AND QtyNum = 1”;
DataRow[] vQtyRows = vicQuoteQty.quoteQtyTable.Select(expression);
foreach(DataRow vQtyRow in vQtyRows)
{
qqtyRow.BeginEdit();
qqtyRow[“DocUnitPrice”] = vQtyRow[“DocUnitPrice”];
qqtyRow.EndEdit();
}
}

The error I get is:

Exception caught in: Epicor.Mfg.BO.Quote

Error Detail

Message: Cannot find the row in the database.
Type: Error
Program: Server/bo/Quote/Quote.p
Method: QuoteQtyUpdateRow
Table: QuoteQty
Row: 0x000000000f6010a5
Field:

What am I missing ?

I’m still learning but this sticks out:

Don’t you have to access a certain table from the view, i.e. …dataView.Table[0].Rows?

If you aren’t sure which table to use, you could view the dataView in the Object Explorer while in customize mode to see the structure.

Hi Chris,

Thanks for your suggestion, but this is the correct way of using it. The .Table property of the dataview gets the source table from which the dataview was generated. If I was working with a dataset, then yes I would need to specify which table I want.

I could also have used the following:
foreach( DataRowView qqtyRow in edvQuoteQty.dataView) to loop through the dataview rows directly instead of the source table.

I see. It looks like I mixed apples and oranges. Here is the way I was accessing a specific row (turns out I was not iterating the rows)


EpiDataView edvRQ =  (EpiDataView)(oTrans.EpiDataViews["RQ"]);
edvRQ.dataView[edvRQ.Row]["CurrentQty"] = myPart["PiecesPerBox_c"];

Sorry for the misinfo :blush:

On a related note, how did you get the rerference to edvQuoteQty. If for some reason the ref wasn’t valid, it could be null and fail on the first line - foreach. Have you written a check to see if it’s null by chance? May be a long shot but I figured I’d think out loud.

Ha it’s ok, I always appreciate when people at least try to help. :slight_smile:

In fact, my problem is that I am unable to commit the changes to the database, as you can see in the error message I get.
Everything seems to be is working fine before that, no compile error, my dataTable clone gets populated with the original QuoteQty datatable values and I can validate it is working by debugging in Visual Studio and see that the fields are changed in the dataview after my loop.

The row ID specified in the error is there, so I don’t understand what’s wrong. I did this kind of customization many times before with other dataViews, this is the first time i’m stuck like that.

1 Like

So… I’m in the exact same boat as you. Did you ever get this running by chance? I appreciate any feedback you have. I’m starting to think this is impossible. I’ve exhausted every BPM route, I’ve exhausted a BPM-Customization-CallContext route, and now I’m about to exhaust the Customization route because of this error.

grumble grumble

Hi Jeremy,

Yes I finally came up with something that works for us. My solution uses ABL code in a BPM and a UDtable.

Method directive on Quote.Update:

  • Pre-Proc, Condition = ttQuoteHed.ShipToNum has been changed from any to any

  • Actions (10) = Synchronously execute ABL. The code here, based on some conditions, copies the value of the following fields to a UDtable:
    QuoteHed.QuoteNum, QuoteHed.QuoteLine, QuoteQty,Quotenum, QuoteQty.UnitPrice,QuoteDtl.Docdiscount

  • Action (20) Set the CheckBox01 field of BPMData to the true expression (use as a flag to trigger post-proc)

Post-Proc

  • Conditions: the ttCallContextBpmData.checkbox01 field is equal to the true expression

  • Actions(10) - Synchronously execute ABL: takes the value from the UDtable and put them back in the QuoteTables.
    Actions(20) Set the checkbox01 field of BPMData to the false expression (reset the flag)