Showing posts with label MSCRM. Show all posts
Showing posts with label MSCRM. Show all posts

Thursday, October 21, 2010

Using XRM SDK in MSCRM 4.0 Plugins

I am back and very excited about MSCRM 5.0. But today I am putting a sample to use xrm sdk in plugins. By default there no method in XrmDataContext class to pass plugin context.
But there are ways around it. You can pass the connection as string or as crmconection as follow

Microsoft.Xrm.Client.CrmConnection.Parse(
"Authentication Type=Integrated; Server=http://localhost:" +
new Uri(Microsoft.Win32.Registry.LocalMachine.OpenSubKey ("SOFTWARE\\Microsoft\\MSCRM", false).GetValue("ServerUrl").ToString()).Port +
"/" + context.OrganizationName)

This worked for me.

Here is sample code I have used to create a note for an account



public void Execute(IPluginExecutionContext context)
{
try
{
Guid ID = new Guid();


switch (context.MessageName)
{
case "Create":
ID = new Guid(context.OutputParameters.Properties["id"].ToString());
break;
case "Update":
ID = (Guid)((Microsoft.Crm.Sdk.Key)((Microsoft.Crm.Sdk.DynamicEntity)context.InputParameters.Properties["Target"]).Properties[context.PrimaryEntityName + "id"]).Value;
break;
case "SetState":
ID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["EntityMoniker"]).Id;
break;
case "SetStateDynamicEntity":
ID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["EntityMoniker"]).Id;
break;
case "Delete":
ID = (Guid)((Microsoft.Crm.Sdk.Moniker)context.InputParameters.Properties["Target"]).Id;
break;

}


var crm = new XRM.MyDataContext(context);

var note = new XRM.annotation()
{
subject = "My XRM Note",
notetext = "This is my XRM Sample.",
Account_Annotation_id = ID,
objecttypecode = "account",

};
crm.AddToannotations(note);
crm.SaveChanges();

Wednesday, April 8, 2009

MSCRM Asynchronous Service is not working

Hi guys, I have come across this problem few times now. This is preety common with upgraded deployments. If your workflows are not firing or your data imports are not working and asynchronous services are running properly. Then what's the problem?

The problem is there is an entry missing in your mscrm database.

To fix this problem update column AsyncSdkRootDomain to servername:port
(crmserver:5555) in DeploymentProperties table.

Happy Easter.......

Monday, June 9, 2008

Spell Checker

A lot of clients ask us to add a spell checker to CRM email templates . There is free spell checker available called IESpell, which can be downloaded from http://www.iespell.com/. Plz check the term and condition on the web site. Install the software. Add a custom button on the CRM form and call the IESpell. It looks like

The spell check can be added to any page of CRM.

If you need further assissatnce contact me at asingh75@gmail.com.