Getting service operations from metadata (D365FO)

When working with metadata in Dynamics 365 for Finance and Operation, the usual approach is using the MetadataSupport class. It’s a simplified interface to actual metadata classes, which is easy to use, but it doesn’t expose everything. For instance, it doesn’t return operations of custom services.

Nothing is lost, because you still can get all details from other classes of the metadata API, you just have to deal with a more implementation details such as metadata providers.

To get service operations, you can write code like this:

using Microsoft.Dynamics.AX.Metadata.MetaModel;
using Microsoft.Dynamics.Ax.Xpp.AxShared;
class Demo
    public static void main(Args _args)
        AxService service = MetadataShared::Provider.Services.Read('DimensionService');
        System.Collections.IEnumerator enumerator = service.ServiceOperations.GetEnumerator();
        while (enumerator.MoveNext())
            AxServiceOperation operation = enumerator.Current;

Note that if you’re interested in service operations from outside F&O, you can use web service themselves (see Discovery of JSON-based custom services in AX 7).

Comment List