Thursday, June 9, 2011

Setting Attribute from javascript


Xrm.Page.getControl("neu_yearstart").setDisabled(false);
Xrm.Page.getAttribute("neu_yearstart").setValue(FiscalYearStart);
Xrm.Page.getAttribute("neu_yearstart").setSubmitMode("always");
Xrm.Page.getControl("neu_yearstart").setDisabled(true);


setSubmitMode as always will save the values to the database . if this value is not set then the value is not saved to the database but it will be visible in the front end

for example on change of one field you are setting other field then on the UI you can see the value as changed but when the user hits the save button the value is not saved to the database.


Saturday, June 4, 2011

Hide Custom Button when form is in create mode


 <RibbonDiffXml>
        <CustomActions>
          <CustomAction Id="org.button.Form.CustomAction" Location="Mscrm.Form.account.MainTab.Save.Controls._children" Sequence="1">
            <CommandUIDefinition>
              <Button Id="org.button.Form.WhatifButton" Command="org.button.Command" LabelText="What If Analysis" ToolTipTitle="Launch" ToolTipDescription="tooltip" TemplateAlias="o1" Image16by16="$webresource:neu_button16x16" Image32by32="$webresource:neu_button32x32" />
            </CommandUIDefinition>
          </CustomAction>
        </CustomActions>
        <Templates>
          <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
        </Templates>
        <CommandDefinitions>
          <CommandDefinition Id="org.button.Command">
            <EnableRules>
              <EnableRule Id="org.account.WebClient.EnableRule" />
            </EnableRules>
            <DisplayRules>
              <DisplayRule Id="org.account.WebClient.DisplayRule" />
            </DisplayRules>
            <Actions>
              <Url Address="$webresource:helloworld.html" PassParams="true" WinMode="0" WinParams="width=1100,height=760,toolbar=no,location=no,resizable =yes" />
            </Actions>
          </CommandDefinition>
        </CommandDefinitions>
        <RuleDefinitions>
          <TabDisplayRules />
          <DisplayRules>
            <DisplayRule Id="org.account.WebClient.DisplayRule">
              <FormStateRule State="Create"
                              InvertResult="true" />
            </DisplayRule>
          </DisplayRules>
          <EnableRules >
            <EnableRule Id="org.account.WebClient.EnableRule">
              <CrmClientTypeRule Type="Web" />
            </EnableRule>
          </EnableRules>
        </RuleDefinitions>
        <LocLabels />
      </RibbonDiffXml>

Add a custom button to entity ribbon



<RibbonDiffXml>
  <CustomActions>
    <CustomAction Id="org.button.Form.CustomAction" Location="Mscrm.Form.account.MainTab.Save.Controls._children" Sequence="1">
      <CommandUIDefinition>
        <Button Id="org.button.Form.WhatifButton" Command="org.button.Command" LabelText="What If Analysis" ToolTipTitle="Launch" ToolTipDescription="30 Years What If Analysis" TemplateAlias="o1" Image16by16="$webresource:neu_button16x16" Image32by32="$webresource:neu_button32x32" />
      </CommandUIDefinition>
    </CustomAction>
  </CustomActions>
  <Templates>
    <RibbonTemplates Id="Mscrm.Templates"></RibbonTemplates>
  </Templates>
  <CommandDefinitions>
    <CommandDefinition Id="org.button.Command">
      <EnableRules>
      </EnableRules>
      <DisplayRules>
      </DisplayRules>
      <Actions>
        <Url Address="$webresource:helloworld.html" PassParams="true" WinMode="0" WinParams="width=1100,height=760,toolbar=no,location=no,resizable =yes" />
      </Actions>
    </CommandDefinition>
  </CommandDefinitions>
  <RuleDefinitions>
    <TabDisplayRules />
    <DisplayRules/>
    <EnableRules />
  </RuleDefinitions>
  <LocLabels />
</RibbonDiffXml>

Thursday, June 2, 2011

How to pass Parameters from one Plugin Step to Ano...

How to pass Parameters from one Plugin Step to Ano...: "here is the way to pass some paramters and get in between the steps in MS CRM 2011, while writing plugin. this can be done by using SharedV..."

Wednesday, June 1, 2011

Get CRM 2011 CrmSvcUtil.exe and the Plugin Registration Tool to Work With WIF on Windows XP

Microsoft Dynamics CRM 2011 makes heavy use of the new Windows Identity Framework.   This been heavily integrated into most of the tools out there for development with the CRM 2011 platform.  This includes CrmSvcUtil.exe and the new plugin / plug-in registration tool.  This also presents a headache for anyone who would like to do any development for CRM 2011 with a Windows XP machine as WIF will not install on an XP machine.  You need to have Vista SP1+, Windows 7, or Windows Server.

It seems that there is an "unsupported" workaround for this.

1. If you were to happen to navigate to the following folder (C:\Program Files\Reference Assemblies\Microsoft\Windows Identity Foundation) on a supported machine that has the Windows Identity Framework (WIF) already installed you might find some assemblies in the directory structure and it's sub folders.

There are four assemblies in my installation:
- Microsoft.IdentityModel.dll
- Microsoft.IdentityModel.resources.dll
- Microsoft.IdentityModel.WindowsTokenService.dll
- Microsoft.IdentityModel.WindowsTokenService.resources.dll

2. If you were to happen to (accidentally of course) copy these assemblies and move them to the same folder as the CrmSvcUtil.exe file or the executable for the Plugin Registration Tool, they will function normally without needing to install the whole WIF framework package.

To build the plugin registration tool you just copy the 4 assemblies from that folder structure to the bin\debug folder and build the tool using Visual Studio.   It then functions normally.

Here is an example from the forums where someone has gotten this to work for CrmSvcUtil, and I have personally done this for the Plugin Registration Tool.  You will also notice that I was the naysayer in the thread at the time :)
http://social.microsoft.com/Forums/en/crmdevelopment/thread/8d8bd121-a34c-402d-86fd-b3c47709a0b4

I hope this helps!

Tuesday, May 24, 2011

Encrypt appsettings in web.config


Below are the steps to do this

1)   Encrypt appsettings in web.config using Aspnet_regiis.exe
using Aspnet_regiis.exe you can encrypt whole section only not a particular key.so when you need to encrypt a particular key in appSettings things get complicated. Here is a roundabout way of doing this. Modify your web.config

2)   <configsections>
<section type="System.Configuration.NameValueSectionHandler,System, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" name="secureAppSettings" />

<appsettings>......</appsettings>

<secureappsettings>
<add key="ipwd" value="secure-password"/>
</secureappsettings>
</configsections>

3)   Under secureAppSettings you can add any key value pairs.

Also secureAppSettings is the name i had given. You can give any. Save this web.config file and go to visual studio command prompt

4)   Type

aspnet_regiis -pef secureAppSettings  “ur web.config path”  -prov DataProtectionConfigurationProvider


5)   In code you can access it as usual

NameValueCollection secureAppSettings = (NameValueCollection)ConfigurationManager.GetSection("secureAppSettings")
String str= secureAppSettings["ipwd"];

Saturday, May 21, 2011

SQL Timeouts in CRM 4.0 - import of customizations fail


When importing customizations to CRM 4.0, the import fails with a message "generic SQL error". Digging a bit deeper the error message is really that a timeout has occured. The same error occurs when trying to create a new entity.
I increased the timeout as suggested in the link below
Increasing the timeout:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSCRM\OLEDBTimeout
This value does not exist by default, and if it does not exist then the default value will be 30 seconds. To change it, add the registry value (of type DWORD), and put in the value you want (measured in seconds). Then you have to recycle the CrmAppPool application pool for the change to take effect

By Increasing the time out in the registry will solve the problem. Number of seconds depends on the amount of data in the database.