Passing information from MES grid to BAQ report

What I am trying to do is pass the select Job/Asm/Opr to a BAQ report as option fields. Normally when one starts a job from MES, the row they have selected in the LaborDetails grid will determine which Job/Asm/Opr they clock on to. I would imagine that I need add the BAQ report form to MES as a button, and then have some sort of customization in MES so that when that the button is clicked, it picks up the information, and passes in to a customized BAQ report that fills the fields accordingly.

Is the LaborDetails grid accessible as a DataView?

2

you’ll need a few things. First yes, you can access that grid as a dataview and get the values you need. Second you will use something called launch form options (LFO), third, you’ll need a UI customization on your BAQ report to use and assign those values passed thru in the LFO context. There are a multitude of examples on this sight in how to declare and access a dataview. I suggest the search function to help yourself there. below is an example of how you could pass values using an LFO. This could be an object such as a datarow, a list, a dictionary etc…

here is an example of how to use LFO

private void btnPrintAll_Click(object sender, System.EventArgs args)
{
     String jobList = "";
     List<UltraGridRow> rr = myGrid.Rows.GetAllNonGroupByRows().ToList();
     LaunchFormOptions lfo = new LaunchFormOptions();
     //  In your case you may want to use the selected rows property instead
     foreach (Infragistics.Win.UltraWinGrid.UltraGridRow row in myGrid.Rows)
     {
          if ((bool)row.Cells["Print"].Value == true)
          //  We are passing a list of jobs for the BAQ report filter
          jobList += string.Format("'{0}',", row.Cells["OrderHed_OrderNum"].Value);
     }
     lfo.ContextValue = jobList.Substring(0, jobList.Length - 1);
     lfo.IsModal = true;
     // this launches the menu item, in this case a BAQ report
     ProcessCaller.LaunchForm(oTrans, "TRAVBPR", lfo);
}

in your BAQ report customization the pass context values are used as shown. Keep in mind that different BAQ reports reference parameters in slightly different ways.

declare a public class variable
EpiDataView edvReportParam;
instantiate the object in initialize customcode
edvReportParam = oTrans.Factory(“ReportParam”);

	private void BAQReportForm_Load(object sender, EventArgs args)
	{
		// Add Event Handler Code
		if(BAQReportForm.LaunchFormOptions!=null && BAQReportForm.LaunchFormOptions.ContextValue !=null)
		{
			DataSet ds = (DataSet)((Dictionary<string,DataSet>)oTrans.GetType().GetField("filterDataSets", BindingFlags.Public 
	                                             | BindingFlags.Instance 
	                                             | BindingFlags.NonPublic).GetValue(oTrans))["FilterList2"];
			EpiDataView edv = oTrans.Factory("FilterList2");
            // Filterlist 2, because it's the second of two filters defined in the BAQ report
			ds.Clear();
			bool recordSelected=false;
			string[] orders = BAQReportForm.LaunchFormOptions.ContextValue.ToString().Split(',');
			

			int split = (orders.Length / 30);
			if(orders.Length % 30 > 0)
				split++;
			int index=0;
			OrderHedListDataSet holdingDS = new OrderHedListDataSet();
			for(int i =0; i<split;i++)
			{
				string ordersS ="";
				for(int c=0; c<30;c++)
				{
					if(orders.Length >index)
					{
						ordersS+= orders[index]+",";
						index+=1;						
					}
					else
						break;
				}
				string whereClause = string.Format("OrderNum in ({0})",ordersS.Substring(0,ordersS.Length-1));
				DataSet dataSet = SearchFunctions.listLookup(oTrans, "SalesOrderAdapter", out recordSelected, false, whereClause, true);
				holdingDS.Merge(dataSet,true,MissingSchemaAction.Ignore);
				
			}
			ds.Merge(holdingDS, true, MissingSchemaAction.Ignore);
			edv.Notify(new EpiNotifyArgs(oTrans, edv.dataView.Count-1, EpiTransaction.NotifyType.Initialize));	
						
			//oTrans.GetType().GetMethod("refreshFilterSummary", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(oTrans, null);
			oTrans.RefreshFilterSummary();	
		}
        edvReportParam.dataView[edvReportParam.Row]["ArchiveCode"] = 1;
	}

as you can tell it’s not a trivial endeavor but it can be done. This should give you a start though.

2 Likes

Thank you! I have set up LFO in the past, so I should be able to do that. I guess my question is, how do I determine what the DataView I need to reference is? For example, I have a DataView on a customization for Start Production, which is called “Start”. I find that out from someone on this forum, but otherwise how would I know what the DataView is called, and what the field names are?

Update: I checked out the EpiBinding for the grid, and it says LaborDtl. So I used that, and I can pull a field from the DataView!

Normally I would fill fields in a form with a DataView, but for the BAQReportForm they are option fields, so I’m not sure how to access that as a DataView.

Update: This thread got me up and running: Pass 3 fields from a deployed dashboard-assembly to a BAQ Report Print - #3 by shobdy - ERP 10 - Epicor User Help Forum

However, if I close the Report form, and then click on my MES button again to reload the form, the fields will not fill in (as if the custom code isn’t running). I tried using the solution in this thread, but it still doesn’t work: https://epiusers.help/t/mes-form-load-only-triggers-once-per-session/38275

@rbucek ,
In the past I have passed data to a BAQReport customization for a ‘Option’ criteria and other Report Parameters, but I am now for the first time attempting to pass data to a BAQReport to be used as a Filter. The code you posted here looked really close to what I am trying to do, but I don’t understand all of it and in my case I am only passing a single value that needs to be added to the FilterList2.
When I started piecing this code together, the first error I ran into was that the ‘Dictionary’ namespace was not found, but I don’t see any ‘using’ reference in your code example. Nor am I sure what it’s doing and if I need it. Here is the line that is throwing a compilation error:

DataSet ds = (DataSet)((Dictionary<string,DataSet>)oTrans.GetType().GetField("filterDataSets", BindingFlags.Public
			| BindingFlags.Instance
			| BindingFlags.NonPublic).GetValue(oTrans))["FilterList2"];

Can you shed some light on how to populate a BAQReport Filter List?
Thanks!