locked
crm2011: how to create many to many records in silverlight? RRS feed

  • Question

  • Hi

    Scenario :

    Customer and Product are custom entities.

    There is a Many To Many relationship between Customer and Product.

    Now in silverlight upon some action I want to associate multiple products with the customer (products are displayed in customer entity).

    I tried the following code but its now working....

    context.AttachTo("pr_customerSet", customerrecord);

    context.AttachTo("pr_productSet", productrecord);

    context.AddLink(customerrecord, "pr_customer_pr_product", dhh_productrecord);

    I this the right way or there is another way of doing this?

    Thursday, May 10, 2012 7:09 AM

Answers

All replies

  • AssociateRequest ?

    Thursday, May 10, 2012 8:18 AM
  • Check this blog post for the sample code about Associate an Entity Record with Another in Microsoft Dynamics CRM 2011 Using C# in Silverlight.
    Thursday, May 10, 2012 8:19 AM
  • Thanks Linn

    I already tried this code but this code does not work , I don't know whether this is a deprecated code.

    Thursday, May 10, 2012 8:27 AM
  • I don't think that one is deprecated.

    You may comment on his post with the error that you're facing.

    I'll try it and let you know too.

    Thursday, May 10, 2012 8:34 AM
  • CrmSdk.OrganizationRequest request = new CrmSdk.OrganizationRequest() { RequestName = "Associate" };

    EntityReference targetEntityReference = new EntityReference();
                                targetEntityReference.LogicalName = "pr_customer";
                                targetEntityReference.Id = recordid;


    request["Target"] = targetEntityReference ;  //// This statement is not working (compiler error)

    Thursday, May 10, 2012 8:41 AM
  • Hello,

    This code would not work without Extensions that you should add to your project. Recheck following article - it will help you with your issue and will remove your compiler error - http://msdn.microsoft.com/en-us/library/gg594452.aspx


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Follow Andriy on Twitter

    Thursday, May 10, 2012 10:12 AM
    Moderator
  • Thanks Andrii

    I have aleady followed the same steps.

    I am also referecing the OrganizationData.csdl as service reference , Is that causing the problem?

    Thursday, May 10, 2012 11:08 AM
  • Thanks Linn , Andrii

    It worked , I recreated the solutions and this time it worked.

    Thank you very much

    Thursday, May 10, 2012 12:09 PM