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; info(operation.Name); } } }
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).
Hi Martin,
It’s very useful your article. Great job!
But maybe you could help me get the name of its service group ?
Thanks you!
First of all, realize that it’s not necessarily a single service group.
I don’t think that the service knows which service groups refers to it, but you can easily iterate service groups and look for the service:
Many thanks Martin! I’m new to AX so I have a lot to learn.
By the chance could you recommend me a good resource about learning to work with metadata in D365?
Unfortunately I’m not aware of any documentation, just a few blog posts like this one.
What sometimes help me is decompiling DLLs with metadata classes and checking the actual implementation, e.g. to find a method that gives me what I need.
This is a good idea! I will do so.
Thanks a lot Martin for your fantastic help!