The E-mail to Case process one of the final steps is to make the e-mail not to display on the Queue, that is called detaching from the queue, this blog post is a follow up on one of the initial blog post on this new CrmBuzz URL, the original post was How to Detach an Email from a Queue? Summary..., so finally after some replies and follow up e-mails and questions I got the time to put in the details for one of most requested line:
returnStatus = emailDetach.EmailDetachFromQueue(EmailID, SourceQueueId);
The code snipped:
1: public bool EmailDetachFromQueue(Guid EmailID, Guid SourceQueueID)
2: {
3: bool returnvalue = false;
4: try
5: {
6:
7: DetachFromQueueEmailRequest detachEmail = new DetachFromQueueEmailRequest();
8: detachEmail.EmailId = EmailID;
9: detachEmail.QueueId = SourceQueueID;
10:
11: DetachFromQueueEmailResponse detachedEmailResponse = (DetachFromQueueEmailResponse)service.Execute(detachEmail);
12:
13: returnvalue = true;
14:
15: }
16: catch (System.Exception e)
17: {
18: returnvalue = false;
19:
20: }
21:
22: return returnvalue;
23: }
The E-mail detach process will not give you too much information on the validity on the completion and you probably will need to validate making another call, so these are some of the steps for the e-mail to case (incident)
- Validate E-mail content is not Spam or Duplicate
- Create new Contact with E-mail address information
- Create new Account with E-mail address information
- Relate new Account with new Contact
- Validate that E-mail is not relation to any Case (Incident)
- Create new Case (Incident) with E-mail information
- Detach E-mail from the Queue (Private or Public Queue)
- Assign the new Case (Incident) to the User Private Queue (Incident Owner)
So these are the most common steps for converting an E-mail to a Case, I will be working on a similar process for Spam e-mails on MS Dynamics CRM 4.0 but in this version I will be using the Workflow's capabilities, stay tuned for more details on the new workflow E-mail to Case process.
Check the Articles soon you would find information related to SDK connectivity with CRM 4.0 On Premises and Online versions
Abe Saldaña
CrmBuzz.net
This all is undocumented and unsupported. Therefore you should only try these kinds of modifications if you feel comfortable working with this.
Everything here, though, is my personal opinion and is not read nor approved before being posted. No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.

Posted by Abe Saldana |
Thu, 12 Jun 2008 21:50:18 GMT |
Comments ()
Working on the previous blog post I have to get some information on the Lead's status and state, just to validate that the lead was not already qualified or disqualified and then make the conversion to an Account and to a Contact, so I started to create a SDK generic library type of assembly with the most common things I will be using on a daily basis.
Working on a lead the first thing I will be doing is check if the lead remains Open [Status = 1 and State = 0 ] or that is not Qualified [ Status = 3 and State = 1 ] and if the lead is not Disqualified [Status = 4 (Most Common - Lost) and State = 2], here is some code to get the independent values:
Getting the Lead Status Information:
1: public int getStatus(Guid leadID)
2: {
3: int returnValue;
4:
5: try
6: {
7: lead leadInformation = (lead)service.Retrieve(EntityName.lead.ToString(), leadID, new AllColumns());
8:
9: returnValue = leadInformation.statuscode.Value;
10:
11: }
12: catch( Exception)
13: {
14: returnValue = -1;
15: }
16:
17: return returnValue;
18:
19: }
Getting the Lead State Information:
1: public int getState(Guid leadID)
2: {
3: int returnValue;
4:
5: try
6: {
7: lead leadInformation = (lead)service.Retrieve(EntityName.lead.ToString(), leadID, new AllColumns());
8:
9: returnValue = ((int)leadInformation.statecode.Value);
10:
11: }
12: catch (Exception)
13: {
14: returnValue = -1;
15: }
16: return returnValue;
17: }
Note: the Lead State value is returned un-boxing the object value from the enum CRMSDK.LeadState
Well that is good to pull the value from the lead, but as part of the conversion process I needed to change the status from Open to Qualified, so I needed to have the Update Method and handle the validation for the update, the lead status is handle not from the Service.Update but the state is managed by the SetStateLeadRequest object, here is the code for updating the Status
1: public bool UpdateStatus(Guid leadID, int Stateparam, int Statusparam)
2: {
3: bool returnValue = false;
4:
5: try
6: {
7: SetStateLeadRequest leadUpdateRequest = new SetStateLeadRequest();
8:
9: leadUpdateRequest.EntityId = leadID ;
10:
11: leadUpdateRequest.LeadStatus = Statusparam;
12:
13: LeadState valueState = (LeadState)Enum.ToObject(typeof(LeadState),Stateparam);
14: leadUpdateRequest.LeadState = valueState;
15:
16: SetStateLeadResponse stateSet = (SetStateLeadResponse)service.Execute(leadUpdateRequest);
17:
18: int resultStateCode = getState(leadID);
19:
20: if (resultStateCode == Stateparam)
21: {
22: returnValue = true;
23: }
24:
25: }
26: catch(Exception)
27: {
28: returnValue = false;
29: }
30:
31: return returnValue;
32:
33: }
After all this the conversion code was so simple to put together and easy to read, I hope the following code snipped's will work for you, keep in mind that I just put the core of the code, CRM connection objects and class definition are not included you need to create those and then test the code
Abe Saldaña
http://crmbuzz.net
Everything here, though, is my personal opinion and is not read nor approved before being posted.
No warranties or other guarantees will be offered as to the quality of the opinions or anything else offered here.

Posted by Abe Saldana |
Wed, 11 Jun 2008 23:07:06 GMT |
Comments ()
Working on a special project, I have to recreate the Lead conversion and make some other customizations on the Accounts and Contact relationship, the first code I was looking was the conversion using the Relationship mapping, I found some code regarding the related request/response, but looking under the SDK documentation finally find some code hints that I can use for the conversion.
The following is the code for converting a source entity to a target entity, taking in consideration the relationship mapping using the TargetRelatedRequest and response classes (CRM 3.0 SDK)
/// <summary>
/// Convert to Contact, Convert/Create first the Contact then the Account
/// </summary>
public Guid ConvertLead2Contact(Guid leadIdvalue)
{
InitializeFromRequest requestObject = new InitializeFromRequest();
requestObject.EntityMoniker = new Moniker();
requestObject.EntityMoniker.Id = leadIdvalue;
requestObject.EntityMoniker.Name = EntityName.lead.ToString();
requestObject.TargetEntityName = EntityName.contact.ToString();
requestObject.TargetFieldType = TargetFieldType.All;
InitializeFromResponse responseObject = (InitializeFromResponse)service.Execute(requestObject);
contact returnContact = (contact) responseObject.Entity;
// You need to create the new created Contact Entity
Guid returnContactId = service.Create(returnContact.Entity);
return returnContactId;
}
/// <summary>
/// Convert Lead to Account, Convert the Account after the Contact.
/// </summary>
public Guid ConvertLead2Account(Guid leadIdvalue, Guid primaryContactId)
{
InitializeFromRequest requestObject = new InitializeFromRequest();
requestObject.EntityMoniker = new Moniker();
requestObject.EntityMoniker.Id = leadIdvalue;
requestObject.EntityMoniker.Name = EntityName.lead.ToString();
requestObject.TargetEntityName = EntityName.account.ToString();
requestObject.TargetFieldType = TargetFieldType.All;
InitializeFromResponse responseObject =
(InitializeFromResponse)service.Execute(requestObject);
account returnAccount = (account) responseObject.Entity;
if(primaryContactId != null)
{
If(primaryContactId != Guid.Empty)
{
// relationship with the Contact
returnAccount.primarycontactid =
CrmTypes.CreateLookup(EntityName.contact.ToString(),primaryContactId);
}
}
// You need to create the new converted Account
Guid returnAccountId = service.Create(returnAccount.Entity);
return returnAccountId;
}
Notes:
I assume you already created or added the CRM Web Service reference and created the CrmService object (service) in your project. Also I'm using the CrmTypes class to help create CRM type objects
The Lead status is not change using the TargetRelatedRequest I will post another article where is going to guide you and have code snippets to check the value, Qualify, Disqualify and Reactivate the Lead.
Hope this article will help.
Abraham Saldaña
http://crmbuzz.net

Posted by Abe Saldana |
Wed, 28 May 2008 09:36:57 GMT |
Comments ()
Partners enrolled in a Partner Service Plan for Microsoft Dynamics™ now have unlimited organizational access to online training for Microsoft Dynamics and related business products.
If you are not enrolled in a Partner Service Plan, learn more at Partner Source > Services & Service Plans > Partner Service Plans to choose the plan that is right for your organization!
Training Document Links:
Installation and Deployment in Microsoft Dynamics CRM 4.0 Course number 8911*
Customization and Configuration in Microsoft Dynamics CRM 4.0 Course Number 8912*
Applications in Microsoft Dynamics CRM 4.0 Course Number 8913*
Microsoft Dynamics CRM Team Blog
http://blogs.msdn.com/crm/archive/2008/01/28/crm-4-0-training-resources.aspx

Posted by Abe Saldana |
Thu, 21 Feb 2008 18:46:07 GMT |
Comments (1)
How would you like a free copy of Microsoft Visual Studio 2008? How about the entire Microsoft Expression Studio? Not enough...... how about Microsoft Windows Server 2003 and more?
Today, Microsoft announced an unprecedented software program that we believe will help change the lives of millions of students around the world. The program, Microsoft DreamSpark, is focused on providing millions of college and high school students with no-cost access to the latest Microsoft developer (i.e., versions of Visual Studio, XNA Game Studio), designer tools (Expression Studio) and Microsoft platform resources (i.e., versions of Windows Server and SQL Server).
Currently, the program is accessible by college students in 11 countries including: Belgium, Canada, China, Finland, France, Germany, Spain, Sweden, Switzerland, the United Kingdom and the United States. In the coming months, the Microsoft DreamSpark team will expand the program’s reach to include high school students and to increase the number of participating countries.
Please visit Channel 8, https://downloads.channel8.msdn.com/ to learn more about Microsoft DreamSpark.

Posted by Abe Saldana |
Thu, 21 Feb 2008 18:36:22 GMT |
Comments ()