Monday, 21 January 2013

Microsoft Dynamics CRM Timeout settings and settings which effect CRM


Please find various timeout settings which can effect CRM, they can be found in the various technologies used in CRM which vary from .NET, IIS, CRM SDK

  1. Registry on CRM application server(s)
    1. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\OLEDBTimeout
      1. In seconds
      2. The OLEDBTimeout value controls the SQL time-out value that is used for a single SQL query
      3. Default is 30 seconds
    2. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\ExtendedTimeout
      1. In milliseconds
      2. The ExtendedTimeout value controls the ASP.NET time-out value
      3. Default is 1,000,000
    3. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\NormalTimeout
      1. In milliseconds
      2. Specifies the SOAP call timeout for most operations
      3. Default is 300,000
  2. Web.config
    1. <httpRuntime executionTimeout=”300″ />
      1. .NET 3.0: “timespan” attribute.  The default is “00:01:50” (110 seconds)
      2. .NET 3.5 and 4.0: an integer in seconds.  Default is 110 seconds.
      3. Specifies the maximum number of seconds that a request is allowed to execute before being automatically shut down by ASP.NET.
  3. IIS/ASP.NET configuration
    1. IIS 6.0 -> Website Properties -> ASP.NET tab -> Edit Configuration button -> Application tab -> Request execution timeout (seconds)
      1. Related to this type of situation in CRM 4.0: http://blogs.msdn.com/b/crm/archive/2008/11/20/asp-net-2-0-50727-0-warning-event-id-1309-due-to-request-time-out.aspx
  4. When using the CRM SDK, there are also timeout settings that can be set via custom code:
    1. CRM 4.0 example:
      1. CrmService service = new CrmService();
      2. service.Timeout = 300;
      3. In milliseconds and default is 100,000
    2. CRM 2011:
      1. ServiceProxy.Timeout property (Timespan)

Thursday, 15 March 2012

CRM Difference between Secure & Unsecure Configuration in Plugin Registration tool

Dear All,


While browsing through to find difference between Secure & Unsecure Configuration in Plugin Registration tool found few interesting info so have combined the info and here it goes..Happy Reading

Secure Configuration of Plugin
Registration tool in CRM
Unsecure Configuration of
Plugin Registration tool in CRM
The Secure Configuration information could be read only by CRM Administrators.(Eg: Restricted data from normal user could be supplied here)


Unsecure configuration information could be read by any user in CRM. Remember its public information (Eg: Parameter strings to be used in plugin could be supplied here)

Imagine that you include a plugin,plugin steps and activate them in asolution. Later solution was exportedas Managed Solution to anotherenvironment. In this scenario, thesupplied Secure configuration  information would NOTbe available in the new environment. The simple  reason behind this is to provide more security to the contents of Secure Configuration.
Imagine that you include a plugin, plugin steps and activate them in a solution. Later solution was exported as Managed Solution to another environment. In this scenario, the supplied Unsecure configuration values would be available in the new environment.

One of the benefits to the plug-in architecture of CRM 4.0 is the ability to store plug-ins in the CRM database so they may be used by multiple CRM servers. This introduces a slight complication regarding the storage of configuration information. Because the plug-in assembly doesn’t reside on the disk the normal method of using a .config file located with the assembly no longer works.
Luckily, the plug-in architecture solves this issue by allowing the developer to supply configuration information for each step executed by the plug-in.
Plug-in Configuration Architecture
As noted in the CRM SDK article, Writing the Plug-in Constructor, when creating your plug-in, you may define a constructor that passes two parameters to your plug-in: unsecure configuration and secure configuration:
   1: public class SamplePlugin : IPlugin
   2: {
   3:   public SamplePlugin(string unsecureConfig, string secureConfig)
   4:   {
   5:   }
   6: }
Both parameters are strings and may contain any configuration data, in any format, that you wish. For the purposes of this discussion, we will only be concerned with the unsecure configuration parameter.
Creating a Configuration Structure
Since most of us are familiar with the XML configuration provided by the standard Properties.Settings structure, I thought it would be a great idea to retain as much of that experience as possible so we can move code from a stand-alone test application to a plug-in with little difficulty.
Using an XML fragment that closely resembles the Settings section found in the .config file of a .Net assembly, we can create a similarly functional system for storing configuration data. Consider the following XML:
   1: <Settings>
   2:     <setting name="RetryCount">
   3:         <value>5</value>
   4:     </setting>
   5:     <setting name="TaskPrefix">
   6:         <value>This task was created on {0}.</value>
   7:     </setting>
   8:     <setting name="FirstRun">
   9:         <value>false</value>
  10:     </setting>
  11: </Settings>
As you can see, we have three settings which contain values that we would normally find in our .config file and which are used to configure our assembly. Using the Plug-in Registration Tool, we can add this information to the Unsecure Configuration field when registering a new step, as show by the figure below:

Plug-in Configuration Class
I created a simple class to extract values from an XML document for simple data types such as Guids, strings, Booleans, and integers, given the structure we discussed above:
   1: class PluginConfiguration
   2: {
   3:     private static string GetValueNode(XmlDocument doc, string key)
   4:     {
   5:         XmlNode node = doc.SelectSingleNode(String.Format("Settings/setting[@name='{0}']", key));
   6: 
   7:         if (node != null)
   8:         {
   9:             return node.SelectSingleNode("value").InnerText;
  10:         }
  11:         return string.Empty;
  12:     }
  13: 
  14:     public static Guid GetConfigDataGuid(XmlDocument doc, string label)
  15:     {
  16:         string tempString = GetValueNode(doc, label);
  17: 
  18:         if (tempString != string.Empty)
  19:         {
  20:             return new Guid(tempString);
  21:         }
  22:         return Guid.Empty;
  23:     }
  24: 
  25:     public static bool GetConfigDataBool(XmlDocument doc, string label)
  26:     {
  27:         bool retVar;
  28: 
  29:         if (bool.TryParse(GetValueNode(doc, label), out retVar))
  30:         {
  31:             return retVar;
  32:         }
  33:         else
  34:         {
  35:             return false;
  36:         }
  37:     }
  38: 
  39:     public static int GetConfigDataInt(XmlDocument doc, string label)
  40:     {
  41:         int retVar;
  42: 
  43:         if (int.TryParse(GetValueNode(doc, label), out retVar))
  44:         {
  45:             return retVar;
  46:         }
  47:         else
  48:         {
  49:             return -1;
  50:         }
  51:     }
  52: 
  53:     public static string GetConfigDataString(XmlDocument doc, string label)
  54:     {
  55:         return GetValueNode(doc, label);
  56:     }
  57: }
Putting PluginConfiguration to Work
Once we have our PluginConfiguration class added to our project, we need to modify the plug-in constructor to extract the values from our configuration string:
   1: public SamplePlugin(string unsecureConfig, string secureConfig)
   2: {
   3:     XmlDocument doc = new XmlDocument();
   4:     doc.LoadXml(unsecureConfig);
   5: 
   6:     string TaskPrefix = PluginConfiguration.GetConfigDataString(doc, "TaskPrefix");
   7:     bool FirstRun = PluginConfiguration.GetConfigDataBool(doc, "FirstRun");
   8:     int RetryCount = PluginConfiguration.GetConfigDataInt(doc, "RetryCount");
   9: }
There is no automatic determination of data types so you will need to know which method to use to extract a specific value from the configuration data.

My Sincere Thanks to
Mitch Milam & D. MANJALY

Thanks For going through the blog

Tuesday, 21 February 2012

Finding CRM 4.0 License Key From Database

Dear Friends,


Way to find CRM 4.0 license  key


The CRM 4.0 license key can be found in MSCRM_CONFIG database in the ConfigSettings table.



USE MSCRM_Config 
SELECT LicenseKey FROM ConfigSettings
All the Best....

Wednesday, 18 January 2012

Custom Filtered Lookup in MS CRM 2011 - Runtime Dynamically



Hey All,

Greetings..

While working on a project of CRM 2011 i came across a scenario where i needed to build a custom lookup on run time dynamically. After go-ogling for many hours could find a simple method  in CRM 2011 as compared in CRM 4.0.

Here is a function below 

Create a new library resource file and add the following function and save it.

function SetCustomLookup() {
    //get the current account
    var requiredlookupfilter = Xrm.Page.getAttribute("Lookupid for which you need filtering").getValue();
    var requiredlookupfilterid = requiredlookupfilter[0].id;
    var requiredlookupfiltername = requiredlookupfilter[0].name;

   //any guid you can generate one if required online Please click the below link

    
    var viewId = "{131da142-5b91-4c6f-986b-0b70a3a3a35b}";
    var entityName = "Look up Entity name";
    var viewDisplayName = "Active Users for " + requiredlookupfiltername;
    //build fetchxml – better to generate it from Advanced Find
    var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
                   "<entity name='Look up Entity name'>" +
                   "<attribute name='Look up Entity required column field 1' />" +
                   "<attribute name=' Look up Entity required column field 2' />" +
                   "<attribute name=' Look up Entity required column field 3' />" +
                   "<order attribute=' Look up Entity required column field 1' descending='false' />" +
                   "<filter type='and'>" +
                   "<condition attribute=' Look up Entity required column condition 1' operator='eq' value='" + requiredlookupfilterid + "' />" +
                   "<condition attribute='statuscode' operator='eq' value='1' />" +
                   "</filter>" +
                   "</entity>" +
                   "</fetch>";

    //build grid layout
    var layoutXml = "<grid name='resultset' " +
                             "object='1' " +
                             "jump=' Look up Entity id' " +
                             "select='1' " +
                             "icon='1' " +
                             "preview='1'>" +
                         "<row name='result' " +
                              "id=' Look up Entity column field 1'>" +
                           "<cell name=' Look up Entity column field 2' " +
                                 "width='300' />" +
                           "<cell name=' Look up Entity required column field 3 " +
                                 "width='100' />" +
                                 "disableSorting='1' />" +
                         "</row>" +
                       "</grid>";

    //add new view view
    Xrm.Page.getControl("Lookup Control id ").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true);
 }


Once the library is ready..open the entity form and add the function SetCustomLookup on onload event and if any other as per your requirement.

Regards
Sandeep Patil