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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to run a custom service D365FO?

(0) ShareShare
ReportReport
Posted on by 1,552

I created a new custom service and a service group (auto deploy : yes). I also created a class with a method that retrieves the customer ids. and i added this method in the service.

i made a job to make sure that my method return customer ids and it did return successfully.

Now i put the following URL:  https://YouInstanceUrl/api/services/ServiceGroupTest/TestService/getCustomerId

when i open the file i don't get any customer ids why is that?

I have the same question (0)
  • nmaenpaa Profile Picture
    101,162 Moderator on at

    How are you calling this service? 

  • junior AX Profile Picture
    1,552 on at

    Using the URL i mentioned above.

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Yes but how? Do you call it from some application? Or do you open this URL via a browser?

    It's not supposed to be used via a browser.

  • junior AX Profile Picture
    1,552 on at

    yeah i open it via a browser.

    What should i do then?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Services are something that you use for integrations between systems. They should be used from code, not from browser.

    You can find links to code examples in the end of this article: docs.microsoft.com/.../custom-services

  • junior AX Profile Picture
    1,552 on at

    which one should i use?

    pastedimage1576680206367v1.png

    and how am i going to connect this to what i did in x++?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    Check Program.cs, that's where the call to the service is. Before that, your code needs to authenticate with AAD.

    It would help if you shared with us what business requirement you are trying to solve. Now you asked about calling a custom service but it seems you might have not known what custom services are. Anyway, you use custom services to expose x++ business logic to external applications. So, external application can call the service and trigger something in D365. Or get some information from D365. Or both.

  • junior AX Profile Picture
    1,552 on at

    this is my scenario, an external system should send me parameters of the customer account they want to retrieve information about and i'll get this information from D365FO.

    Here is my class: 

    class CustomerCustomService
    {
        [SysEntryPointAttribute(true),
    
            AifCollectionTypeAttribute('return', Types::Class, classStr(CustomerCustomService)),
    
            AifCollectionTypeAttribute('_custList', Types::String)]
    
            public List retrieveCustomerInfo(List _custList)
    
        {
    
            CustomerCustomServiceContract    dataContract;
    
            ListEnumerator  listEnum = _custList.getEnumerator();
    
            List            resultSet = new List(Types::Class);
    
            CustTable       custTable;
    
     
    
            while (listEnum.moveNext())
    
            {
    
                select firstOnly custTable
    
                where custTable.AccountNum == listEnum.current();
    
     
    
                dataContract = new CustomerCustomServiceContract();
    
     
    
                if (custTable)
    
                {
    
                    dataContract.parmCustGroupId(custTable.CustGroup);
    
                    dataContract.parmCustName(custTable.name());
    
                    dataContract.parmDefaultLanguage(custTable.languageId());
    
                }
    
     
    
                resultSet.addEnd(dataContract);
    
            }
    
     
    
            return resultSet;
    
        }
    
    }

    1)  do i need to use sysEntryPointAttribute(true) and what does it mean? and does my class need to extend anything?

    2) is there a way to call the service using c# code without AAD? if not what i need to do exactly?

  • Suggested answer
    nmaenpaa Profile Picture
    101,162 Moderator on at

    1) SysEntryPointAttribute is not needed in d365, you will actually get a best practice warning about it when you compile your code

    2) You must always authenticate with AAD in order to communicate with D365FO. You can find a example here: github.com/.../AuthenticationUtility

  • junior AX Profile Picture
    1,552 on at

    1) what does it mean, i read that it checks authorization but i didn't get it? and does my class need to to extend SysOperationServiceBase?

    2) so for testing purposes i can't create a c# project to call it and do what they used to do in AX 2012? I'll take a look at the link now.

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 429 Most Valuable Professional

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 239 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans