web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Unanswered

Help on translating to the new version of D365 FO Service development

(0) ShareShare
ReportReport
Posted on by

Hello guys,

I'm having difficulties in understanding what need to use or to write in order to testing Service development.

I found a blog which is looks quite simple and good for me to start trying out this development. But apparently the code in that blog seems outdated, Can someone help me to translate it, show me which code already obsolete and how is the current code should be.

This is the blog I'm referring to: Microsoft Dynamics 365 for Finance and Operations: Custom service to create Sales order with lines in Dynamics 365 and testing it (vishwad365fo.blogspot.com)

Especially when he is creating Contract Class for Sales Order Header at this part: 

[DataMemberAttribute('SalesLineList'),
    AifCollectionTypeAttribute("sales"ineList", Type::Class, classstr(SalesOrderLineContract),
    AifCollcectionTypeAttribute("return", Type::Class, classstr(SalesOrderLineContract))]

Because I just found out that is not the way it is written now, but I don't have a clue what is the correct one then?

Many thanks in advance.

I have the same question (0)
  • Martin Dráb Profile Picture
    237,924 Most Valuable Professional on at

    The code looks almost correct, except of the fact that both the blog post author and you have a bug in the name of _salesLineList argument in AifCollectionTypeAttribute. The blog post uses salesLineList, although the parameter name is _salesLineList. And you have sales"ineList in your code, which won't even compile.

    Please elaborate what you mean by "I just found out that is not the way it is written now".

  • VoltesDev Profile Picture
    on at

    Hi Martin,

    Yes, and sorry the mistake, it is only a typo error when I write it again over here.

    The "not the way it is written now" is because I also looked at 1 book for my learning, and it is stated the usage like this:

    [AifCollectionType('return', Types::Class, classStr(ConVMSVehicleTableContract))]
    public List GetVehicles()
    {
        List vehicleList;
        ConVMSVehicleTable vehicles;
        ConVMSVehicleTableContract contract;
        vehicleList = new List(Types::Class);
        while select vehicles
        {
            contract = new ConVMSVehicleTableContract();
            contract.VehicleId(vehicles.VehicleId);
            contract.VehicleGroupId(vehicles.VehicleGroupId);
            contract.VehicleType(vehicles.VehicleType);
            contract.VehRegNum(vehicles.VehRegNum);
            contract.AcquiredDate(vehicles.AcquiredDate);
            vehicleList.addEnd(contract);
        }
        return vehicleList;
    }

    Of course, it is different case, but I wonder if it is the way it is written now?

    When I say it is different case, also because in that blog, it was written in Contract Class, while in my book, it is for the Service Class. Probably because it is for different purposes, so it put in different class?

    Thanks,

  • VoltesDev Profile Picture
    on at

    Ok, provided I want to know why the blog put that specific code in Contract class while in my book "the code that  look similar" is on Service Class, however I have managed to create those classes free of errors.

    But now I'm lost for what should I do next?

    Starting at this part of that blog ->

    Post the build, the service is ready to be consumed, deployed as per below url:

    https:[Your organization's root URL]/api/services/service_group_name/service_group_service_name/operation_name

    Now, if it has to be tested in any of the tools, apart from writing code and consuming it in any visual studio console applications.

    May I know what to do? Is that Post means Build? and when he says if it has to be tested, how to test it?

    Also then he's talking about Postman, but doesn't really describe what should I do  (and the steps) since I never use Postman before.

    Thanks,

  • Martin Dráb Profile Picture
    237,924 Most Valuable Professional on at

    Let me consider just the case when we're returning a list, not when we're using a list as a parameter. It's similiar with parameters, but my description will be simpler if I focus just on a single thing.

    A service operation may return a list and then you need AifCollectionType attribute. If it returns a single value, such as a single string or a single data contract object, no AifCollectionType is needed.

    You can also have a method in a contract class returning a list (e.g. you have an order contract with a list of lines). Then you need AifCollectionType to describe what kind of data the method returns.

    It's completely possible that your service operation returns a list of contract objects (such as a list of orders), and each of these contract objects has a method returning another list (such as a list of lines), therefore you'll use AifCollectionType at both places.

    When the blog post author means by "post the build" is that you should compile (build) the project or model.

    Then the service is deployed to two endpoints, which have different URLs and they differ in the way how they can be consumed. See Custom service development for slightly more details. The blog post mentions the URL of the JSON-based endpoint, which is usually the preferred one.

    Please use a search engine to learn more about Postman; you'll find a plenty of resources. It's an application that allows you (among other things) create and send HTTP requests and observe the result.

    When you decide to write code, don't miss code samples shared by Microsoft on GitHub.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 298 Super User 2025 Season 2

#2
Siv Sagar Profile Picture

Siv Sagar 183 Super User 2025 Season 2

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 118 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans