BAQ Data View with Parameters Error

I’ve been reading the following the posts about pulling data from a BAQ into a Form with Parameter executing the data. 2 I have working without issue, the third gives an error however it still works. Trying to figure out the error. The first 2 only have 1 parameter on the query for the PartNum. The last one is using CustNum and PartNum.

If I load the form and make a new order, BAQ’s work correctly each time. Part UOM’s, Part On Hand Qty’s and Sales History for the Part by that Customer all populate each time.

The Business Logic Error only happens when i load the form and then load an existing order. As soon as the form populates the Header screen I get a Popup window with “The parameter CustNum has no value specified and empty value is not allowed”. When I go to the Lines Tab and click on the part number field, the form refreshes and all data is correct. This only happens on an existing order. I thought it was the parameter settings on the baq but they are both flagged as “ignore if empty”

Attached the BAQ i’m using and the section of code, any help much appreciated

CustPastSO.baq (29.7 KB)

Code.txt (4.6 KB)

What if your code retrieves the partNum and custID from the data view instead of the native controls?

pardon the question but i’m not a programmer by trade, i just read lots of books on this stuff trying to figure things out. Pull it from the data view? i dont know how you would do that

dataviews aren’t my specialty. I was guessing that your function fires before the UI is updated. And since your function gets the partNum and CustID from the UI form (via the GetNativeControlReference() calls), that it was using the Partnum from the line you were previously on. In other words, the UI isn’t up to date yet, when your code runs.

Instead of :

var partNum = (EpiTextBox)csm.GetNativeControlReference("b7505712-6225-4cce-90bb-c39ee8c9efae");
var custID = (EpiTextBox)csm.GetNativeControlReference("6a911f64-73a8-4b1a-a837-756b05cbd4d3");

use

string partNum = (string)view.dataView[args.Row]["PartNum"];
string custID = (string)view.dataView[args.Row]["CustNumCustID"];

Note

  1. My variables are the string values, so no need for the .Text where you use them
  2. The column name for the custID in the OrderDtl dataview is different than you might expect.

That worked. Thank you. Had to redo the BAQ to throw nvarchar instead of an int. WHile I named the parameter custID i was actually pulling the CustNum field. Again… not a programmer, live and learn.

Redid the BAQ to pull CustID and PartNum with both nvarchar’s, changed the code to your 2 strings and it pulled through the data without an error. Again thanks