Search code examples
dynamics-crmmicrosoft-dynamicsdynamics-crm-2016

How to add data to a relation between Dynamics CRM entities?


I created a new custom entity "car types" in my Dynamics CRM 2016. The entity "car types" should be a list of car types that can be found at customers (account entity).

I would like to track the car types per account entity. An account can have N values of the car types entity, so it's an 1:N relation.

I also would like to allow to add the information when the relation was added. I would like to add this date to see if the information is up to date. If someone noted that an account uses e.g. BMW cars in 2013, then it might be worth checking if the account still uses BMW cars, or of they switched to Daimler.

How can I add this information when a record was assigned to the relation? I would also like to be able to update this field manually, e.g. in case someone verifies that the information is still correct.

When working with databases, I would do this using a mapping table like this:

[table accounts]---<[1:n]>---[accounts2car_types]---<[n:1]>---[car_types]

The table accounts2car_types would then have the following fields: * foreign key of account table * foreign key of car_types table * the date field containing the date when the relation was added

How do I do that in Dynamics CRM for custom entities?

NB: Maybe I simply do not know the name / keywords of what I'm trying to do. What is the name of "adding data/information to en entity relation"?


Solution

  • You do the same exact thing that you've described. You really want a N:N relationship between Accounts and car_types, which CRM Will do for you, but, you also want additional data (when the joining table record was created).

    1. Create your new N:N table AccountCarsTypes (or whatever name you'd like).
    2. Add to that entity relationships to Account and car_types (this can be done via adding relationships, or adding entity relationship fields.
    3. Create a LastVerifiedOn field to that entity as well.
    4. Create a workflow that sets the LastVerifiedOn field to the created on date, when the record gets created, and someone could go and update it later if need be.