Monday, June 15, 2009

Create Custom Workflow Activities for Microsoft Dynamics CRM 4.0

Sometimes there are situations when we need to add our own custom logic in workflow. The answer to it is custom workflow activity in Microsoft Dynamics CRM 4.0.

keeping that in mind I have decided to write a post for the same, but as usual before writing any new post I searched for the same on some of my favourite blogs and then I found a great article on the same on stunnware.

A must read post for all newbies. You can find it here.

happy coding :-)

Thursday, June 11, 2009

Invalid Argument error when importing customization

If you export an entity before it has been published, you will get an 'Invalid Argument' error when importing the entity if it has any relationships.

The reason for this is that the relationship attribute will have no display name, which results in the error. The simplest solution would be to go back to the original deployment, publish the entity, then export again. But, if that's not an option, you can fix the problem within the exported xml as follows:

The invalid relationship xml will look like the following:

The problem is that the displaynames element is blank. This can be changed to something like the following

The languagecode attribute will need to be set to the correct value for your deployment. Many other elements will have this value set in the customizations.xml file

Wednesday, June 10, 2009

"Not have enough privilege to complete Create operation for an Sdk entity" exception while registering a CRM 4.0 plug-in

when you try to deploy new plug-in assembly into CRM 4.0 and instead of successfully deploying you get the strange looking Soap Exception "Not have enough privilege to complete Create operation for an Sdk entity".

Unhandled Exception: System.Web.Services.Protocols.SoapException: Server was unable to process request.

Not have enough privilege to complete Create operation for an Sdk entity.

It looked pretty strange because your user might be having System Administrator role and in CRM it might be having all the rights.

Note: The Active Directory account used to deploy and register new assembly into CRM 4.0 database has to be added into Deployment Administrators group in CRM Deployment Manager.

Here are the steps to accomplish this:

1. Open CRM 4.0 Deployment Manager Console (Start -> All Programs -> Microsoft Dynamics CRM -> Deployment Manager).

2. Go to “Deployment Administrators” node and choose “New Deployment Administrator…” option.

3. Insert appropriate user and confirm selection by clicking “OK” button.

After completing this step, your users will be able to register and deploy the assembly successfully. So, remember about this when you try to deploy plug-ins with user that you added to CRM.
Happy Coding :-)

wish to change the code after plugin is deployed ?

After registering your plugin if you wish to change the code, you might get a build error when building the solution again in Visual Studio:
something like :
Unable to copy file "obj\debug\MyPlugin.dll" to "..\..\..\..\Program Files\Microsoft Dynamics CRM Server\Server\bin\assembly\MyPlugin.dll". the process can not access the file "..\..\..\..\Program Files\Microsoft Dynamics CRM Server\Server\bin\assembly\MyPlugin.dll". because it is being used by another process.
This occurs because Microsoft CRM has a lock on the DLL. In order to release the lock, you have to restart the service that has it locked.

For synchronous plug-ins, the CRM Application Pool within IIS can be recycled, or you can run IISReset.

For asynchronous plug-ins and custom workflow assemblies, you have to restart the Microsoft CRM Asynchronous Processing Service in the Services Control panel Applet.

To recycle the CRM Application Pool from the command line: Click Start, Run, type “cscript c:\windows\system32\iisapp.vbs /a CRMAppPool /r” and press enter.

To restart the Microsoft CRM Asynchronous Processing Service from the command line: Click Start, Run, type “net stop mscrmasyncservice” and press enter. Click start, Run, type “net start mscrmasyncservice” and press enter.