locked
set customer name in Case entity from plugin RRS feed

  • Question

  • Hi,

    I am trying to set customer in Case records from plugin . It has set but it's name does not update. My scenario is

    I have workflow, in workflow case entity is created. I have write a plugin on precreate of Case entity for set customer lookup.When Case is going to create I have set customer name. Customer has set but it's name does not update.

    I have tried following code

    EntityRefrence objconRefrence=new EntityRefrence("contact",{Guid of contact record})

    objconRefrence.Name="{contact name}"

    objcontact["customerid"]=objconRefrence;

    Can any one help me out , why this type of behavior occur.

    Thanks,

    Vaib


    ---vaib

    Thursday, February 28, 2013 10:22 AM

Answers

  • Hi,

    Finaly I have resolved this issue. I have registered plugin on prevalidation insted of preoperation. It worked successfully.

    Thanks


    ---vaib

    • Marked as answer by vaib01 Thursday, February 28, 2013 2:46 PM
    Thursday, February 28, 2013 2:46 PM

All replies

  • Hi,

    you should be good with below only

    objcontact["customerid"]=new EntityRefrence("contact",{Guid of contact record});

    or may be you can paste your complete code for inquiry ?


    Contact Me
    Follow me on Twitter
    My Facebook Page
    Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    Thursday, February 28, 2013 11:16 AM
    Moderator
  • As the customer of the case could be "account" or "contact", two potential problems may arise: 1- You may get the account as customer, hence if you want to set it, it cause error. You have to check both of contact and account before you set it. 2- The customer field in this case is activity party. Hence, setting it in the way Mahendar said may be causes error. In this case, you have to create an activity party first and then add it to the case.

    If the answer helped you, remember to mark it as answer.

    Thursday, February 28, 2013 1:23 PM
    Moderator
  • Hi,

    Thanks for reply.

    By this code I am able to update normal lookup. But it is creating issue , when I am trying to update required field like customer in case.

    I also tried same code with opportunity , it is creating same issue with potential client name lookup, but working fine with project office.

    In my case customer of case will be always contact type. So I don't need to check account.

    Thanks,


    ---vaib

    • Marked as answer by vaib01 Thursday, February 28, 2013 2:46 PM
    • Unmarked as answer by vaib01 Thursday, February 28, 2013 2:46 PM
    Thursday, February 28, 2013 2:34 PM
  • Hi,

    Finaly I have resolved this issue. I have registered plugin on prevalidation insted of preoperation. It worked successfully.

    Thanks


    ---vaib

    • Marked as answer by vaib01 Thursday, February 28, 2013 2:46 PM
    Thursday, February 28, 2013 2:46 PM
  • Hi Vaib,

    I am new to CRM . I have a similar task like you did. I am new to writing plug ins. Could you please briefly explain all the steps for this particular plug in. Appreciate your help.

    Thanks

    Monday, June 24, 2013 9:19 PM