Creating a custom service
A custom service in Dynamics AX allows any X++ logic to be exposed as a service. Custom services are normal X++ classes decorated with attributes, which allow any existing methods to be exposed as service operations without writing any additional code.
In this recipe, we will create a new custom service with a single, simple operation. The operation will accept currency code and return the currency description.
How to do it...
Carry out the following steps in order to complete this recipe:
1. In the AOT, create a new class named
CustomCurrencyService
with the following code:class CustomCurrencyService { } [SysEntryPointAttribute] public CurrencyName getCurrencyName(CurrencyCode _currencyCode) { return Currency::find(_currencyCode).Txt; }
2. Set the class properties as follows:
Property
Value
RunOn
Server
3. In the AOT, create a new service with the following properties:
Property
Value
Name
CustomCurrencyService
Class
CustomCurrencyService
4...