Good Morning everyone. I am attempt to grab the value out of a combo drop down to handle some logic based on the ProdGrup. I am getting the below error.
Unable to cast object of type ‘Erp.UI.Controls.Combos.ProdGrupCombo’ to type ‘Erp.Adapters.Controls.ProdGrupCombo’.
Stop while you are head, do not grab values from the UI controls. Use the data views (assuming you are in Part Entry something like this should work)
var edvPart = oTrans.Factory('Part');
if(edvPart.Row>=0)
{
var partNum = edvPart.dataView[edvPart.Row]["PartNum"] as String;
var partNum = edvPart.dataView[edvPart.Row]["PartDescription"] as String;
var prodCode= edvPart.dataView[edvPart.Row]["ProdCode"] as String;
}
You should always strive for abstraction and not tie yourself to individual controls on the screen. What happens if Epicor redesigns that screen and renames the controls? or the GUID changes.
Working directly with the dataViews affords you the abstraction required for more robust future proof customizations that will generally upgrade cleaner and lead to less maintenance issues.
If Epicor moves that control to another tab, renames it, or removes it entirely you still have access to the underlying data view its binding.
I keep getting an Object reference is not set to instance of Object. I feel like I am so close but I am missing something. Message Box A and B appear but not C
Like @josecgomez has mentioned, this is not Winforms. We really have to work with the dataviews. This becomes even more important when you move to Kinetic.