Creating a user exit in .NET
- Create a class library project in Visual Studio.
- Reference Ird.SC.Arp.Assortment.UserExits.dll from the Assembly Area of your installed application in your Visual Studio project.
- Create a class and inherit and implement the IOperation interface from the Ird.SC.Arp.Assortment.UserExits namespace.
-
Copy the output .dll file of your project to the Extensions folder of the
application, located at
C:\Users\<username>\AppData\Roaming\Infor\Extensions.
This is a sample source code written in C#:
using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.Linq; using System.Text; using System.Threading.Tasks; using Ird.SC.Arp.Assortment.UserExits; using System.IO; namespace SampleUserExits { [InheritedExport(typeof(IOperation))] [ExportMetadata("Id", "86fa59f4-483e-4cdf-908f-dd2704311d4e")] //Unique Id for the UserExit, use GUID [ExportMetadata("Name", "My User Exit in C#")] //Display Name for the User Exit [ExportMetadata("Description", "This is a sample UserExit written in C#")] //The description for the User Exit public class MyUserExits : IOperation { #region IOperation Members //This Execute() method is called every time you run a User Exit. public object Execute(params object[] args) { //Retrieve and assign the parameters passed to a Dictionary key pair value object. Dictionary<string, object> parameters = args[0] as Dictionary<string, object>; decimal cost = 0.00m; //how to check if the parameters contain a particular key if (parameters.ContainsKey("Supplier_CountryCode")) { string countryCode = parameters["Supplier_CountryCode"].ToString(); switch (countryCode.ToUpper()) { case "US": //United States cost = 112.50m; break; case "CN": //China cost = 45.00m; break; case "SE": //Sweden cost = 99.50m; break; case "VN": //Vietnam cost = 36.75m; break; case "FR": //France cost = 87.10m; break; default: //Other Countries cost = 100.00m; break; } } // return the value in decimal type return cost; } #endregion } }
Note: There is no file name requirement for .NET user exit dll. As long as the code has the signature and is implementing the IOperation interface under the Ird.SC.Arp.Assortment.UserExits namespace that is defined for user exits, the application will execute the script.For example, you can name your .NET user exit dll as M3BEConnector.dll or TaxTable.dll.