none
Relationship between two entities

    Question

  • Hi,

    I want to create a Relationship between two entities and use association mapping between the columns for Updation and Retrieval.

    For example:

    Account and customerAddress entities are related with a Relationship. When a new account is created by default two records will be inserted into CustomerAddress entity by using the relationship.

    In Account we have attribute like Address_1.Street1 which is Related to CustomerAddress.line1, So when users enters the data in the field Address_1.Street1 , actual data is stored in CustomerAddress entity.

    Based on that I have two questions:

    1)How is the attribute Address_1.Street1 is visible in Account entity even though the field is actually present in CustomerAddress entity, i mean how is this mapped internally?

    2)Similarly, I want to create a relation between Account and Distributor (custom entity) and I need the columns of Distributor to be present in account entity similar to how Address_1.Street1 is present in account entity. How can I achieve this ?


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Wednesday, August 25, 2010 5:49 AM

Answers

All replies

  • 1)How is the attribute Address_1.Street1 is visible in Account entity even though the field is actually present in CustomerAddress entity, i mean how is this mapped internally?

    you have to create another attribute in Account for this and use this in mapping.

    2)Similarly, I want to create a relation between Account and Distributor (custom entity) and I need the columns of Distributor to be present in account entity similar to how Address_1.Street1 is present in account entity. How can I achieve this ?

    Also for the same you can create relationship between account and Distributor, there is not way to present column of related entity, only you have to create those attribute in account or you can map existing column with the column of your distributor entity.


    Mahain : http://mahenderpal.wordpress.com
    Wednesday, August 25, 2010 6:22 AM
    Moderator
  • Hi Mahendar,

    Can you please tell me, How the mapping is done between the Account entity and Customeraddress entity for Address_1.Street1 attribute in the Account entity?

     


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This will help other members to find the solution easily.
    Wednesday, August 25, 2010 8:44 AM
  • This is a system defined mapping, I am not sure how it's done internally, but you should be able to achieve your requirement accordingly using workflow/plugin
    Mahain : http://mahenderpal.wordpress.com
    Wednesday, August 25, 2010 8:54 AM
    Moderator
  • hi Mahender,

    can you share the plugin code(if you have any) for a mapping the two entities similar to attribute Address_1.Street1 OR related links where i can find the code

    Wednesday, August 25, 2010 9:43 AM
  • you can write code on update/create on some entity to update/create related entity records
    Mahain : http://mahenderpal.wordpress.com
    Wednesday, August 25, 2010 9:58 AM
    Moderator
  • I am moving this to the development forum to gain more visibility.  You can also have a look through the SDK to see if you can find more information about what you need.

    Regards, Donna

    Thursday, August 26, 2010 2:17 PM
    Owner
  • Hi Ksvimal,

    In mapping the data flow from parent to child when a new child record is created. With workflows you can easily acheive two way update. CRM support doing an update from child entity to parent entity. You can download dll from http://crm40distributewf.codeplex.com/ and get the ability to update from parent to child record. This should fulfill your requirements.

    Regards

    Faisal

    Thursday, August 26, 2010 2:35 PM
  • Hi Ksvimal,

    You'ld define 1:N relation ship between Account & Distributor entity & define the mappings between Address_1.Street1 of Account & related custom attribute of Distributor on mappings tab. When you will create new Distributor record in context of Account (i.e. using Add exitsting or New from Account' Distributor view) then Address_1.Street1 will get initialized with value from Account's Address_1.Street1 attribute.

    But if you create a Distributor record outside the context of Account record(i.e manually performing lookup to add account) then fields will not be initialized automatically from parent. Here you have to handle it on yuor own. You can develope plug-in or workflow for that purpose on Create & Update events of Distributor entity.

    But if you want the Address_1.Street1 to be changed immediately on change of Account field on Distributor , then you've to write Cilent -side Javascript eventhandler for "Onchange" event of Account attribute on Distributor .

    One more thing , if you want the change in attribute Address_1.Street1 on Account to be reflected in all Distributor records associated with it then you can do this through custom workflow activity or plug-in.

    Thank you.

    JayshriP.

    Friday, August 27, 2010 5:14 AM
  • hi,

    i dont want to create a new record for distributor enttiy after creation of 1:n relationship, by default when a new account is created, a record in distributor entity should also be inserted. in the account form i want to place a distributor fields such that when user enter those values. by default the values will be inserted in the distributor table.

    i want to similar to customerAddress entity record updation, when account is created by default 2 records are inserted in the customeraddress entitty and the fields Address1_street1,Address_stree2 will update the Customeraddress entity. in this similar fashion i want to update distributor entity

    can you provid the solution for the above case.

    Monday, August 30, 2010 9:01 AM
  • you have to create these fields again in account entity, then you can implement this logic in plugin or workflow when these fields are filled by user create corresponding record in distributor entity.


    Mahain : http://mahenderpal.wordpress.com
    Monday, August 30, 2010 9:12 AM
    Moderator