Monday, 11 December 2017

Use of ILSpy in Dynamics 365

If you are part of any Dynamics migration project, you sometime can face this typical issue.

Your customer's previous vendor provided the source code without supplying all the required Proprietary DLLs. This applies to Visual Studio solutions for plugins or custom workflow activities. When you open these solutions, they will not compile and give errors about missing references. 

In these cases there is a workaround "ILSpy". ILSpy is an open -source .NET assembly browser and decompiler. This can be used to view source code and namespaces for a Dynamics CRM plugin/custom workflow DLLs.

Download ILSpy
  • Go to http://ilspy.net and download the binaries. Unzip it in any location on your computer. You can use the ILSpy to de-compile a plugin solution and browse through all namespaces.

Unzip ILSpy Binaries
  • Create a blank solution in source CRM. Include Plugin or workflow assembly. Do not include any sdk message processing steps.
Create Solution with Plugin Assembly
  • Export the solution and save it on your computer. Unzip the solution.
Export Solution
  • Go to folder which has the plugin. Open ILSpy.exe. Drag and drop the plugin to ILSpy.
Open Folder with Plugin Assembly

Open ILSpy.exe

Drag and Drop the Plugin Assembly to ILSpy

As you can see all the namespaces used in a plugin are extracted. This way even if you do not have the DLLs, you can create references in the Visual Studio solution by including all namespaces and the code within. Hopefully this will help compile the code.

Sunday, 10 December 2017

Adding and Updating Security Roles to a Migrated Business Process Flow

There is still an issue in case you want to "Enable Security Roles" for a migrated Business Process Flow in Dynamics 365 Version 9.

When you do a migration from a lower version of Dynamics CRM to Dynamics 365 and as part of the migration are existing custom business processes. If you open one of these business processes and select "Enable Security Roles", there are no options to either "Enable for everyone" or "Enable only for the selected security roles". 

"Enable Security Roles" Option for Migrated Business Process

In Dynamics 365 for new Business Process Flows and existing system Business Process Flows, there are no issues. You can find options "Enable for everyone" and "Enable only for the selected security roles". 

"Enable Security Roles" Option for Existing Business Process

The solution is to directly open "enable security roles" windows for a migrated business processes using a URL.

The format of the URL for a Business Process in my Dynamics 365 V9.0 environment would be:

https://ashishm1974.crm.dynamics.com/tools/dialogs/RoleAssignment.aspx?dType=1&oid=%7b6E9A821B-3CBC-4F04-9619-F2B723FE4880%7d

This will directly open the window to enable security roles for a business process. Replace the URL and Business Process GUID as in your Dynamics 365 environment.


Thursday, 7 December 2017

Who are Data Scientists and What they Do

Now-a-days the buzz word is Data Analytics. Customers are savvy and want to know how we can help analyze their data.

I feel Data Analytics should be part of every medium to large Dynamics 365 project. This is first of many blogs I will start writing for Data Analytics.

Good news is that Microsoft is already leading the way in Data Analytics through extreme investments in Dynamics 365, Windows, Azure, Machine Learning, SQL Server and IoT. 

Data scientists are a special breed who work on data and have the art of making some sense out of it. Having said that it is not as simple as picking customer's SQL Server and start writing TSQL queries. 

Data scientists should have the following
  • Constant learning of current state of any project or business
Customer's data is the representation of its business in the form of numbers, text, dates and images.
  • Fully understand the expectations and deliverable 
Planning and the execution both depend on the end goal. A data scientist should be clear of what is expected so that the analysis and transformation can be performed accordingly.
  • Knowledge of methodologies and tools 
A data scientist should be aware of various methodologies and tools available at his/her disposal. For example, Microsoft has many tools for data analysis and they work with all kinds of data.
  • Curiosity, Persistent, Patient and Focused 
A data scientist sometimes need to churn Terabyte or Petabyte or Exabyte of data. Therefore they need to have constant curiosity and be persistent, patient & focused to explore, visualize, slice and dice data.
  • Technical Savvy
Data scientists should know how to work with raw data. They should be able to transform it to an easy format & visualization so that correct analysis can be made and timely decisions can be reached. Data scientists should be good in math and statistics. Statistics is a branch of mathematics dealing with the collection, analysis, interpretation, presentation, and organization of data.

What does a Data Scientist Do?
  • Data scientists spend most of the time preparing data
Data scientists need to clean, prepare and process raw data so that it can be analyzed. 
  • Run software programs against data
Data scientists use various software programs and languages to analyze data. For example SQL query language, R, Python, Hive, Hadoop, Microsoft R Server, Power BI, Excel, etc.
  • Prepare Reports and Visualizations
Data scientists produce reports, charts and tables for easy understanding.

Saturday, 2 December 2017

C# Code to Retrieve System and Custom Views from Dynamics 365 (Version 9.0)

There are times we write utilities to retrieve CRM data/information using C#. My favorite is a .NET console application which I always create for my projects. In this console app I dump useful code snippets which makes my work very productive.

In this blog I will provide C# code to retrieve System and Custom views.

Code:

using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Tooling.Connector;
using System;
using System.Configuration;
using System.Linq;
using System.ServiceModel;

namespace ConsoleUtilities
{
    class GetViews
    {
        public static void Main(string[] args)
        {
            try
            {
                CrmServiceClient crmConn = new
                    CrmServiceClient(ConfigurationManager.ConnectionStrings["CRMConnectionString"].ConnectionString);

                IOrganizationService crmService = crmConn.OrganizationServiceProxy;

                OrganizationServiceContext orgContext = new OrganizationServiceContext(crmService);

                var objCRMViews = from crmView in orgContext.CreateQuery("savedquery")
                                  select new
                                  {
                                      savedQuery_SavedQueryId = crmView["savedqueryid"],
                                      savedQuery_Name = crmView["name"]
                                  };

                foreach (var localObjCRMViews in objCRMViews)
                {
                    System.Console.WriteLine("savedQuery_savedqueryid: "
                        + localObjCRMViews.savedQuery_SavedQueryId.ToString());
                    System.Console.WriteLine("savedQuery_name: "
                        + localObjCRMViews.savedQuery_Name.ToString());
                    System.Console.WriteLine();
                }

                // exit
                Console.WriteLine("Press any key to exit.");
                Console.ReadKey();
            }
            catch (FaultException<OrganizationServiceFault> ex)
            {
                string message = ex.Message;
                throw;
            }
        }
    }
}

Explanation:

1) Use the following types in a namespace.

"using" Directive - Namespace

2) Connect to Dynamics 365 V 9.0 online or on premise. Write a LINQ query to retrieve all views. Loop through and display all the views. At the end exit the console app.

LINQ Query to Retrieve All Views

You can also add a "Where" clause to the LINQ query to retrieve only one view. In my case I have added the where clause to retrieve a view named "Payments with No Taxes".

LINQ Query to Retrieve One View

3) Add Try/Catch to handle any exceptions.

Try/Catch
You can use this utility to get a list of all views or get information on just one view. This is useful when developing and customizing a CRM application.

Friday, 1 December 2017

Use of Option Set Vs Two Options in a Business Process Flow

Business processes within Dynamics 365 streamlines and creates a visualization of information flow through various stages. Each stage combine "data steps" to reach a business decision to either move forward or backward.

The data steps in a business process stage are fields used to capture information. Option sets and two options can be used as data steps. 

Two option should only be used if a data step is not required in a business process stage. The problem with two options is that they cannot have "unassigned value" as a default. Therefore even if a two option is marked as required on a business process stage, one can still move to next stage based on the default selected.

1) I have created 2 fields on Opportunity. These will be used as data steps to capture whether due diligence is done. 
One field is an option set with two values "Yes" and "No". The default value is unassigned.

Option Set Field

Second field is a two options with values "Yes" and "No". Default value is "No". The issue here is that the default value can only be selected as "Yes" or "No".

Two Options Field

2) Both these fields are displayed as data steps on the Opportunity Business Process "Qualify" stage.

Business Process on Opportunity


3) Open a new Opportunity, enter a "Topic" and "Save". This will create a new opportunity in "Qualify" stage. As seen the two fields are displayed as data steps in "Qualify". The top field is an option set and bottom field is a two option.

Testing these Fields


4) The both are required but only option set field will force a user to select a value (if nothing is selected) when moving to next stage. 

Option set can have an unassigned value as a default. Therefore always use option set over two options whenever it is required to capture data on a business process stage

Wednesday, 22 November 2017

How to get started with 30-Day Free Online Dynamics 365 Version 9.0 Trial

You can easily create a 30-day free online 'Dynamics 365 version 9.0' trial through Microsoft.

1) Go to https://www.microsoft.com/en-us/dynamics/free-crm-trial.aspx

2) Click on "Get Started".

Microsoft Online CRM Trial Page

3) Select a relevant Dynamics 365 app. For example, I selected "Dynamics 365 for Sales". If you are creating this ORG in your company Office 365 tenant, enter your work email and phone number. I am creating a personal ORG for myself. Therefore, I will select "Sign up here".

Select an App

3) Enter your name, personal email, phone number, company name, language and organization size. Click on "Next".

Enter your Details

4) Select a username and password. These will be used to connect to Office 365 Portal and Dynamics 365. The first part of username before @ sign will be used to create the Dynamics 365 URL. Click on "Create my account".

Select User ID and Password

5) To prove that you are not a robot, enter your phone number to receive a code. The code can be texted to your mobile number. Click "Text me".

Get Code

6) Enter the code and click "Next".


Enter Code

7) Your personal Office 365 Portal will be created. Click and go to the next step.

Setting up Office 365 Portal

8) After Office 365 Portal setup, you can create a new Dynamics 365 trial ORG. Select the language, apps and default currency. For my purpose, I selected English as language, all apps and USD as default currency.

Settings for Dynamics 365

9) Wait for few minutes. This will set up a brand new Dynamics CRM 365 Version-9 30-day trial ORG. After completing the setup you will be redirected to Dynamics 365 ORG.

The path to your ORG would be
https://<<your user ID part before @ sign>>.crm.dynamics.com/main.aspx

Dynamics 365 Version 9.0

10) Click on arrow next to Dynamics 365 to view available apps as selected during setup. In my case, I have Dynamics 365 apps for Sales, Customer Service, Project Service and Field Service.


Dynamics 365 Apps

11) You can go to Office 365 portal to use other services like Office and SharePoint.

Office 365 Portal

You can repeat these steps to create multiple test Dynamics 365 ORGs.