locked
Create Connection to custom Entity using C# RRS feed

  • Question

  • I ve a custom entity created inside CRM and i need to add connection between that custom entity and contact entity. I found sample in SDK but there they have implemented CRM Entity classes by deriving it from Microsoft.Xrm.Sdk.Entity.

    GetAttributeValue method of Entity class is public but SetAttributeValue is protected. due to which i cannot add and set attributes within custom entity class without implementing it using Entity class. Is there any other way to add Connection to Custom Entity without implementing it using Entity class?


    F a i r L i g h t

    Friday, January 30, 2015 1:25 AM

Answers

  • I found this sample in SDK. It is deriving classes from CRM entity class i ve created custom entity and i need to connect from Contact to that custom entity. That custom entity type is not there in Helper class.

    F a i r L i g h t

    In case you will recheck already mentioned article (Early Bound Classes generation) - you will get an information how to generate wrappers for your custom entity.

    In case you don't want to use Early Bound you can use Late Bound.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    • Marked as answer by FairLight Monday, February 2, 2015 9:40 AM
    Friday, January 30, 2015 10:00 AM
    Moderator
  • Please make sure the Connections is Enabled for the custom entity and publish the customisations. It will be available after that once you regenerate the early bound classes.

    Hope this helps.
     
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

     
    • Marked as answer by FairLight Monday, February 2, 2015 9:41 AM
    Friday, January 30, 2015 10:09 AM

All replies

  • Hello,

    You can use Early Bound classes and combine it with creation of entities for Connection.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog


    Friday, January 30, 2015 5:20 AM
    Moderator
  • I found this sample in SDK. It is deriving classes from CRM entity class i ve created custom entity and i need to connect from Contact to that custom entity. That custom entity type is not there in Helper class.

    F a i r L i g h t

    Friday, January 30, 2015 8:26 AM
  • I found this sample in SDK. It is deriving classes from CRM entity class i ve created custom entity and i need to connect from Contact to that custom entity. That custom entity type is not there in Helper class.

    F a i r L i g h t

    In case you will recheck already mentioned article (Early Bound Classes generation) - you will get an information how to generate wrappers for your custom entity.

    In case you don't want to use Early Bound you can use Late Bound.


    Dynamics CRM MVP/ Technical Evangelist at SlickData LLC
    My blog

    • Marked as answer by FairLight Monday, February 2, 2015 9:40 AM
    Friday, January 30, 2015 10:00 AM
    Moderator
  • Please make sure the Connections is Enabled for the custom entity and publish the customisations. It will be available after that once you regenerate the early bound classes.

    Hope this helps.
     
    -----------------------------------------------------------------------
    Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/


    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

     
    • Marked as answer by FairLight Monday, February 2, 2015 9:41 AM
    Friday, January 30, 2015 10:09 AM
  • Hello

    As I read your question, I think you don't fully understand Connections between entities. A Connection is an entity on its own. You need to create an entity object of type Connection with a record1id = entity1 , record2id = entity2, record2roleid & record1roled = connection role (Defines what the relation is between the two entities).

    Check Andrii Butenko's answer for implementation.

    Correct me if I am wrong.

    Kind Regards


    • Edited by Jochen- Friday, January 30, 2015 11:21 AM
    Friday, January 30, 2015 11:20 AM
  • Thanks Andrii Butenko

    F a i r L i g h t

    Monday, February 2, 2015 9:41 AM