I assumed if I I commented out all but the 1st two lines of the CreateHoursBAQView function (where is sets the view) I would get all the data that shows when testing the BAQ, but that still shows no data…
My code is below, I get all 3 MessageBoxes on load.
[details=THE CODE]```cs
// **************************************************
// Custom code for MesActivityForm
// Created: 5/11/2017 8:37:46 AM
// **************************************************
using System;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Windows.Forms;
using Erp.Adapters;
using Erp.UI;
using Ice.Lib;
using Ice.Adapters;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
using Ice.Lib.Broadcast;
public class Script
{
// ** Wizard Insert Location - Do Not Remove ‘Begin/End Wizard Added Module Level Variables’ Comments! **
// Begin Wizard Added Module Level Variables **
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
BAQDataView baqViewHours;
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
// End Wizard Added Custom Method Calls
CreateHoursBAQView();
}
public void CreateHoursBAQView()
{
baqViewHours = new BAQDataView("HLI-EmpHours");
oTrans.Add("MyHoursBAQ",baqViewHours);
string emp = ((Ice.Core.Session)(oTrans.Session)).EmployeeID;
string pubBinding = "LaborHed.EmployeeNum";
IPublisher pub = oTrans.GetPublisher(pubBinding);
MessageBox.Show( "Session EmpID: " + emp );
if(pub==null)
{
MessageBox.Show( "pub = null" );
oTrans.PublishColumnChange(pubBinding, "MyCustomPublish");
pub = oTrans.GetPublisher(pubBinding);
}
if(pub !=null)
MessageBox.Show( "pub != null" );
baqViewHours.SubscribeToPublisher(pub.PublishName, "EmpBasic_EmpID");
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
I ran across several places where the EmployeeID was not being populated by the system. I took matters in to my own hands to solve it. Here is what I did in my part tran bpm to fix it. You could do a null check first to make sure it’s needed. I also did something similar in a Receiving BPM.
ttPartTran.FirstOrDefault().EmpID = Session.EmployeeID; // aglitch in E10 cause it not to log the EMP
The messagebox shows up with the current EmpID, so I don’t think thats the issue.
I don’t think it’s an issue with the Publish & Subscript, if I just attached the BAQ to the grid without subscribing it to anything, shouldn’t I get all the data I get when I test the BAQ? I do not; I get no data…
Yes, both LaborHed_EmployeeNum and EmpBasic_EmpID, not that both are
needed. It’s showing all LaborHed records for the last 2 weeks and I want
to filter it by the Logged in EmpID.
I think a workaround might be to make a new (or modify existing) BAQ to use the EmployeeID as a parameter. If your BAQ returns the proper results in the designer when you type the employee as a parameter, you’ll get the same results in the code. Of course, you could just have your BAQ built to get only the current EmployeeID record right out of the gate by using BAQ special constant CurrentEmployeeID and bypass the parameter altogether.
For the dashboard, modify it to be blank. Then open the dashboard and customize it. Add a blank UltraGrid and then use dynamic query adapter to populate it (get EmpId and pass as parameter). We’d basically be leveraging the dashboard as a free form (thanks to @josecgomez for this idea) and handling the rest manually.
Here is some code I use to call a BAQ with parameter and feed it to a grid (in your case you’d get Session.EmployeeID - I think that’s what it’s called):
//---- Setup printer list-----
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("Printer_By_Company_CC");
qeds.ExecutionParameter.Clear();
qeds.ExecutionParameter.AddExecutionParameterRow("COMPANY",((Ice.Core.Session)oTrans.Session).CompanyID,"nvarchar",false,Guid.NewGuid(),"A");
dqa.ExecuteByID("Printer_By_Company_CC",qeds);
//MessageBox.Show(dqa.QueryResults.Tables["Results"].Rows.Count.ToString());
if(dqa.QueryResults.Tables["Results"].Rows.Count > 0)
{
//SET TO GRID HERE........
PrinterGrid.DataSource = dqa.QueryResults;
//PrinterGrid.DataSource = dqa.QueryResults.Tables["Results"]; this works too
@josecgomez – I don’t think it’s SUUUER BIG… 687 rows, 6 columns. Runs in 55 ms. I’m going to try doing the same thing in a different screen and see what happens. Maybe there’s something funky going on in Office MES?
@Chris_Conn, thanks for the other idea, I’ll see if I can make any headway using that as well.
It seems like it should be an easy task to add this simple BAQ to a screen…
I think something weird is going on In Office MES, as I never seem to get any data in either a BAQ grid or a dashboard sheet.
I decided I was making this more complicated then is needed to be there was no real reason to have to add it to Office MES, except for that it was one place to go to verify times and clock out.
So to simplify things and just deploy a dashboard that has a filter for CurrentEmployeeID. Quick & easy and now I can take another thing off my list.
I’m curious if any of the technical limitations of MES could be affecting this? For example, a certain adapter or query not being available\disabled. I’m just thinking out loud.