Set EpiUltraCombo value on load

Hi,
I have a Dashboard with a Tracker. I believe the Tracker has an EpiUltraCombo filter for Plant, although it says Erp.Adapters.Controls.PlantCombo. I’m trying to default the filter’s value to the current plant when the screen loads.

I can get the current Plant ID and Name successfully, but I cannot make the value stick to this Combo box. Maybe I’m referencing the wrong type.

My current code is below:

image

private void MainController_Load(object sender, EventArgs args)
{
	var Session = (Ice.Core.Session)oTrans.Session;
	EpiDataView edvPartPlant = ((EpiDataView)(this.oTrans.EpiDataViews["V_OMS_PartByPlantBin_1View"]));
	EpiUltraCombo PartPlant = (EpiUltraCombo)csm.GetNativeControlReference("ae21fbc8-1a3f-4591-b250-84a5c24e13a4");

	
	PartPlant.DisplayMember = Session.PlantName;
	PartPlant.ValueMember = Session.PlantID;
	PartPlant.Focus();
 
	MessageBox.Show(Session.PlantID + " " + Session.PlantName);
	MessageBox.Show(PartPlant.Text + " " + PartPlant.Value);
	
}

If I try:

Erp.Adapters.Controls.PlantCombo PartPlant = (Erp.Adapters.Controls.PlantCombo)csm.GetNativeControlReference("ae21fbc8-1a3f-4591-b250-84a5c24e13a4");

I get this error:
Error: CS0234 - line 64 (148) - The type or namespace name ‘Controls’ does not exist in the namespace ‘Erp.Adapters’ (are you missing an assembly reference?)

Thanks for looking.
Luis

This might work. Note that I used the CoreSession (less code). Also, you want to set the value on the dataview and not the object.

private void MainController_Load(object sender, EventArgs args)
{
	EpiDataView edvPartPlant = oTrans.Factory("V_OMS_PartByPlantBin_1View");
	edvPartPlant.dataView[0]["PartPlant_Plant"] = oTrans.CoreSession.PlantID;
	oTrans.OnRefresh();	
}

Thanks for the suggestion Jason. Unfortunately I got the following error:

Application Error

Exception caught in: mscorlib

Error Detail

Message: Exception has been thrown by the target of an invocation.
Inner Exception Message: Index 0 is either negative or above rows count.
Program: CommonLanguageRuntimeLibrary
Method: InvokeMethod

Client Stack Trace

at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeScriptMethod(MethodInfo scriptMethod, Object[] parameters)
at Ice.Lib.Customization.CustomScriptMethodInvoker.InvokeCustomFormLoadIfExists(String methodName, Object sender, EventArgs e)
at Ice.Lib.Customization.CustomScriptManager.<>c__DisplayClass104_0.b__0()
at Ice.Lib.Customization.CustomScriptManager.TryActionShowExceptionBoxOrLogVerificationErrorIfException(Action action, String exceptionBoxTitle)

Inner Exception

Index 0 is either negative or above rows count.

at System.Data.DataView.GetRow(Int32 index)
at Script.MainController_Load(Object sender, EventArgs args)

Just to confirm, this combo is on the Tracker View.
image

Maybe this?
Otherwise, try moving the code into the MainController_Shown event (there are other threads for how to do this).

private void MainController_Load(object sender, EventArgs args)
{
	EpiCombo PartPlant = (EpiCombo)csm.GetNativeControlReference("ae21fbc8-1a3f-4591-b250-84a5c24e13a4");
	PartPlant.Text = oTrans.CoreSession.PlantID;
	//Maybe a Key Field Validation is requireed too?
	oTrans.OnRefresh();	
}

I don’t know if you ever got this figured out… I’ve been struggling with it myself for the past couple of days. Here’s what finally seemed to work for me to get the value to stick in the PlantCombo

private void MainController_Load(object sender, EventArgs args)
{
	// Add Event Handler Code
	PlantCombo cmbPlant = (PlantCombo)csm.GetNativeControlReference("8c146d90-4637-4135-8c63-0cb680953e99");
	cmbPlant.FillList();
	cmbPlant.Value = oTrans.CoreSession.PlantID;

I gave up and did something else. Thanks, I’ll try this code.