Monday, December 15, 2014

Incident.ResponsibleContactId is obsolete, replaced by PrimaryContactId

Found another interesting new wrinkle in CRM 2013/2015.  Apparently there has been a schema change on the Incident / Case entity, or at least a schema replacement.

I was rebuilding a Plugin that was originally developed with CRM 2011.  In the Plugin, there was an early bound reference to the system entity for Incident, where I was looking at the ResponsibleContactId.

Symptom:
When building the plugin Assembly, you get this error:


Warning 4 'xxxx.Incident.ResponsibleContactId' is obsolete  .....

Output Windows will show something like this:

.... warning CS0612: 'xxxx.Incident.ResponsibleContactId' is obsolete

If you browse the .cs file generated by CrmSvcUtil, you will see this in the line with the System.ObsoleteAttribute() added.

/// <summary> /// Choose an additional customer contact who can also help resolve the case. /// </summary> [Microsoft.Xrm.Sdk.AttributeLogicalNameAttribute("responsiblecontactid")] [System.ObsoleteAttribute()] public Microsoft.Xrm.Sdk.EntityReference ResponsibleContactId { .... }

So I had never seen System.ObsoleteAttribute() before, so naturally I Googled... uh, I mean, Bing'ed... the term to see what was up.

DotNetPerls had a pretty good explanation.

Still couldn't figure why Microsoft would obsolete this attribute, until I ended up on this page:


The key here is the Note at the beginning about the ResponsibleContactId being replaced by PrimaryContactId

The incident entity ResponsibleContactId lookup attribute should be considered deprecated and the PrimaryContactId lookup attribute introduced with the Microsoft Dynamics CRM 2013 Service Pack 1 (SP1) release should be considered the primary system lookup attribute to associate incidents with a contact record.
There are no plans to remove the ResponsibleContactId lookup attribute, but if you plan to create new customizations you should use PrimaryContactId rather thanResponsibleContactId. If you have existing customizations that currently use ResponsibleContactId, you should consider migrating them to use PrimaryContactId instead.

So, ResponsibleContactId will be around for a while, but is being replaced.

A lot of my PluginCode for the 2 CRM instances I manage uses this field, so I'm going to have to rework how those work, or just ignore the message for a while.  

Tuesday, December 2, 2014

Install CRM Developer Tookit in Visual Studio 2013 - Repost

I ran into this problem today trying to open a Plugin project on a PC that I hadn't installed the CRM Developer Toolkit on to yet.  Not sure why the SDK doesn't support VS 2013, which is now almost 2 years old?

I ran across this blog post with a fix, so I am copying it here.

(Edit: This was the original site, but it seems to be offline now? http://www.hashtagcrm.com/?p=79)

(Edit: New Site: http://torsteinutne.com/2014/03/24/getting-the-crm-developer-toolkit-to-work-with-visual-studio-2013/)

(Update: April, 2016:  I have tried this trick with Visual Studio 2015, but can't get it to work.  My recommendation for VS2015 going forward is to use the Dynamics CRM Developer Extensions developed by Jason Lattimer.)


If you’re anything like me, then you generally prefer to be using the latest and greatest technology, unless there is a tremendously compelling reason not to. You also dislike the inconvenience of having to use two different tools when one should be capable of everything you need.

For most people Visual Studio 2013 is not a huge change from 2012. There are a few minor visual differences, but it looks pretty much the same. There’s several convenience features, like the cloud integration that automatically loads your settings on any computer you log in to. Several new technologies were introduced in VS2013 such as MVC5 and WebApi 2.0, which I’ve recently started using and am not looking back. It’s got enough new changes that I strongly prefer it over 2012 and I would love to use it exclusively, except for one painfully obvious thing… The CRM Developer Toolkit.

A more patient person might just wait until a new version is released as part of the SDK. But then I thought about the CRM Report Authoring Extensions (*cough* *cough* *hint* *hint* Microsoft), that still hasn’t moved past VS2010. So I’m not going to hold my breath for this update. But VS2012 and 2013 are so similar, I’d doubt there’s any major compatibility issues for this little plugin. So let’s see what we can do:

Step 1 :

Extract the contents of CrmDeveloperToolsVS12_Installer.msi

  1. Open a Command Prompt as Administrator
  2. Navigate to: sdk\Tools\DeveloperToolkit\
  3. Run: msiexec /a CrmDeveloperToolsVS12_Installer.msi /qb TARGETDIR=<EXTRACTFOLDER>


Step 2 :

Modify the VSIX package

  1. Navigate to the folder which you extracted the files
  2. Open the Visual Studio folder
  3. Open the archive file Microsoft.CrmDeveloperTools.vsix (I used 7-Zip for this)
  4. Edit extension.vsixmanifest
  5. Replace: InstalledByMsi=”true” with: InstalledByMsi=”false”
  6. Replace all instances of: Version=”[11.0,12.0)” with: Version=”[11.0,12.0]“ (note the closing bracket changed)
  7. Update the file in the archive


Step 3 :

Install the package
Double click to install the VSIX package Microsoft.CrmDeveloperTools.vsix
Looks promising so far. Click Install.
Sweet! But does it actually work?

Step 4 :

Verify

  1. Start up VS2013 and create a new CRM Solution Project
  2. You should get the Connect to CRM window, and it should connect as normal
  3. Test out whatever you may use on a regular basis
  4. Profit.


So there you go! CRM Developer Toolkit in Visual Studio 2013. The best part is that it “just works”. It didn’t require any changes for compatibility, other than explicitly allowing it to be installed in VS2013.

So far everything I’ve tried is working perfectly, not a single hiccup. With this, there’s no more need to keep both versions of VS installed. Let me know in the comments below if this works for you too, or if you run into any features of the dev kit that’s not working yet in 2013.

I should probably put a legal disclaimer on this one. Of course this is not supported by anybody, and any harm that may come to you or your computer or anyone/anything else in the process of attempting these steps is in no way the responsibility of myself or of hashtagcrm.com.

UPDATE Feb 26, 2014: If you are running Visual Studio 2013 and 2012 on the same machine, you’re probably getting a: “Could not load file or assembly ‘Microsoft.Windows.Design.Host” error. To resolve this issue you must copy the contents of the CRM MSBUILD folder you extracted from the msi package to: C:\Program Files (x86)\MSBuild\Microsoft\CRM
Also, you must edit C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\devenv.exe.config, add the following lines:

<dependentAssembly>
<assemblyIdentity name=”Microsoft.Windows.Design.Host” publicKeyToken=”b03f5f7f11d50a3a” culture=”neutral” />
<bindingRedirect oldVersion=”4.0.0.0-4.1.0.0″ newVersion=”4.2.0.0″ />
</dependentAssembly>

Thanks to Eduardo for sharing that fix!

On a last note, if you have both VS2012 and VS2013, and you uninstall VS2012 that seems to cause additional issues that I have not resolved yet.