Tuesday, May 7, 2019

Dynamics CRM for IOT - Hello Intelligent Big Data - Connected Field Service

Dynamics have connected with IoT with Azure, enhancing the number of possible real world implementations. Dynamics 365 Field Service is a best avenue to take advantage of IoT technology for industrial benefits. 

With the massive amounts of data available in field service industry collected via IoT devices, D365 Field Service can move forward in taking sound management decisions using real time data. D365 Field Service is the best platform to manage small to large scale service industry requirements.

Field Service under D365 Umbrella
  • To start with Dynamics 365 is a collection of intelligent business applications on a common platform, And from these, Field Service is a very popular application among manufacturing and service industries. It targets in helping organizations to deliver outstanding onsite/offsite services to their  customers. 

 
  • Field service, extends Microsoft Dynamics 365 to provide an end to end solution to manage field agent activities


  • In general field service is all about completing a work order for the customer fulfilling required resources and services.
    So general field service starts when a customer inquire about a service, then it manages the entire service providing process.
  • It does resource management, inventory management, scheduling, mobile agent handling and Analytics etc.



Internet of Things (IoT)

  • Kevin Ashton (researcher in RFID and sensor technology),  is known for coining the term “the Internet of Things” to describe a system where the Internet is connected to the physical world via ubiquitous sensors.
  • Describes IoT as a network of “eyes and ears” for computers: with Internet of Things, computers can sense things for themselves (Keyboard data entry era is over)

  • One of the first examples of an Internet of Things is from the early 1980s, which was a Coca Cola machine, at Melon University. Local programmers have connected it to internet to see if there was a cool drink available, before making the trip to the machine.
  • In the chart you can see how much of IoT devices are proactively used in various industries. And it is expected to have over 267 billion USD worth IoT devices  by 2020.



Field Service and IoT

Field Service is one of the very first industries to use IoT in Commercial use
  • The field service industry has evolved alongside IoT. And it has established interoperability across devices, applications, and platforms.
    • Reduced Costs - Preventing breakdowns and reducing downtime. Efficient Use Of Resources.
    • Best-of-Breed Solutions - IoT encourages businesses to use software applications and hardware devices are specific to their needs.
    • Customer Satisfaction – The ability to take actions even before customer notice it and make a service call. Proactive services.
The challenge, is how to utilize the massive amount of data generated through IoT devices on the field, to improve operations and customer satisfaction.

D365 Traditional Field Service
  • In a traditional field service organization, when customer gets a problem they calls to arrange a service agent to get it fixed. (Ref: https://www.naviworld-asia.com)


D365 Connected Field Service (CFS)
  • Connected Field Service - Detect, troubleshoot, and resolve issues remotely so a technician is dispatched only when necessary. Know about problems and solve them Just-In-Time before customers are affected using IoT Technology.
  • Connected Field Service eliminates the customer concern by attempting to complete self-healing repairs remotely before sending out a technician





  • Organizations can benefit from “just-in-time” preventative maintenance instead of scheduled preventative because Connected Field Service can look at the actual consumption of a part and send out alerts when the part needs to be changed or cleaned. 



CFS Path to Implementation

Basic:
When an anomaly is detected, Field Service automatically creates a work order and dispatches a technician to consider the issue. This level of Connected Field Service takes a proactive approach to improve customer satisfaction by decreasing overall downtime and making repairs before customers become aware of the problem.
Advanced:
When an anomaly is detected, Field Service asks the device to try to fix itself with a single, self healing command. If that command doesn’t work, then Field Service automatically creates a work order and schedules a technician. Organizations experience improved customer satisfaction levels and gain greater productivity because fewer technicians are dispatched when devices can self-heal.
Expert:

At this level, Field Service initiates a multi-step workflow when an anomaly is detected. This attempts to fix the device in as many ways possible without requiring human intervention. This level maximizes customer satisfaction and resource productivity because a technician is only dispatched when all other possibilities are exhausted.


CFS Implementation

There are two offerings you can use to connect IoT-enabled devices into the Field Service solution:
Connected Field Service for Azure IoT Central (SaaS)
Connected Field Service for Azure IoT Hub (PaaS)



Azure IoT Central

Azure IoT Central is a fully managed global IoT SaaS (software-as-a-service) solution that makes it easy to connect, monitor, and manage IoT assets at scale.

Objective:  Connect a Physical Device to IoT Cloud and then Allow Dynamics 365 Field Service to Act        upon the sensor data.
  • Azure IoT Central can send information about device anomalies to Connected FieldService (as an IoT Alert) for diagnosis.
  • Connected Field Service can create cases or work orders triggered from device anomalies.
  • Connected Field Service can schedule technicians for inspection to prevent the downtime incidents.



  • Azure IoT Central enables builders to configure rules and actions. Based on those actions, IoT alerts will be created in Connected Field Service. Also, based on service activities in Connected Field Service, information can be sent back to Azure IoT Central. This is accomplished by using Microsoft Flow, a SaaS offering for automating workflows across applications and services.




Azure IoT Hub

Objective:  Connect a Physical Device to IoT Cloud and then Allow Dynamics 365 Field Service to Act upon the sensor data.
  • IoT Hub is a managed service, hosted in the cloud, that acts as a central message hub for bi-directional communication between your IoT application and the devices it manages.
  • IoT Hub supports multiple messaging patterns to control your devices from the cloud, such as
    • Device-to-cloud Telemetry
    • File Upload From Devices
    • Request-reply Methods
  • IoT Hub gives you a secure communication channel for your devices to send data
  • Built-in message routing functionality gives you flexibility to set up automatic rules-based message fan-out (Use message routing to control where your hub sends device telemetry)
  • Integration from IoT Hub to other Azure services available to build end-to-end solutions
    • Azure Event Grid
    • Azure Logic Apps
    • Azure Machine Learning
    • Azure Stream Analytics





  • IoT Hub can be used to build IoT solutions with reliable and secure communications between millions of IoT devices and a cloud-hosted solution back-endYou can connect virtually any device to IoT Hub.

Below is a step wise guideline for setting IoT Hub for Field Service
    1.  Apps Automatically created in IoT Hub




    2. Add Connected Field Service in D365 CRM Instance Manage

          
       
     3. Connect your IoT device to Internet

    4. Use Logic app in IoT hub to create records (anything you want as output) for IoT feeds



    5. You will get records created in D365 Field Service according to the IoT feeds



    Sunday, March 10, 2019

    Trigger common plugin code (C#.net) for any entity in Dynamics 365 (CRM)

    Hello dynamic world,

    Now this is a simple trick I learnt to do to make my life much easier. The simple case study was that, I wanted to call same function, on create/update of several entities, with some pre-defined conditions for each entity.

    Now I could have write separate handler for each entity (entity01handler, entity02handler, .. , entitynhandler) and call the same function keeping it accessible for all handlers.

    However what I did is write one handler for all the entities. It was just simple as passing null for target entity in step register.

    public class CommonEntityHandler : Plugin
    public CommonEntityHandler() : base(typeof(CommonEntityHandler)) {
                base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>((int)PipelineStage.PostOperation, ContextMessageName.Create, null, new Action<LocalPluginContext>(ExecuteCommonEntityCreate)));
                base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>((int)PipelineStage.PostOperation, ContextMessageName.Update, null, new Action<LocalPluginContext>(ExecuteCommonEntityUpdate)));            base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>((int)PipelineStage.PostOperation, ContextMessageName.Associate, null, new Action<LocalPluginContext>(ExecuteCommonEntityAssociate)));            base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>((int)PipelineStage.PostOperation, ContextMessageName.Disassociate, null, new Action<LocalPluginContext>(ExecuteCommonEntityDisassociate)));            base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>((int)PipelineStage.PreOperation, ContextMessageName.Disassociate, null, new Action<LocalPluginContext>(ExecuteCommonEntityDisassociate))); }
    private void ExecuteCommonEntityCreate(LocalPluginContext localContext)
     {
       localContext.TracingService.Trace("Common Entity create " + localContext.PluginExecutionContext.Depth);
       if (localContext == null || localContext.OrganizationService == null)
        {
           throw new ArgumentNullException("localContext");
        }
    
        IOrganizationService service = localContext.OrganizationService;
        ITracingService tracingService = localContext.TracingService;
        IPluginExecutionContext context = localContext.PluginExecutionContext;
        tracingService.Trace("start create");
        try
        {
          if (localContext.PluginExecutionContext.InputParameters.Contains(InputParameter.Target) && localContext.PluginExecutionContext.InputParameters[InputParameter.Target] is Entity)
          {
            var commonEntity = localContext.PluginExecutionContext.InputParameters[InputParameter.Target] as Entity;
    
          // use commonEntity.Id, commonEntity.LogicalName, commonEntity.Name for your logic
          }  
        }
        catch (InvalidPluginExecutionException)
        {
            throw;
        }
     }
    }