locked
Converting Email into Case -> Big Problems !!! Need Help RRS feed

  • Question

  • Hello dear forums users,

    I got a Problem:
    I want to manage a service - queue using a workflow.

    If a costumer sends a mail to the queue (support@mydomain.de) the mail has to be converted  into a case. No Problem so far.

    The problem occurs when the customer field has to be dynamically filled up with the sender by the system.
    The only option is regarding here ...

     

    How to manage this problem ? I go crasy with this stuff !!!

    Of course, I had a look in a lot of different forums, but still got no result.

     

    Thank you for every answer !

     

    Greets Jan.

    Friday, September 2, 2011 10:39 AM

Answers

  • Hi Israel de Andres,


    finally i got this steps:


    //Create Reference to Customer to verify that it will be completly correct looked up
    EntityReference contactref = new EntityReference("contact", (Guid)entity.Attributes["contactid"]);
    
    
    //Set full Customername to the Attributes
    //entity => from fetchxml with data about customer
    if (entity.Attributes.Contains("fullname"))
    	contactref.Name = entity.Attributes["fullname"].ToString();
    
    //Add Information to Case
    NewIncident.Attributes.Add("customerid", contactref);

    And finally create the case using crm service.

    Bye.


    • Marked as answer by Jan1992 Monday, April 2, 2012 9:14 AM
    Monday, April 2, 2012 9:13 AM

All replies

  • Hi,

    From field in Email is a type PartyList (ActivityParty) field (special lookup field that allows Account, Contact or Lead type record ) and Customer field in Case entity is a type Customer field (special lookup field that only allows contact or account type record) due to the different field types system wold never allow you to set From field to Customer field. In this situation you need to develop a custom workflow activity ( http://technet.microsoft.com/en-us/library/gg309745.aspx) that will take Email entity reference as input paramter, retrieve from field members and then return a contact or account entity reference in output parameters and then you can set this output parameter in case.

    Custom workflow activity assemblies are only supported by Dynamics CRM on-premise (company hosted) and CRM 2011 online does not support.


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, September 2, 2011 12:34 PM
  • Custom workflow activity assemblies are only supported by Dynamics CRM on-premise (company hosted) and CRM 2011 online does not support.

    Okay, I think there's my 2. problem, now. Our company got CRM 2011 Online.


    What can I do now ?

    Thanks, for your reply Jehanzeb !


    Regards Jan :)

    Friday, September 2, 2011 1:35 PM
  • You can not do this just by workflow. You have to write some custom code.

    This will solve your problem.  Here is plugin solution. This example talk about crmonline but the plugin can be modified to work with on premise installation.

    http://blog.solomon2crm.com/2011/02/23/rtgdynamics-crm-2011-online-email-to-case-solved.aspx

    I hope this helps.


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Friday, September 2, 2011 2:31 PM
    Friday, September 2, 2011 2:31 PM
  • Hi,

    In this case i would suggest you to approaches, one code less and then via plugin code:

    Code less Approach 

    1. Create a new N:1 relationship from the case entity to the email (system will create a lookup of email entity into the Case entity, drag the field into case form and name field i.e. Originating Email

    2. Create a dummy customer record i.e. name customer like  Sample Customer or Unassigned Customer Record and in Converting a Case workflow, assign the Sample Customer to the case and set the Originating Email field with the Email

    3. Educate the users to update the customer field with the one in the From field of Originating Email

    Plugin Code Approach

    1. Either write a plugin to completely handle the scenario or handle via workflow and plugin 

    2. If handling via workflow and plugin then follow Step 1 and 2 from Code less Approach

    3. Develop plugin that will register on Incident (case) entity on Create message in Pre-Operation stage that will check if  Originating Email field has value and Customer field has Sample Customer record then retrieve the From field values of an email via Retrieve (by email id) webservice request and update the Customer field

    You may refer to the following sample code for extracting values from the email From field.

    wod_EmailFromPartyField = (EntityCollection)wod_EmailEntity["from"];

    // Checking if plugin entity From field is activityparty entity object

    if (wod_EmailFromPartyField != null && wod_EmailFromPartyField[0].LogicalName  == "activityparty")

    {

        EntityReference wod_PartyReference = 

        (EntityReference)wod_EmailFromPartyField[0]["partyid"];

        // Checking if email is sent by CRM Account

        if (wod_PartyReference.LogicalName == "account")

        {

          // write here a code to update the case customer field value

        }

    }

    To handle the scenario completely via plugin you may refer the following blog post: http://worldofdynamics.blogspot.com/2011/08/dynamics-crm-2011-execute-custom.html


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Friday, September 2, 2011 2:35 PM
  • hey amreek,

    thanks 4 your answer !

     

    I have already tried this solution, but after execution i got a javascript error, wich i can't solve :/

     

    c u jan !

    Monday, September 5, 2011 6:31 AM
  • Oh man dude, I think after 1 week,  i got first progresses !

     

    Thank u for your response !

     

    I will note, if I get success ;)

    Monday, September 5, 2011 6:43 AM
  • Hi,

    The solution mentioned in the Url uses Plugin, you need to download the Solution zip file (https://skydrive.live.com/?cid=d72ec2c64d6010a0&sc=documents&id=D72EC2C64D6010A0%21107) and then import into the CRM (then no need to register the plugin)


    Jehanzeb Javeed

    http://worldofdynamics.blogspot.com
    Linked-In Profile |CodePlex Profile

    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".
    Monday, September 5, 2011 6:59 AM
  • thanks, but with your approach i'll try to implement it now ;)
    Monday, September 5, 2011 11:22 AM
  • Oh man dude, I got it now !!! :)

     

    But I got 2 more Problems:

    While creating the case through workflow i use the dummy contact "test contact" After running my Plugin, the dummy contact still appears, but refrers to the correct cutomer (who sent the mail).

    The 2. Prob is that the Mail content (Email Descrition) is displayed in html format ?!

     

    Regards, Jan

    Tuesday, September 6, 2011 9:17 AM
  • Problem 1

    It should not be happening but some how name attribute of lookup is not getting updated.

    Try updating the entityreference code in plugin. You can try something like that
    add this line to fetch xml
    <attribute name='name' /> //next to <attribute name='contactid' />

    replace the following line

    entity_to_update.Attributes.Add(CRM_CONTACT_ID_FIELD, new EntityReference("contact", (Guid)entity.Attributes["contactid"]));

    with

    EntityReference er = new EntityReference();
    er.Id = Guid)entity.Attributes["contactid"];
    er.Name =Guid)entity.Attributes["name"];
    er.LogicalName ="contact";
    entity_to_update.Attributes.Add(CRM_CONTACT_ID_FIELD, er);

    Problem 2
    I have a look at it but it has nothing to do with plugin for sure.

    I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    Tuesday, September 6, 2011 1:24 PM
  • Problem 1

    It should not be happening but some how name attribute of lookup is not getting updated.

    Try updating the entityreference code in plugin. You can try something like that
    add this line to fetch xml
    <attribute name='name' /> //next to <attribute name='contactid' />

    replace the following line

    entity_to_update.Attributes.Add(CRM_CONTACT_ID_FIELD, new EntityReference("contact", (Guid)entity.Attributes["contactid"]));

    with

    EntityReference er = new EntityReference();
    er.Id = Guid)entity.Attributes["contactid"];
    er.Name =Guid)entity.Attributes["name"];
    er.LogicalName ="contact";
    entity_to_update.Attributes.Add(CRM_CONTACT_ID_FIELD, er);

    Problem 2
    I have a look at it but it has nothing to do with plugin for sure.

    I hope this helps.

     


    Amreek singh Senior CRM Consultant CDC Praxa Sydney,Australia http://mscrmshop.blogspot.com/
    • Proposed as answer by Amreek Singh Tuesday, September 6, 2011 1:25 PM
    Tuesday, September 6, 2011 1:24 PM
  • Hey Amreek !

     

    Thank you 4 your approach !

    I tried it now, but the dummy contact does still appears ...

    I got this code, to add the attribute to my case:

    EntityReference er = new EntityReference();
    er.Id = (Guid)entity.Attributes["contactid"];
    er.Name = entity.Attributes["fullname"] as String;
    er.LogicalName ="contact";
    entity_to_update.Attributes.Add("customerid", er);
    

    Before this action, i removed the "customerid" field from attributes.

     

    What can I do now, please help me !

     

    Regards, Jan =)

    Wednesday, September 7, 2011 8:14 AM
  • Hey Amreek !

     

    Thank you 4 your approach !

    I tried it now, but the dummy contact does still appears ...

    I got this code, to add the attribute to my case:

    EntityReference er = new EntityReference();
    er.Id = (Guid)entity.Attributes["contactid"];
    er.Name = entity.Attributes["fullname"] as String;
    er.LogicalName ="contact";
    entity_to_update.Attributes.Add("customerid", er);
    

    Before this action, i removed the "customerid" field from attributes.

     

    What can I do now, please help me !

     

    Regards, Jan =)

    Hi Jan, did you find a solution for this issue? sounds like a bug. We have been struggling for a while and finally i decided jump over this with a workflow setting the Customer field with the current Customer field, sounds weird but works.

    cheers

    Wednesday, March 21, 2012 12:07 PM
  • Hi Israel de Andres,


    finally i got this steps:


    //Create Reference to Customer to verify that it will be completly correct looked up
    EntityReference contactref = new EntityReference("contact", (Guid)entity.Attributes["contactid"]);
    
    
    //Set full Customername to the Attributes
    //entity => from fetchxml with data about customer
    if (entity.Attributes.Contains("fullname"))
    	contactref.Name = entity.Attributes["fullname"].ToString();
    
    //Add Information to Case
    NewIncident.Attributes.Add("customerid", contactref);

    And finally create the case using crm service.

    Bye.


    • Marked as answer by Jan1992 Monday, April 2, 2012 9:14 AM
    Monday, April 2, 2012 9:13 AM