When creating solutions that utilize the CRM 4.0 SDK I often find myself needing to quickly create and test a piece of code that allows me perform a specific function.
I’ve created a simple application skeleton to aid in my development efforts. It has the code required to connect to CRM and display the results of whatever code I’m writing. It is a simple Visual Studio 2008 Windows Forms solution that contains a list box, a large text box and a couple of buttons. I use the list box and text box to display the results of whatever test I’m working on.
I find this skeleton especially useful when developing plugins because I need to write and test the code outside of the plugin environment. Once I’m sure that the code is functioning the way I wish, I simply copy and paste it into the plugin.
You can find this skeleton in the Free Utilities section of this blog.







Good job man. I also like your ROI Calculator. Keep up the great work.
Thanks Mark.
[...] CRM 4.0 Development Skeleton [...]
[...] CRM 4.0 Development Skeleton [...]
Could someone show me how to close a CRM Incident by passing in the IncidentID Or even the ticket number? Thanks
The following code connects to CRM Just fine. but i dont know what to do next.
string crmServerUrl = "http://myserver/mygroup/";
string connectionStringIntegrated = string.Format("Url={0};", crmServerUrl);
string connectionString = connectionStringIntegrated;
var connection = CrmConnection.Parse(connectionString);
using (var service = new OrganizationService(connection))
{
using (var crm = new CrmOrganizationServiceContext(service))
{
//Resolve Incidents and Cancel Incidents in here by passing in the incidentID
}
}
I found this will Close Incidents, However I still can not programatically close the associated activities.
Entity caseResolution = new Entity("incidentresolution");
caseResolution.Attributes.Add("incidentid", new EntityReference("incident", new Guid("MYGUIDHERE")));
caseResolution.Attributes.Add("subject", "testing programatic closing.");
//service.Create(caseResolution);
Microsoft.Crm.Sdk.Messages.CloseIncidentRequest req = new Microsoft.Crm.Sdk.Messages.CloseIncidentRequest();
req.IncidentResolution = caseResolution;
req.RequestName = "CloseIncident";
OptionSetValue o = new OptionSetValue();
o.Value = 5;
req.Status = o;
Microsoft.Crm.Sdk.Messages.CloseIncidentResponse resp = (Microsoft.Crm.Sdk.Messages.CloseIncidentResponse)service.Execute(req);