LaborAdapter from within MES Customization

I am trying to create a query using the LaborAdapter from within MES, using the code below. However, it is failing at l.InvokeSearch(opts) with the exception message of:

Unable to cast object of type ‘Ice.Core.Session’ to type ‘Ice.Lib.Framework.ILaunch’.

I assume that has to do with the first line and it not liking oTrans.Session to be used in the LaborAdapter, but I am not sure what else I should be doing. There is a good chance I am going about this entire thing the wrong way as well. I am learning as I go :slight_smile:

Dim l As New LaborAdapter(oTrans.Session)
l.BOConnect()
Dim queryHead As String = String.Format("EmployeeNum = '{0}' and ActiveTrans = true", GetEmployeeId())	
Dim opts As Ice.Lib.Searches.SearchOptions = New Ice.Lib.Searches.SearchOptions(Ice.Lib.Searches.SearchMode.AutoSearch)
opts.DataSetMode = Ice.Lib.Searches.DataSetMode.RowsDataSet
opts.PreLoadSearchFilter = queryHead
l.InvokeSearch(opts)

GetEmployeeID() on the 2nd line in the code above simply returns the current UserID in MES (IE: 001973). Nothing special with that.

Anyone able to point me in the right direction?

Adapter should be instantiate oTrans not oTrans.Session

1 Like

That did exactly what I needed. Thank you much, Jose :slight_smile: