Press ESC to close

Creating Custom Services in Dynamics 365 Finance and Operations: A Comprehensive Guide

Overview:  

In this blog post, we’ll explore the process of creating custom services in Dynamics 365 Finance and Operations, empowering you to extend the capabilities of your ERP system to meet the unique needs of your business. Whether you’re looking to integrate with external systems, automate processes, or enhance user experiences, custom services offer a flexible and powerful solution.  

image-212.png

Let’s take a scenario where dynamics is holding the data and that data can be exposed outside by using a service. So how to create a service from Dynamics and try to expose it outside and try to use it within the postman that is the first step actually to ensure that I am able to interact with the postman.  

Tools Required:  

image-212.pngimage-211.png

Create a new project in Visual Studio  

image-213.png

Follow the steps:   

image-214.png

Follow the steps:  

image-212.png

A project has been created:  

image-215.png

Create a class:  

image-217.png

Follow the steps:  

image-216.png

Code:  

image-218.png

Copy code and paste in the class:  

internal final class CalculateTaxServiceClass
{
    public str computeTotalTax(str _salesOrder, RealBase _amount)
    {
        RealBase computedTotal = _amount + (_amount/10);
        return strFmt("Computed tax for sales order %1 with amount %2 is %3", _salesOrder, _amount, computedTotal);
    }
    public str computeOnlyTax(str _salesOrder, RealBase _amount)
    {
        RealBase computedTotal = _amount/10;
        return strFmt("Computed tax for sales order %1 with amount %2 is %3", _salesOrder, _amount, computedTotal);
 }

Create a Service:  

image-224.png

Follow the steps and enter the values in the fields of properties:  

Write the class name in “Class” property.  

image-236.png

Create Service Operation:  

image-223.png

Create two operations:  

Operation name same as method name in the class:  

image-219.png

Follow the steps and enter the values in the fields of properties:    
Method = Method name in the class:  

image-237.png

Follow the steps and enter the values in the fields of properties:  

image-225.png

Create Service Group:  

image-227.png

Add the Service or drag and drop the service into the Service Group:  

image-226.png

Follow the steps and enter the values in the fields of properties:  

image-228.png

We can trace the services, service group and the method in the class by this URL  

Dynamics URL\api\services\ServiceGroup\Serivce\ServiceOperation:  

image-227.pngimage-220.png

Visit portal.azure.com and follow the steps:  

image-229.png

Register new App:  

image-237.png

Follow the steps:  

image-230.png

Follow the steps:  

image-238.png

App has been registered. keep save the Application (client) ID, Object ID and Directory (tenant) ID for further use:  

image-238.png

+Add a permission and Follow the steps:  

image-239.png

First click on Delegated permissions:  

image-240.png

Select/tick all and follow the steps:  

image-241.png

Again +Add a permission:  

image-249.png

Now this time click on Application permission and follow the steps:  

image-242.png

Contact your IT admin to grant the permissions to complete the permission process successfully:  

image-243.png

After permission granted by IT Admin:  

image-244.png

Go to Certificates & secrets and follow the steps:  

image-245.png

Copy the “Value”, will be used later in the PostMan part:  

image-230.png

Go back to Dynamics and follow the steps:  

image-246.png

Click on +New and enter the “Client ID” given by Azure during App registration:  

image-246.pngimage-222.png

Go to web.postman.co, create new workspace or start work in already created workspace:  

image-231.png

Follow the steps to create new workspace:  

image-232.png

Name the workspace and create:  

image-247.png

Select the workspace, Create new Collection in the Workspace and follow the steps:  

image-232.png

Follow the steps:  

image-247.png

Follow the steps one by one:  

image-248.png

After saving and “Send” the GET request, I got the token, copy this token:  

image-250.png







Take the URL as it in the screenshot below:    
dynamicURL/api/services/your service group/your service/your service operation.    
Here the service operation is “computeTotalTax”.  

image-233.png

Copy the above URL in step 3 and follow the following steps:Passing the parameters Sale Oder and amount for which we find the amount with tax.  

image-233.png

Select the Auth Type, which is “Bearer Token” and paste the token in step 4:  

image-234.png

Save and send has been done already in the above screenshot, You will get the amount with tax from the dynamics.  

image-234.png

Change the URL for finding only the tax amount in step 1:  

dynamicURL/api/services/your service group/your service/your service operation.    
Here the service operation is “computeOnlyTax”.    
change the input for which you find the tax amount in step 5.    
In last “Save ” and “Send”. You will get the result or output in step 8.  

image-235.pngimage-221.png