Sunday, February 3, 2008

Generate postImageEntityXml (MSCRM 3.0) equivalent in MS CRM 4.0 Plugins


If you worked on MS CRM 3.0 callouts, in the method signature of Pre/Post you get a string called as postImageEntityXml.

postImageEntityXml is nothing but an XML string that describes the entity after the assign operation was performed. This is a serialized version of DynamicEntity.

You can create the DynamicEntity Object using the Context Object.
Eg:
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];

Below is the code for MS CRM 4.0 which is equivalent of the postImageEntityXml string value in 3.0.

To implement this code functionality in plugin, use the Sample Plugin Code:
------------------------------------------------------------------------
public class postImageEntityXmlExample : IPlugin
{

// This fucntion gets called from the EXECUTE method of plugin (marked in bold)

private string SerializeDynamicEntity(Microsoft.Crm.Sdk.DynamicEntity entity)
{
XmlSerializer serializer = new XmlSerializer(typeof(Microsoft.Crm.Sdk.DynamicEntity));
StringWriter writer = new StringWriter(CultureInfo.InvariantCulture);
serializer.Serialize(writer, entity);
return writer.ToString();
}


private void WriteToFile(string message)
{
try
{
StreamWriter sw = new StreamWriter(@"c:\ErrorLog.txt", true);
sw.WriteLine();
sw.WriteLine(System.DateTime.Now.ToString());
sw.WriteLine();
sw.WriteLine(message);
//Cleanup
sw.Close();
}
catch (Exception ex)
{
//TODO Develop Code, if an Error comes while write to File
}
}

public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = null;

if (context.MessageName=="Create" context.MessageName == "Update")
{
if (context.InputParameters.Properties.Contains("Target") &&
context.InputParameters.Properties["Target"] is DynamicEntity)
{
entity = (DynamicEntity)context.InputParameters.Properties["Target"];

//call the below code to Serialize Dynamic Entity into postImageEntityXml
WriteToFile("\XML string \n" + SerializeDynamicEntity(entity));
}
}
}
}

---------------------------------------------------------------------------

Isn't it simple?
Happy MS CRM Development.

Comments are welcome..... :)

Tuesday, January 22, 2008

Microsoft Dynamics CRM 4.0: 90-Day Trial Versions

Brief Description:
Microsoft Dynamics CRM 4.0 90-day trial versions for released languages.


http://www.microsoft.com/downloads/details.aspx?familyid=A9C110FD-AAC8-4D2A-B401-7801B1866E82&displaylang=en

Microsoft Dynamics CRM 4.0 Server Readme

Brief Description:
This document provides important late-breaking information for Microsoft Dynamics CRM 4.0 Server.


http://www.microsoft.com/downloads/details.aspx?familyid=1DB2D16D-7885-4561-A461-20B948913B3F&displaylang=en

Microsoft Dynamics CRM 4.0 Internet Facing Deployment Scenarios

Brief Description:
This document covers how to set up the Microsoft Dynamics CRM 4.0 Web site to make it available from the Internet.

http://www.microsoft.com/downloads/details.aspx?familyid=3861E56D-B5ED-4F7F-B2FD-5A53BC71DAFC&displaylang=en

Microsoft Dynamics CRM 4.0 Implementation Guide

Brief Description:
This guide contains comprehensive information about how to plan, install, and maintain Microsoft Dynamics CRM 4.0.


http://www.microsoft.com/downloads/details.aspx?familyid=1CEB5E01-DE9F-48C0-8CE2-51633EBF4714&displaylang=en