Dear all,
I am new to Wizard Events and have very limited knowledge of how Adapters work inside Epicor but have a relatively good programming experience in C#. Unfortunately Form Event Wizard is mainly in VB so please bear with me.
This is my code:
// **************************************************
// Custom code for SalesOrderForm
// Created: 2020-10-27 7:11:06 PM
// **************************************************
extern alias Erp_Contracts_BO_AlternatePart;
extern alias Erp_Contracts_BO_SalesOrder;
extern alias Erp_Contracts_BO_Quote;
extern alias Erp_Contracts_BO_Part;
extern alias Erp_Contracts_BO_Customer;
extern alias Erp_Contracts_BO_RMAProc;
extern alias Erp_Contracts_BO_OrderDtlSearch;
extern alias Erp_Contracts_BO_OrderHist;
extern alias Erp_Contracts_BO_QuoteDtlSearch;
extern alias Erp_Contracts_BO_SerialNumberSearch;
extern alias Erp_Contracts_BO_ShipTo;
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 Erp.UI;
using Ice.Lib.Customization;
using Ice.Lib.ExtendedProps;
using Ice.Lib.Framework;
using Ice.Lib.Searches;
using Ice.UI.FormFunctions;
public class Script
{
// ** Wizard Insert Location - Do Not Remove 'Begin/End Wizard Added Module Level Variables' Comments! **
// Begin Wizard Added Module Level Variables **
private EpiDataView edvUD07;
private SalesOrderAdapter adSO;
// End Wizard Added Module Level Variables **
// Add Custom Module Level Variables Here **
public void InitializeCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Variable Initialization' lines **
// Begin Wizard Added Variable Initialization
this.edvUD07 = ((EpiDataView)(this.oTrans.EpiDataViews["UD07"]));
this.adSO = new SalesOrderAdapter(this.oTrans);
this.adSO.BOConnect();
// End Wizard Added Variable Initialization
// Begin Wizard Added Custom Method Calls
this.epiButtonC1.Click += new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Custom Method Calls
}
public void DestroyCustomCode()
{
// ** Wizard Insert Location - Do not delete 'Begin/End Wizard Added Object Disposal' lines **
// Begin Wizard Added Object Disposal
this.epiButtonC1.Click -= new System.EventHandler(this.epiButtonC1_Click);
// End Wizard Added Object Disposal
// Begin Custom Code Disposal
// End Custom Code Disposal
}
private void epiButtonC1_Click(object sender, System.EventArgs args)
{
// ** Place Event Handling Code Here **
EpiTextBox txtSO = ((EpiTextBox)csm.GetNativeControlReference("4fceeeec-518c-4256-932e-34a4c1a584ee"));
bool recSelected;
string whereClause = string.Empty;
System.Data.DataSet dsSalesOrderAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans,"SalesOrderAdapter", out recSelected, true, whereClause);
if(recSelected)
{
System.Data.DataRow adapterRow = dsSalesOrderAdapter.Tables[0].Rows[0];
txtSO.Text = adapterRow["OrderNum"].ToString();
this.adSO.SalesOrderData.Clear();
this.edvUD07.dataView[edvUD07.Row]["ShortChar01"] = dsSalesOrderAdapter.Tables[0].Rows[0]["OrderNum"].ToString();
}
}
}
For starters I wanted to load same adapter that Sales Order Entry uses and fill the form. Later my was to use the same adapter to load but use a different parameter to search. We have some SalesForce opportunity IDs that I wish to search based on those instead of using OrderNum.
The current status is that when I click on the button, it launches the search window and when I select the order number, instead of populating the form, it shows an error:
The details of the error shows this:
I understand this can be done quite easily using quick search, but I was wondering if I could achieve it this way as well.
I would appreciate it if you can help me achieve my goal.
Regards,