Dynamic 365 Field Service Integration with NB.ai’s Route Optimization API

Introduction

Microsoft Dynamics 365 Field Service serves as a robust solution to enhance the efficiency of field service operations. This platform empowers field service teams through real-time visibility into service activities, resource scheduling, and inventory management. Dynamics 365 Field Service equips businesses with tools for predictive maintenance, proactive issue resolution, and intelligent insights, thereby fostering productivity and ensuring a seamless end-to-end service delivery process. Whether managing work orders, dispatching technicians, or analyzing performance metrics, this dynamic solution enables organizations to adapt and excel in the ever-evolving landscape of field service management.

Nextbillion's Route Optimization API complements these capabilities, providing businesses with precise and efficient route planning to save time, reduce costs, and elevate customer satisfaction. Real-time tracking and analytics features allow businesses to monitor their fleet, gaining valuable insights for continuous operational improvement.

By integrating the capabilities of Dynamics 365 Field Service and Nextbillion's Route Optimization API, businesses can revolutionize their field operations, maintaining a competitive edge in today's market.

Pre Requisites

In order to successfully integrate Dynamics 365 Field Service with NextBillion.ai's services, certain prerequisites must be met. These include:

  1. Active Microsoft Dynamics 365 Field Service account: Ensure that you have a functional and active account for Microsoft Dynamics 365 Field Service. This account serves as the foundational element for the integration, providing access to the necessary functionalities within the Dynamics 365 Field Service platform.

  2. Valid API key from NextBillion.ai: Acquire a valid API key from NextBillion.ai, which acts as the authentication mechanism for connecting your Dynamics 365 Field Service instance with NextBillion.ai's services. This key establishes a secure and authorized communication channel between the two platforms, facilitating seamless data exchange and integration. Contact support to get your API key.

By satisfying these prerequisites, you create the essential groundwork for a successful and secure integration between Dynamics 365 Field Service and NextBillion.ai's Route Optimization API.

Integration Steps

Step 1: Set Up Dynamic 365 Field Service Application

Assuming the availability of the Dynamics 365 Field Service application with the user, follow these steps to establish an external connection through OAuth:

1. Configure Connection in Microsoft Azure Cloud Platform

  • Log in to Microsoft Azure Cloud.
  • Navigate to 'App registrations' and select 'New Registration.'
docs-image

2. Fill Application Details

  • Enter the required details for the application, including a suitable Name and Redirect URI (e.g., localhost or a chosen web platform).
docs-image

3. Application Registration

  • Upon registration, your application is created.

4. Create Client Secret

  • Generate a client secret for authentication by clicking 'Add.'
  • Immediately copy and securely store the client secret, as it cannot be retrieved later.
docs-image
docs-image

5. Authentication

  • Use the client ID and secret credentials to test the application and generate an access token.
  • Utilize tools like Postman for generating and testing the access token.
docs-image

6. Validate Basic CRUD Operations

  • Verify basic CRUD operations using the generated access token.

By following these steps, you establish an OAuth connection for Dynamics 365 Field Service, facilitating secure external access and enabling essential operations through the generated access token.

Step 2: Pull List of Vehicles from Dynamic 365 Field Service

In this step, we retrieve work order tasks from the Dynamic 365 Field Service account. The objective is to pull a comprehensive list of vehicles that provide essential details for further analysis and optimization.

docs-image

API Request

Use the following cURL command to retrieve vehicles data.

1# Fetch Vehicles from Dynamic 365 Field Service
2curl --location 'https://org83f3f8a8.crm.dynamics.com/api/data/v9.0/bookableresources?$select=*&$filter=statuscode%20eq%201' \
3--header 'Accept-Language: en-US' \
4--header 'Authorization: Bearer <access_token>'

API Response

The following API response represents information about vehicles retrieved from Dynamics 365 Field Service.

1{
2 "@odata.context": "https://org83f3f8a8.crm.dynamics.com/api/data/v9.0/$metadata#bookableresources(*)",
3 "value": "[...]"
4}

Here's an explanation of the key components:

  • @odata.context: This specifies the OData metadata context, indicating the data model and version. In this case, it points to the metadata for bookable resources in Dynamics 365 Field Service.
  • value: This is an array containing the details of individual resources. Each element within this array represents a separate resource (e.g., a vehicle or field service personnel).
    • @odata.etag: A unique identifier for the resource's current state. It helps in managing concurrency and ensuring data consistency.
    • statecode: Represents the state of the resource. A value of 0 typically indicates an active state.
    • statuscode: Indicates the status of the resource. A value of 1 commonly signifies an active status.
    • msdyn_displayonscheduleboard: Boolean indicating whether the resource should be displayed on the schedule board.
    • createdon: The timestamp indicating when the resource was created.
    • _msdyn_organizationalunit_value, _calendarid_value, _owningbusinessunit_value, _ownerid_value: These are unique identifiers referencing other entities within Dynamics 365 Field Service, such as organizational units, calendars, business units, and owners.
    • name: The name or identifier of the resource (e.g., "Mickey Mouse").
    • versionnumber: A numerical value representing the version of the resource.
    • timezone: An integer representing the timezone associated with the resource.
    • msdyn_enableoutlookschedules, msdyn_enabledripscheduling, msdyn_enabledforfieldservicemobile: Boolean values indicating specific functionalities enabled for the resource.
    • modifiedon: The timestamp indicating when the resource was last modified.
    • msdyn_endlocation, msdyn_startlocation: Numeric identifiers representing the end and start locations of the resource.
    • Other fields represent additional details about the resource, such as hourly rates, geographic coordinates, and organizational information.

This response provides a comprehensive set of data about each vehicle, allowing for detailed insights into their characteristics and configurations within the Dynamics 365 Field Service application.

Step 3: Pull Work Order Records from Dynamic 365

The work order records will be mapped to the jobs or shipments parameter in Nextbillion's Route Optimization API. The work order records are pulled from the Dynamic 365 Field Service application using the GET request.

docs-image

API Request

1# Fetch WorkOrders from Dynamic 365 Field Service
2curl --location 'https://org83f3f8a8.crm.dynamics.com/api/data/v9.0/msdyn_workorders' \
3--header 'Accept-Language: en-US' \
4--header 'Authorization: Bearer <access_token>'

API Response

The following API response contains information about a work order retrieved from the Dynamics 365 CRM system.

1{
2 "@odata.context": "https://org83f3f8a8.crm.dynamics.com/api/data/v9.0/$metadata#bookableresources(*)",
3 "value": "[...]"
4}

Here's a breakdown of the key fields and their meanings:

  • @odata.context: Specifies the metadata URL of the Dynamics 365 CRM entity for work orders.
  • value: An array containing the details of individual work orders. In this case, it includes information about a single work order.
  • @odata.etag: Represents the entity tag for optimistic concurrency control. It's a unique identifier associated with the current state of the entity.
  • msdyn_name: The name or title of the work order, in this case, "00420".
  • createdon: The timestamp indicating when the work order was created.
  • msdyn_workordersummary: A brief summary or description of the work order, often used for reference purposes.
  • msdyn_timefrompromised: The promised start time for the work order.
  • msdyn_totalamount: The total amount associated with the work order, typically reflecting the cost or value of the services.
  • msdyn_worklocation: An identifier representing the location of the work, such as an address or geographical coordinates.
  • msdyn_timewindowstart/msdyn_timewindowend: The start and end times of the time window during which the work needs to be completed.
  • msdyn_city/msdyn_stateorprovince/msdyn_postalcode: Address details specifying the city, state/province, and postal code associated with the work order location.
  • statuscode: Indicates the current status of the work order.
  • modifiedon: Timestamp indicating the last modification time of the work order.
  • msdyn_longitude/msdyn_latitude: Geographical coordinates specifying the longitude and latitude of the work order location.
  • msdyn_...: Various other fields providing additional details about the work order, such as billing information, priority, resolution details, and more.

Overall, this API response provides comprehensive information about a specific work order, including its details, status, location, and associated metadata.

Step 4: Data Preparation and Mapping with Route Optimization API

  • After successfully pulling data from Dynamics 365 Field Service, integrate the fetched data with Route Optimization API.

  • Use the provided API endpoint to map the data to respective API parameters.

  • Configure optimization settings, including shift start and end times, service time, and start and end location coordinates.

1if (localStorage.values.apiKey == '') {
2 txtApiKey.setValue('**ENTER API KEY HERE**');
3 return;
4}
5let vehicles = [];
6let shifts = [];
7let starts = [];

Step 5: Create Optimization Job

In this step, the mapped data is sent to Route Optimization API to create an optimization job and response confirms the job creation and returns a unique job id.

API Request

The following cURL command sends a POST request to the Route Optimization API to create an optimization job.

1curl --request POST \
2 --url https://api.nextbillion.io/optimization/v2?key={{localStorage.values.apiKey}}

API Response

The following API response confirms the creation of optimization job.

1{
2 "id": "26df14ca9575f2158a1235eef1022d79",
3 "message": "Optimization job created",
4 "status": "Ok",
5}

Step 6: Retrieve Optimized Route Result

Retrieve the optimized route result by making a GET request to the NextBillion.ai Route Optimization API with the job ID and API key.

API Request

1https://api.nextbillion.io/optimization/v2/result?id={{nbaiOptimizationRun.data.id}}&key={{localStorage.values.apiKey}}

API Response

1{
2 "result": {
3 "code": 0,
4 "summary": "{...}",
5 "routes": "[...]"
6 },
7 "status": "Ok",
8 "message": ""
9}

Visualize Routes using Nextbillion.ai's Route Planner Tool

Explore and analyse optimized routes effortlessly using NextBillion.ai's Route Planner Tool. This tool is accessible through NextBillion.ai's Cloud Console (NCC), providing a user-friendly interface for visualising, reviewing, and fine-tuning routes generated by the optimization process. Seamlessly navigate through the routes, gaining valuable insights into the geographical distribution and efficiency of planned tasks. Leverage the Route Planner Tool within NCC to enhance route visualisation and optimize your field service operations with ease.

The following image showcases the optimized routes within the Route Planner Tool interface.

docs-image