Microsoft Dynamics CRM 2011

Microsoft Dynamics CRM 2011

Tuesday, September 3, 2013

How-to add a N:1 (MANY-TO-ONE) relationship in Dynamics CRM

by Carmel Schvartzman

   1.  In this walkthrough we will create Step-By-Step a N:1 (MANY-TO-ONE) relationship between CRM entities: account and campaign. A campaign can spread on multiple accounts, so we'll set a MANY-TO-ONE relationship between ONE campaign to MANY accounts. In CRM 2011/2013 we do that by adding a N:1 relationship at the account's relationships. That means, when we are done, you will notice a "Campaign" field on the Account's form holding a link to the Campaign this account - and many more accounts - are related.
     2. The few next steps will be done on the CRM UI. Go to "Customize the System" and then to Entities. Find the "Account" entity and select "N:1 Relationships":





Open the "Type" combo and select "Custom": this will filter only the relationships that you established:



You'll see there are no relationships yet. After we execute the next steps, you'll check again this tabble and see the new dependency created.
3. Now we create the account's field that will hold the relationship. Still at the "Account" properties, select the "FIELDS" option and click "NEW":


The following dialog will open:


At the NAME textbox add a "new_campaign" field: this will be the field that holds the related Campaign. 

4. For the TYPE of the field select "Lookup":


5. And for the TARGET RECORD TYPE select the related entity, Campaign:


6. Slash the RELATIONSHIP NAME to make it more friendly:


7. Finally, Save and Close the dialog:



8. We are done. Now, if we go back to the "N:1 Relationships" table, we could see that automatically the CRM engine created for us a N:1 relationship between Account(RELATED ENTITY)  to Campaign(PRIMARY ENTITY), which means that from Campaign(parent) to Account (child) there exists now a 1:N One To Many relationship:



Finally , click "Publish All Customizations":


And that's all.
Happy programming!!!!


כרמל שוורצמן

No comments:

Post a Comment