Automate Business Processes: C# Code in Epicor 10

After our consultants wrote a quick guide on how to call business objects in Epicor using ABL/4GL code, we've received several inquires regarding the code for performing this same action in Epicor version 10, which uses C# language. So, we've put together this quick how-to for you!

Below is the source code that you can insert to automate Epicor business processes by calling a business object using C# code.

Here is the source.

Method directive on ABCCode.Update

add reference to UD01 assembly:

Ice.Contracts.BO.UD01

no "using" statements required

/*Delcare a UD01DataSet variable */

var UD01DataSet = new Ice.Tablesets.UD01Tableset();

/* Declare variable hUD01 of type Ice.Contracts.UD01SvcContract and set its value to null */

Ice.Contracts.UD01SvcContract hUD01 = null;

/* Select the first ttABCCode if it exists and store it in a new variable ttAbccode_xRow */

var ttAbccode_xRow = (from ttAbccode_Row in ttABCCode

select ttAbccode_Row).FirstOrDefault();

/*Set the value of hUD01 */

hUD01 = Ice.Assemblies.ServiceRenderer.GetService(Db);

/* If hUD01 is not null: */

if (hUD01 != null)

{

/* call the hUD01 object's GetaNewUD01 method and put the result into the UD01DataSet variable */

hUD01.GetaNewUD01(ref UD01DataSet);

/* Get the first row from the UD01DataSet, if it exists */

var ttUD01_xRow = (from ttUD01_Row in UD01DataSet.UD01

where ttUD01_Row.RowMod == "A"

select ttUD01_Row).FirstOrDefault();

if (ttUD01_xRow != null)

{

/* Assign values in the new UD01 record. */

ttUD01_xRow.Company = Session.CompanyID;

ttUD01_xRow.Key1 = "AbcCode"; /*Table that was affected*/

ttUD01_xRow.Key2 = "CountFreq"; /*Field that was affected*/

ttUD01_xRow.Key3 = DateTime.Now.ToString("HH:MM:SS"); /*Time*/

ttUD01_xRow.Key4 = System.Guid.NewGuid().ToString(); /*Unique Identifier*/

ttUD01_xRow.Date01 = DateTime.Now; /*Date*/

ttUD01_xRow.Number01 = ttAbccode_xRow.CountFreq; /* Value from AbcCode */

ttUD01_xRow.ShortChar01 = Session.UserID; /*User id*/

/*Commit record*/

hUD01.Update(ref UD01DataSet);

}

}

Have more questions about Epicor ERP? Datix is an Epicor Platinum Partner, making us a premier source for successful ERP projects and tips. Give us your questions by contacting us today!