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; ...

Get Microsoft Dynamics AX 2012 Development Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.