UI Customization; Dashboard Sheet

Alrighty, I’m just now getting back to this. Ever wish you could just focus on one issue at a time?

Anyhow, I’ve managed to add code to create a BAQView from my BAQ and bind it to the EpiUltraGrid. Thanks to @josecgomez for the YouTube video!

My issue is the grid does not populate with any data. The grid shows columns from the BAQ, but no data.

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
}

}

Is there data in the LaborHed DataView? The screen shot you have posted it doesn’t look like it.

Sorry, I think that screenshot was taken while customization was open.

The EmpID field in top right-hand corner is bound to LaborHed.EmployeeNum and it’s populated, but the BAQ is empty.

Norman,

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

Thanks for the idea @Chris_Conn. Here’s what I tried, I added the following code to the CreateHoursBAQView.

	EpiDataView eData = (EpiDataView)oTrans.EpiDataViews["LaborHed"];
	DataRow edRow = eData.CurrentDataRow;
	string empID = (string)edRow["EmployeeNum"];
	MessageBox.Show( "DataView EmpID: " + empID );

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…

let me see your code

So when you run BAQ in designer you can see the EmployeeID?

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.

Thanks,

Norman Hutchins
System Administrator
Howell Laboratories, Inc.

Can you paste the code you are using to load the BAQDataView

But of course I can.

	public void CreateHoursBAQView()
	{
		baqViewHours = new BAQDataView("HLI-EmpHours");
		oTrans.Add("MyHoursBAQ",baqViewHours);

//DataView Check
EpiDataView eData = (EpiDataView)oTrans.EpiDataViews["LaborHed"];
DataRow edRow = eData.CurrentDataRow;
string empID = (string)edRow["EmployeeNum"];
MessageBox.Show( "DataView EmpID: " + empID );

//Core Session Check
string emp = ((Ice.Core.Session)(oTrans.Session)).EmployeeID;
MessageBox.Show( "Session EmpID: " + emp );

		string pubBinding = "LaborHed.EmployeeNum";
		IPublisher pub = oTrans.GetPublisher(pubBinding);

		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");
	}

So if you just have this

baqViewHours = new BAQDataView("HLI-EmpHours");
oTrans.Add("MyHoursBAQ",baqViewHours);

And nothing else, do you get data on the grid? Also when is this running ? which method are you calling this from?

Correct if I comment out all but those 2 lines, no data shows up on the grid.

CreateHoursBAQView(); is being called from InitializeCustomCode().

And I am assuming that HLI-EmpHours doesn’t have any parameters or anything like that right?

Correct as well. Just a straight query, 2 tables, and one criteria.

No other ideas why I wouldn’t be getting data on the grid when I don’t pub&sub to anything? @josecgomez or @Chris_Conn

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

It doesn’t make sense that the BAQView wouldn’t populate… is you BAQ SUUUPER BIG in terms of Data?

@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…

1 Like

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.

Thanks again @josecgomez & @Chris_Conn for your assistance.

2 Likes

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.