Microsoft Dynamics CRM 2011

Microsoft Dynamics CRM 2011

Thursday, September 10, 2015

Install CRM 2013 Developer Tools in your Visual Studio 2012

In this article we describe Step by step How to Install CRM 2013 Developer Tools in your Visual Studio 2012 in 5 minutes.
The CRM 2013 Developer Toolkit , once installed inside the Visual Studio 2012, will allow you to easily create CRM Plugins , Dialogs and Workflows , accessing to CRM Entities and strongly typed proxy classes, and even create, edit and deploy CRM Web Resources, everything from your code!!! The CRM 2013 Developer Toolkit will allow you to easily deploy your code on CRM web servers  :

Install CRM 2013 Developer Tools in your Visual Studio 2012



How to Install CRM 2013 Developer Tools in your Visual Studio 2012



Phase 1: Check for required prerequisites before installing the Developers Toolkit:

Go to the Install or uninstall the Developer Toolkit to check for prerequisites, and to the Developer Toolkit for Microsoft Dynamics CRM web page to see the details of the Developers Tools:

Install CRM 2013 Developer Tools in your Visual Studio 2012 1


Install CRM 2013 Developer Tools in your Visual Studio 2012 2



Phase 2: Download the Toolkit and open the ZIP file:

Click on the installer and follow the CRM 2013 Developer Tools for Visual Studio 2012 setup instructions:
Install CRM 2013 Developer Tools in your Visual Studio 2012 3





Phase 3: Finish the CRM 2013 Developer Tools in your Visual Studio 2012  Setup :


After you finish the CRM 2013 Developer Toolkit for Visual Studio 2012 installation , save your projects, close Visual Studio 2012, and reopen it, to see the changes:

Install CRM 2013 Developer Tools in your Visual Studio 2012 4



As you can see, now there are Templates for you to use when creating a new CRM 2013 Plugin or Workflow.




That's all...Enjoy Dynamics CRM

by Carmel Schvartzman

כתב: כרמל שוורצמן

    Friday, August 14, 2015

    How to Check Error Codes in Dynamics CRM API Web Service

    In this article we see Step by step How to Check Error Codes in Dynamics CRM API Web Service  .
    We'll review here in only 5 minutes how to search for the DYNAMICS CRM API web service error codes , such as "0x80041a06" , for example :


    How to Check Error Codes in Dynamics CRM API Web Service


    How to Check Error Codes in Dynamics CRM API Web Service


    The steps are as following:
    1) open the error file and find the corresponding XML element for the Entity
    2) get the hexadecimal error code for the Entity and get rid of the hexadecimal prefix "0x"
    3) search the web for the error without the "0x" prefix


    1) Step #1: open the error file and find the XML element for the Entity :

    Check Error Codes in Dynamics CRM API Web Service



    2) Step #2: get the hexadecimal Error Code without its "0x" prefix :


    Error Codes in Dynamics CRM API Web Service




    3) Step #3: search the Web for the Error code without the prefix "0X":

    How to Check Error Codes




    That's all.

    Happy programming.....

          by Carmel Schvartzman


    כתב: כרמל שוורצמן


    Sunday, July 5, 2015

    How to Add a custom Button to a CRM 2013 Web Form

    In this article we see Step by step How to Add a custom Button to a CRM 2013 Web Form .
    We'll review here in only 5 minutes how to create an HTML5 Button at the client side Front End , using only javascript, HTML and CSS3:




    The steps are as following:
    1) create a CRM field to be the container of the button(set its text as ".")
    2) create a web resource containing the following javascript
    3) call the web resource from your CRM form, sending as argument the name of your container field.


    1) Step #1: create a CRM field to be the container of the button:


    The button will be located at the CRM field (called "sFieldName" in the following code).
    Try to create a new CRM field to parent the button, and set "." as its text. This way the button will fill the field, and you can locate it wherever you want inside the CRM form.

    2) Step #2: create a web resource containing the following javascript:

    This is the code that creates the Button:
    It just retrieves the HTML5 element wrapping the CRM field where you want the button appended to, and creates an element with a custom button:





    Create a Web Resource with the following javascript code (note: this code does not depend on jQuery or any other framework: you can copy-paste it as it is):

    function fnXRMClientButton(sFieldName)
    {   // sFieldName : "new_somefield"
        
        if (document.getElementById(sFieldName) != null) {
             sFieldName = "field" + sFieldName;
             if (document.getElementById(sFieldName) == null)
             {
                var oParentElement = document.getElementById(sFieldName + "_d");
                oContainerElement = document.createElement("oContainerElement");
                oParentElement.appendChild(oContainerElement, oParentElement);
                
                var btn = document.createElement("button");
                var txt = document.createElement("span");
                txt.innerText = "BUTTON TEXT";            
                btn.id = "btnCallAction";
                btn.appendChild(txt);
                btn.style.margin = "10px";
                btn.style.padding = "5px";
                btn.style.width = "300px";
                btn.style.height = "50px";
                btn.style.textAlign = "center";
                btn.style.borderRadius = "5px";
                btn.style.textShadow = "1px 1px 2px #FFF";
                btn.style.color = "#000";
                btn.style.boxShadow = "#a8a3a3 5px 5px 1px";           
                btn.style.border = "1px double #dcdcdc";           
                btn.style.background = "#f5f5f5";
                btn.style.font = "600 14px Tahoma";
                oContainerElement.appendChild(btn);


                document.getElementById(sFieldName).style.width = "0%";
                btn.onclick = function () {
                    OnClickActionFunction(oContainerElement);

                };

            }
        }
    }


    3) Step #3: call the web resource from your CRM form, sending as argument the name of your container field:


    fnXRMClientButton("new_somefield")


    That's all.  

    Happy programming.....

          by Carmel Schvartzman


    כתב: כרמל שוורצמן



    Tuesday, June 9, 2015

    How to watch SSIS Variables values at debugging in Sql Server Integration Services

    In this article we see Step by step How to watch SSIS Variables values at debugging in Sql Server Integration Services .
    We'll review here in only 5 minutes how to check SSIS variables at runtime, telling apart those at Foreach Loops from those at Data Flows  . We'll be using the following SSIS application:

    How to watch SSIS Variables values at debugging in Sql Server Integration Services


    How to watch SSIS Variables values at debugging in Sql Server Integration Services


    In the picture below you can see the guiding principles of watching variables at runtime  in a  "Data Flow Task" :

    watch SSIS Variables values at debugging in Sql Server Integration Services


    To start, select the SSIS item in which you want to watch the variables values.
    Since variables have  scopes,   you should make sure that the current scope comprehend the chosen item.
    We'll start by setting a breakpoint in a Data Flow Task .
    Now that you decided which flow item to watch,  click the "Edit Breakpoints" menu  :


    Now choose the Break condition where to stop the debug . Mostly it can be the OnPreExecute event, or any one of the several Events that you can see on the following picture:


    SSIS Variables values at debugging in Sql Server Integration Services

    However, in case of a Foreach Loop Container, it stands to reason that you will want to watch the variables at the start of every loop iteration . So select from the checklist the "Break at the beginning..."  option:


    values at debugging in Sql Server Integration Services

    It can also be set in which cases to stop the runtime: it can be set to stop when the breakpoint has been reached certain times:


    Variables values at debugging in Sql Server Integration Services

    Once you finished setting the breakpoints, start the debug and, while the breakpoint has been reached, open the "Locals" window. There you will find all the current variables in scope:



    debugging in Sql Server Integration Services

    How to watch SSIS Variables values at debugging


    That's all.  

    Happy programming.....

          by Carmel Schvartzman


    כתב: כרמל שוורצמן




    Tuesday, April 21, 2015

    How to use Tracing in CRM 2011-2013 Plugins and Workflows

    In this article we describe Step by step How to use Tracing in CRM 2011-2013 Plugins and Workflows in C# in 5 minutes.
    Since CRM Plugins and Workflows are deployed on web servers after the development reaches the release stage , it is usually very helpful to include tracing in your code in profusion, not only in error cases, at least when you are putting to the test new developments .
    CRM 2011-2013 allows you to include tracing galore:
    How to use Tracing in CRM 2011-2013 Plugins and Workflows



    How to use Tracing in CRM 2011-2013 Plugins and Workflows



    Phase 1: use the GetExtension() method from the "context" at your plugin-workflow:
    Tracing in CRM 2011-2013 Plugins and Workflows


    Since this is a generic C# Dot.Net method, use the ITracingService interface to get the tracing service from the context.


    Phase 2: Send the ITracingService to any method where you intend to log information using tracing:

    CRM 2011-2013 Plugins and Workflows

    For example:

    How to use Tracing in CRM


    Phase 3: inside the plugin's methods, call the ITracingService's Trace() method to send messages to the tracing:

    How to use Tracing in CRM 2011-2013


    In case of error, CRM will display an alert showing the tracing:


    How to use Tracing in CRM 2011-2013 Plugins and Workflows


    That's all...Enjoy Dynamics CRM

    by Carmel Schvartzman

    כתב: כרמל שוורצמן


      Wednesday, April 15, 2015

      How to programmatically create a CustomerAddress in Dynamics CRM 2011/2013


      1. In this article we see how to programmatically create a CustomerAddress in Dynamics CRM 2011/2013. 
        In CRM 2013, the address data of an Account or a Contact are stored in a separate Entity called CustomerAddress, on a 1:N relationship basis, in which an Account can have (and have, by default) many addresses.
        This post is about Dynamics CRM 2011 - 2013 custom Plugins or custom Workflows, and any   C# code which calls the CRM Organization Web Service to create a new CustomerAddress item , that means, a third address for an Account or a Contact. The following snapshot shows the Account address fields:
        How to programmatically create a CustomerAddress in Dynamics CRM 2011/2013

      How to programmatically create a CustomerAddress in Dynamics CRM 2011/2013


      1. When an Account is created, CRM creates by default 2 addresses for it, from  the CustomerAddress entity type, which are called Address1 and Address2.
      2. If you intend to programmatically update the Account or Contact address, and not to create a new address, you just instantiate the following Account fields with the data, and CRM will automatically update the corresponding CustomerAddresses objects related to the specific Account:
      oAccount["address1_telephone1"]
      oAccount["address1_line1"]oAccount["address1_city"]oAccount["address1_postalcode"]


      Change "Address1" with "Address2" if you want to update the second Account address.

      If you intend to create a new (third) CustomerAddress item for the Account, follow this step by step instructions:

      1. First we write a check to see whether we got a legal ID of the Account we want to refer to:

        if (guidParentAccount.HasValue){
      2. Then we create the CustomerAddress entity , and instantiate the "ParentID" of the CustomerAddress . When creating a new address for an Account or a Contact entity, it's crucial to provide a reference field which points to the "ParentId" , that means , the Account or Contact to which belongs this new address. The C# code below instantiates the "ParentId" property with the actual Account , and not just the Parent's  ID (guid) :

        Entity oAccountAddress = new Entity("customeraddress");                                  
        EntityReference parentID = new EntityReference();                   
        parentID.Id = guidParentAccount.Value;                   
        parentID.LogicalName = "account";
                           
         oAccountAddress.Attributes["parentid"] = parentID;
      3. However, if you try to instantiate this "ParentId" field with the guid, you will be confronted with an exception , that's raised informing that the value is null : this error message is misleading, and we wrote about it in another article here.
      4. Another way, shorter, to instantiate the ParentID is the following:

        oAccountAddress["parentid"] = new EntityReference("account", guidParentAccount.Value );
      5. Next we save the street in the "line1" field: for the example, here i made a street search by street code on a generic List<> which contains street codes and descriptions:
                        

          string sStreetDescription = String.Empty;                   
          if ( oStreetList != null &&  oStreetList.Count > 0  && iStreetCode > 0)                   
          {                       
                   sStreetDescription = oStreetList.FirstOrDefault(sc => sc.Code == iStreetCode).Description;                       
                   if (sStreetDescription.Length > 0)                       
                   {                           
                             oAccountAddress["line1"] = sStreetDescription;                       
                   }                   
          }
      6. Next we save the city  in the "city" field: for this example, here i got a city object also from data migration, which contains both city code and description:

        string sCityDescription = String.Empty;                   
        if (oCity != null)                   
        {                       
              sCityDescription = oCity.Description;                       
              if (sCityDescription.Length > 0)                       
              {                           
                       oAccountAddress["city"] = sCityDescription;                       
              }                   
        }


      7. Then we instantiate the "postalcode" and "telephone1" properties:

         if (oAccount.Zip != null)                    
        {                        
                 oAccountAddress["postalcode"] = Convert.ToString(oAccount.Zip);                    
        }
        oAccountAddress["telephone1"] = oAccount.Phone ?? "0";
      8. Finally we call the Organization Web Service to create the CustomerAddress entity from the Account:

        Guid? guidAccountAddress = XrmContext.Create(oAccountAddress);
      9. The CRM database will then reflect the 3 addresses (AddressNumber 1,2 and 3) as shown here:
        How to programmatically create a CustomerAddress in Dynamics CRM 2011/20131
         


      That's all...Enjoy Dynamics CRM!!!

      by Carmel Schvartzman

      כתב: כרמל שוורצמן

        Monday, April 13, 2015

        How to name SQL parameters in an SSIS Execute SQL Task

        In this article we describe Step by step How to name SQL parameters in an SSIS Execute SQL Task , to avoid the common Sql Server Integration Services error : "Parameter name is unrecognized."  
        We follow here the conventions introduced by  MSDN in the SQL Server documentation for SSIS . For explaining naming SQL parameters in an Execute SQL Task ,  we will make use of the following SSIS application:

         How to use SQL parameters in an Execute SQL Task


        How to name SQL parameters in an SSIS Execute SQL Task



        We will want to give to the SQL parameters a proper name in order to avoid  the "Execute SQL Task" error, that can be seen in the picture above   : "Parameter name is unrecognized." :


             How to use   Execute SQL Task



        The  MSDN Documentation explains that naming conventions for using SQL  parameters in OLE DB  should be as follows:

        How to use SQL parameters in an Execute SQL Task 1





        Suppose that we have this SQL query which is using parameters. Then we must use the "?" marker this way :

         How to fix the SSIS error :  Parameter name is unrecognized. 1


        All parameters must be mapped to the query markers, and indexed base "0" . So, as we have 4 "?" markers, we must name 4 parameters indexed from "0" to "3" ,  using integer numbers conforming to the index positions:


              WHEN ?  - ? <  0          
              WHEN ?  - ? > 0   
                
             
            

         How to use SQL parameters   2



        That's all...Enjoy Dynamics CRM

        by Carmel Schvartzman

        כתב: כרמל שוורצמן