Thursday, 6 September 2018

Dynamics CRM: SandboxAppDomainHelper.Execute


With upgrade of Dynamics CRM after 2016 some time we faced different kind to strange issue.
Recently I had faced issue in one of our running plugins.

Error: -
Parameter name: SandboxAppDomainHelper.Execute: The plug-in type could not be found in the plug-in assembly: MyAssemblyName

Dynamics CRM Version: -











After debugging and doing different R&D we find there is no issue in our plugin code.
Issue was occurred due to Microsoft update. If you find this kind of error fellow below steps. Hope this will also works for you.

Resolution Steps: -
1.        Update below reference in “MyPluginName” assembly with version 9.0
·         Microsoft.Crm.Sdk.Proxy
·         Microsoft.Xrm.Sdk
2.       Update assembly using plugin registration tool.
3.       Update below reference in “MyPluginName” assembly with version 8.2.0.0
·         Microsoft.Crm.Sdk.Proxy
·         Microsoft.Xrm.Sdk
4.       Update assembly using plugin registration tool.
5.       Disable and again enable below step
I had used Nuget “Microsoft.CrmSdk.CoreAssemblies” package.


Share your comment and follow blog to be updated.
Happy CRM!!

Thursday, 30 August 2018

Dynamics CRM: Note Control Customization


In Dynamics CRM 2013 onward Microsoft introduce note control with more options.
Note control have “Posts’, “Assistance”, “Activities” , “Notes”, “One Note” etc.
















This is a great Control to see all information in single control.
But this control does not support any customization. Some time we need to customize this control for our users.

I will try to explain how we can customize note control. However, this customization is Unsupported customization and not recommended by Microsoft.

Requirement: - I had the requirement where I need to show “Activities” and “Notes” on contact form and only “Notes” on Account Form.

Solution: - I have create a html web resource to accomplish my requirement. In HTML we are getting note control help of getElementById method of DOM Javascript. After getting note control based on our requirement we remove unwanted elements from our control like “POST” and “ASSISTANT” from contact form.

Import below solution in your organization. CRM version 9.0. This solution contains HTML web resource need to use. If you faced any issue while importing, unpack this solution and create a new HTML web resource in your organization and paste html code from sav_wsblankhtml file.


Download Solution


Once web resource is created, add this on contact or other entity form as required below note control.











After adding web resource pass parameter to hide required components. And uncheck visibility. Change value as per requirement.

POSTS=true&ASSISTANT=true&ACTIVITIES=false&NOTES=false&ONENOTE=true























Open “Activities Tab” property and select tab which need to default and visible always.
























Now Publish your customization. And refresh(ctrl+r) your entity record.

Result: -

Contact record:













Account record:














Share your comments and follow blog to be updated.
Happy CRM!!

Wednesday, 1 August 2018

Dynamics CRM: Delete Components From Managed Solution


Currently I have faced a scenario where I need to remove few unused components from my managed solution in Production Instance.

My first approach was remove unused components from my solution in Dev instance and export as managed solution than re-import in Production. But this approach not worked for me.

So, my second approach was delete unused components from my solution in Dev instance and export as managed solution than re-import in Production. But this approach also not worked for me.

Finally, I found one approach that works and fulfill my requirement. Here I am sharing my final approach, and this also work in supported way.

I will try to explain this with a simple example where no dependencies components are present.


  • I have created one solution named Solution1 in Dev instance and create a two new entities Entity1 and Entity2 in that solution and publish all customization.









  • Export Solution1 as Managed Solution from Dev and import in Production Instance. This will create Entity1 and Entity2 and my Production Instance.






  • Now create new solution named Solution2 in Dev Instance and add Entity1. Here we have not added Entity2 in this solution because we need to delete Entity2 from all Instance as result.








Note: - If number of components are larger, than use Xrmtoolbox “Manage Solution” Plugin to create clone to solution. And remove unused component from newly created solution.










  • Export Solution2 as Managed Solution from Dev and import in Production Instance. This will not create any entity but hold Entity1 as another managed solution layer.







  • Delete managed solution Solution1 from your Production instance. This will delete solution and its component but Entity1 will remain in your Production Instance due to Solution2.







  • Now Delete Entity2 from Dev instance and publish all customization.








  • Export Solution1 as Managed Solution from Dev and import in Production Instance. This will not create any entity but hold publisher, solution name all other components as it was required in this approach. 
Expected Result: -








  • Delete managed solution Solution2 from Production and Dev instance to clean instance.

 With this approach, I was able to remove my all unused component from my solution. Also, solution name is same and no need to data backup and reimport. But solution Installed On date is changed which was not important in my use case.

Thursday, 19 July 2018

Dynamics CRM : ViewRoleConfiguration

Recently in Dynamics 365 I got a requirement to show system views based on user security role. 
I try find any out-of-box way to achieve this but unfortunately there is no Out-of-box way to achieve this.
I had developed customize way to configure System views visibility based on security role. 
After completing my solution, I think this might be requirement for other CRM users also.

This tool is working only on classic CRM and also install a solution in your environment.

So, I have created XRMToolBox plugin for this configuration. Now anyone can download this plugin either from XRMToolBox or from given link ( Download Plugin) and configure.

Configuration: -

  • Open XRMToolBox and connect to your Organization.
  • Search “view-role configuration” if already installed else go to XRMToolBox “Plugin Store” and install this plugin. Or save downloaded plugin in your Plugin folder.















  • Open View-Role Configuration plugin. If you are using this plugin first time you need to click on “Import Solution” button first.
















  • This step will install a new solution named “ViewRoleConfiguration” in your organization. This solution is developed on Dynamics 365(9.0) version.









  • Once this solution is successfully installed. We are ready to configure our system views based on different security role.
  • Click on “Retrieve Data” button. This will retrieve security role list and entities list.














  • Select your “Security Role” for which you want to configure view permission.













  • Now select entity for which need to configure view permission.















  • On Entity selection, it will show all system views whose (querytype is 0). I.e view which shows in view selector.





























  • Select the view which you want to hide for given security role.

Example: - I am using “My Active Accounts” for demo.

  • Now click on “Save Data”. This will create a record in “View Role Configuration” entity. This record will be used to enable security role-based view visibility.





















Before View-Role view configuration: -





After View-Role Configuration: -
























  • We can see that “My Active Accounts” is not visible in Account view selector list. Even this view also not available in advance find view.












  • When we want to remove View-role security. Follow the same process and now just de-select view and click on “Save Data”. This will delete the configuration record and view will become available for that security role.
  • We can also delete this solution from your organization with the help of given plugin.












Note: - Use two users while testing this plugin. One user by which you connect XRMToolBox. Second user which have that security role on which you are configuring security role-based system views.

Please provide your comment and share your reviews.

Thursday, 5 July 2018

Dynamics CRM: Manage Solutions


People says, “Necessity is the mother of invention”. But I think “Laziness also initiator of invention”.  ðŸ˜Š

In CRM as a developer we always played with Solution. We create new solution to manages our development and to transfer our work from Dev to Test instance etc. Solution also required for marketplace package movement.


After CRM 2016, Microsoft also added two new option in Solution: -
Clone a patch- To make small change related to parent solution.
Clone Solution- To merge current solution and patch in single updated solution. And remove previous one.
But here I am not discussing about these features because you will find some good materials related to these new features in google.

Use Cases: -
  • When I was working for one of my project I have a solution more than 400 components. And I need to create a solution with 300 components of that solution. You could say Clone a patch might work but not in my case because it creates dependency on parent solution and create a blank solution.
  • In one of another project I had a managed solution in Production. In development Organization have unmanaged solution which played by lot of team members, as we developer do always.😉 We need an unmanaged solution from that managed solution. But Microsoft do not give any feature for this.
  • I need to export list you all solutions. But no option found either in advance find or in solution view.
While tackle with these situation, I was thinking there should be something a single click option to do so.
Now I started developing a XrmToolbox plugin to help me. Today I am deploying my Plugin for all developers and soon it will be available in XRMToolbox also.

Features of this Plugin.
  • Retrieve all Solutions
  • Make a Copy of Solution
  • Delete Solution
  • Export Solution to folder
  • Export Solution list to excel
  • Publish All Customization.

Download XRMToolBox from given URL and install. https://www.xrmtoolbox.com/

Install Managed Solution Plugin in your XRMTollBox using plugin store.























If you are not able to find Manage Solution plugin.
Download Plugin
Install in XRMToolBox by clicking Settings->Path->Storage folder->Plugin folder.
Copy assembly in Plugin folder.









































Connect your organization and open plugin Managed Solution.






Click on “Retrieve Solution”. Now you will see list of all solutions and their information.














Select any managed or unmanaged solution to make a copy of it. Select solution and click on “Make a copy” button. Before creating a copy, you need to provide new solution name.










It will create a copy of your solution with all source solution component.










To Delete any solution, select your solution and click on “Delete Solution” button.

To Publish all customization, click on “Publish All Customization” button.

To export all solutions list, click on “Export Grid” button provide your location to store solution excel sheet. Make sure you have MS office preinstall to use this option.










To export any unmanaged solution, select unmanaged solution and click on “Export Solution” and it open a new form. Fill required details in new form and click “Export” button.



























It will save your unmanaged solution in your specified location. You can save managed and unmanaged solution same time.
With this plugin I was able to tackle all my use cases in lesser time. 

"I choose a lazy person to do a hard job because a lazy person will find an easy way to do it" 
      Bill Gates.......
Note: - Plugin based on .net framework 4.5.2

Please share your feedback.
Follow my blog so you will not miss my new upcoming blogs.

Tuesday, 5 June 2018

Dynamics CRM: Access Local Web API


In Microsoft Dynamics 365 we always need to integrate with other software or application.
Most of integration need custom or built-in connector to send and receive data from Dynamics CRM.

In almost each integration we need web API to sent and receive request. This mainly consider through server-side code or scripting.

But in some cases, we need to implement client-side scripting to use our web API.

Use Case: -
                        We have created a Rest based web API in our local system. And it works fine in local environment. We need to call our local Web API from Dynamics CRM.
We need to tackle cross-browser request-response issue. We should ale to call our web API from client-side scripting like “JavaScript”.

We can also deploy our Web API in Intranet organization. We can also deploy our web API in Azure portal or other portals, so it can also support server-side. But in this article, I am not considering Server-side API consumption.

Prerequisite: - 
  • Visual Studio (Example on VS 2013)
  • Internet connection
  • Dynamics CRM instance (online or on-premise)

Steps: -

  • Create a Web API.
  • Handle Cross-platform access
  • Calling Web API from local web application
  • Calling Web API from Dynamics CRM.

Let Start!!
Create a Web API: -
                                Open Visual studio and create and click on new project select “ASP.NET web Application” from template.



















Select “Empty” template and check “Web API” from add folder and core reference folder.



















Open package manager console and install Cors package to handle cross-platform.















Install-Package Microsoft.AspNet.WebApi.Cors














Now Add new controller class named “TestController”.










Add below code in your class.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
using System.Web.Http.Cors;
namespace LocalWebAPI.Controllers
{
    [EnableCors(origins: "*", headers: "*", methods: "*")]
    public class TestController : ApiController
    {
        string fileName = @"D:\demo.txt";
        public HttpResponseMessage Get()
        {
            try
            {
                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                // Create a new file
                using (FileStream fs = File.Create(fileName))
                {
                    // Add some text to file
                    Byte[] title = new UTF8Encoding(true).GetBytes("Demo Text File");
                    fs.Write(title, 0, title.Length);
                    byte[] Time = new UTF8Encoding(true).GetBytes(" " + DateTime.Now.ToLongTimeString());
                    fs.Write(Time, 0, Time.Length);
                }


            }
            catch (Exception Ex)
            {

            }
            return new HttpResponseMessage()
            {
                Content = new StringContent(DateTime.Now.ToLongTimeString())
            };
        }

        public HttpResponseMessage Post()
        {
            return new HttpResponseMessage()
            {
                Content = new StringContent("POST: Test message")
            };
        }

        public HttpResponseMessage Put()
        {
            return new HttpResponseMessage()
            {
                Content = new StringContent("PUT: Test message")
            };
        }
    }
}

You can see we have added below code on the top of class to allow all request from any system. Later we will restrict to our Dynamics CRM application only.

[EnableCors(origins: "*", headers: "*", methods: "*")]














Now open “WebApiConfig.cs” class and add below code.
config.EnableCors();

Now our Web API is ready to test and use. Press F5. It will open forbidden page.
Add”/api/test” after URL to test your Web API.

Example: -

You can see now output as current date. You can also check local file that create by our Web API at specified location.
I.e we can also use File operation in our Web API.
































Calling Web API from local web application: -
                                                                                Open Visual Studio and create Asp.Net or HTML application.
Add a HTML page in your application and add below code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript">

        var xmlHTTP;
        if (window.XMLHttpRequest) {
            xmlHTTP = new window.XMLHttpRequest;
        }
        else {
            try {
                xmlHTTP = new ActiveXObject("MSXML2.XMLHTTP.3.0");
            }
            catch (ex) {

            }
        }
        xmlHTTP.open("GET", "http://localhost:51453/api/test", true);
        xmlHTTP.onreadystatechange = function () {
            if (xmlHTTP.readyState == 4 && xmlHTTP.status == 200) {
                alert(xmlHTTP.responseText);
            }
        }
        xmlHTTP.send();

    </script>
</head>
<body>

</body>
</html>
Replace URL with your local host URL. Now run your HTML page and you will able to call your Web API.
Make sure your previous Web API application is in running mode.

Calling Web API from Dynamics CRM: -
                                                                                Login in your Dynamics CRM organization and create a solution and add HTML web resource that we have already created.













Click on “PREVIEW” button to test your Web API.












If everything working fine. Now time to restrict to WEB API call from to accept only our Dynamics CRM call instead of all.
Stop your Web API application and replace “*” with your Dynamics CRM URL in “TestController” Class.










If you want that you Web API can access from all user in your Intranet network. Than publish our Web API any local server IIS which should be accessible in your Intranet network.

Limitation: - These web API and not accessible from server-side. So, you will not able to use this Web API in plugin or custom workflow.

You can enhance this functionality based on your requirement.
Please comment if faced any trouble while implementation. 

Click on follow button to be updated about my blogs.

HAPPY CRM 😊!!

Field Security Profile - Based on Owner

 Recently received requirement related to Field security profile. Expectation : - 1.       Set to users need access of secure attributes. 2....

Test