BAQ data view problem

Hi everyone,
I have added a BAQ data view to the sales order customisation, see code below, and it compiles without any errors. The fields are available for binding. I have a checkbox on the OrderDtl which is bound to the calculated_issued field of the BAQ, which will tell me if the materials have been issued for this line. When I check the BAQ the value is true but it is not showing in the customisation. Have I missed something out?

public class Script
{
	// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
	// Begin Wizard Added Module Level Variables **

	BAQDataView JobStatusBAQDV;
	// End Wizard Added Module Level Variables **

	// Add Custom Module Level Variables Here **

	public void InitializeCustomCode()
	{
		// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
		// Begin Wizard Added Variable Initialization
			
		CreateJobStatusBAQDV();
		// End Wizard Added Variable Initialization

		// Begin Wizard Added Custom Method Calls
	
		// End Wizard Added Custom Method Calls
	}
public void CreateJobStatusBAQDV()
{
	JobStatusBAQDV = new BAQDataView("Job-Status");
	oTrans.Add("JobStatusBAQDV",JobStatusBAQDV);
	string pubBinding = "OrderDtl.OrderNum";
	IPublisher pub = oTrans.GetPublisher(pubBinding);
	if(pub==null)
	{
		string pubName = Guid.NewGuid().ToString();
		oTrans.PublishColumnChange(pubBinding, pubName);
		pub = oTrans.GetPublisher(pubBinding);
	}
	if(pub !=null)
	JobStatusBAQDV.SubscribeToPublisher(pub.PublishName, "OrderDtl_OrderNum");

	pubBinding = "OrderDtl.OrderLine";
	IPublisher pub2 = oTrans.GetPublisher(pubBinding);
	if(pub2==null)
	{
		string pubName = Guid.NewGuid().ToString();
		oTrans.PublishColumnChange(pubBinding, pubName);
		pub2 = oTrans.GetPublisher(pubBinding);
	}
	if(pub2 !=null)
	JobStatusBAQDV.SubscribeToPublisher(pub2.PublishName, "OrderDtl_OrderLine");
}

Best regards
Adrian.

The code works, I just copied and pasted it into a new customization to test it out. Is it an issue with the data type you are binding? What if you make a new calculated field and bind it to a text box?

Hi @Carson,
Thanks for coming to my rescue again. I added a text box as you suggested and bound it to the JobNumber field of the BAQ and it worked, but although the Issued tickbox on the BAQ is true, the tickbox on the order remains false.

image

image

Can you tell me the syntax for referencing the fields in the BAQ in the customization code? I want to display a message showing me the value in the BAQ.

Thanks again for your help.
Adrian.

I just tried making a calculated bit field in the BAQ and it worked fine.
In code you can reference the BAQ Dataview just like any other epidataview.

			EpiDataView edvJobStatusBAQDV = ((EpiDataView)(this.oTrans.EpiDataViews["JobStatusBAQDV"]));
			System.Data.DataRow edvJobStatusBAQDVRow = edvJobStatusBAQDV.CurrentDataRow;
			if ((edvJobStatusBAQDVRow != null))
			{
				MessageBox.Show(edvJobStatusBAQDVRow["Calculated_Test"].ToString());
			}

Adrian and I looked at it together and the problem was the BAQ was returning multiple rows for a given sales order line. I suppose a good thing to do with a BAQ Dataview when using it to return a single value is to bind it to a grid while testing to ensure you don’t have multiple rows.

Thanks for all your help with this @Carson. I would never have got there without it.

Best regards
Adrian