web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Tying 2 Entities together

(0) ShareShare
ReportReport
Posted on by

Hello everyone!

Is it possible to tie 2 entities together so that I can pull data from one record and place it in another? More specifically.. Is it possible to take a "Product" and associate the "Product ID" with a new custom field in a custom entity called "Deal"? I kind of have the feeling this can be achieved in a N to N relationship? Any help would be greatly appreciated. Thank you!

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at
    RE: Tying 2 Entities together

    Hello Aileen,

    Thank you very much! You have been great help!! I am definitely going to do it the way you suggest.

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at
    RE: Tying 2 Entities together

    Hello Captain,

    Quote you can generate as much as you want it has all copy function functionality from Opportunity to Quote including all the products, so the "Deal" can be a redundant job for the users if you still make Opp then make "Deal" then make "Quote :)

    If you use Quote, you are no need anymore to write a plug-in, don't worry, more codeless.

    Just FYI, you cannot close Opportunity before you close all Quote (either Lost or Won).

    In your case if one Opportunity might have more than Quote won, then you still use CRM process, but if you want to validate only 1 "Deal" won for each Opportunity you need to cancel the rest Quote to the Lost and make sure the user only Won the one.

    Hope this helps.

    Thanks.

  • Community Member Profile Picture
    on at
    RE: Tying 2 Entities together

    Hello Aileen,

    Wow, you are awesome!! Thank you so much for your time and your help, I really appreciate it! Please do not worry about writing too much, it is interesting to me and yes I do read it all. I really do not have anybody to talk CRM with, so I do need as many suggestions as you can give!

    It sounds like you understand what I am doing now, you described it perfectly! And yes, I think you might be right about getting rid of the Deal entity and just doing it all on the quote form. That does sound much easier. Also, I have not yet created any plug-ins for CRM, so I would have to do some research on that before I try it that way. So I think I will just try doing it in quote for now. Thanks again!!

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at
    RE: Tying 2 Entities together

    Hello Captain,

    Ok, excellent explanation.

    SO the "Deal" is having relationship to the Opportunity and have field =  standard price (the total of the whole Opportunity, correct?)

    When you are able to create the Deal with the name of Opportunity and the standard price, you want to make sure that in the newly created Deal, the users can see the Product from the Opportunity that they have created and attached before using the OOTB method.

    Actually the user can see the list of the Product through the original opportunity, but you don't want the user to be burdened by clicking "Deal", clicking Opportunity.

    Okay, understand if that I captured correctly.

    I can recommend three options:

    1. You don't create another "Deal" Product line item so you can go by adding the N:1 Relationship from "Opportunity Product" entity to the "Deal"

    Then when you create the "Deal" right, you can get the "Deal" is created, then you must create a plugin that triggered on the "Deal" created, in the "Deal" I believe you have all of the Opportunity info, including Opp Unique Id.

    So your plugin logic is:

    Just retrieve the Opportunity Id from the "Deal", then get the Opportunity ID then you use the Query Expression to retrieve all the related Opportunity Product records, okay? After that you just link the Opportunity Product to the "Deal" just now you created.

    Now, in your "Deal" form, just add a subgrid to put the Opportunity Product subgrid.

    So the result, you can imagine that the "Deal", when the users came in, they will see the all Products from the Opportunity. It is very easy and convenience for them to see all the Products related without clicking the Opportunity.

    But, you might try to block them to not update this because it will affect the whole Opportunity.

    If your purpose is to let them edit the Price in the Deal only, not the Opportunity, you might go for option number #2

    2. You create another Entity "Deal Product" which will have 3 fields at least: Product, Opportunity (all lookup fields) and the price from the Opportunity Product.

    Then you create a plugin to copy the Opportunity Product to this entity.

    Do the same plugin concept mentioned in number #1

    It might not better than option #1, just to let you know the alternative here.

    The pro side here is you don't need any validation to block them to not edit the Product line because it wont affect the real Opportunity.

    The Question here is:

    "What if the user create an Opportunity, with 5 vehicles, A, B, C, D, and E"

    Then you create a new deal.

    Can they change the Products? To A, B, X, Y, Z or only selling A and B? or add to A, B, C, D, E, F?

    You read my response for first 1, you want to keep track the original Opportunity price or not? If yes, then you go for option number 2, that is duplicate the Opportunity product to store the changes of negotiation through the "Deal".

    The advantages for number 1 are you save space, no need to build custom entity anymore, but you cannot see the different between "Deal" and Opportunity Product.

    If you go for number 2, it is more flexible for users to adjust the Product + the Price, but you might need to come back to update it back to the Opportunity product right? Because you want to have Quote and Invoice and so on.

    So the quote basically will have copy from the Opportunity Products, so if you already fixed everything in the Opportunity you might not need to be headache when generate a quote because it copies them all.

    3. My another suggestion is the combination.

    But you might need a Quick View Form.

    Configure a new quick view form for the Opportunity.

    Then from that Quick View form, please put a subgrid, put the Opp Product subgrid, ok.

    Then after that you back to the Deal Form and put the Quick view form you created before.

    You still need a plugin to copy all the Opportunity product to the Deal Product (number #2 step).

    Imagine when the user go to the Deal, they can see the Opportunity Info, including all the Products without clicking the Opportunity.

    Actually the best way is N:N (manual intersection) from Opportunity Product and the "Deal" but the Opportunity Product cant have the 1:N Relationship so it wont work.

    If I may recommend you, for the price adjusting, and negotiation as well.

    Usually my recommendation is using Quote.

    So from Opportunity instead of creating "Deal" as the Custom Entity, why you not utilize the Quote as "Deal"?

    What kind of information "Deal" has except the Product Line and the Price?

    Because it is very easy if you use Quote from the Opportunity, it will inherit everything.

    The deal is kind of longer procedure if you can make it done just using Opportunity and Quote.

    You can generate as many Quote as you want from an Opportunity before making it Won or Lost.

    If you have the "Deal" between Opp and Quote, you need to update the price back to the "Opp" then you create the "Quote" so double job for the users?

    Just a thought.

    Overall, (I Know it is long message as reply, so you might not reading it all), I recommend you to replace the "Deal" with Quote if your "Deal" is just an entity to store the negotiation price changes.

    If you want to have the "Deal" with all of the Product that already created in the Opp process then you want to adjust the price you can go for option #2, but remember you need to have more code in the Plugin.

    Hope this helps

    Thanks.

  • Community Member Profile Picture
    on at
    RE: Tying 2 Entities together

    Hello Aileen,

    The "Deal" form is where the salesman can negotiate with the customer, and calculate the exact final price of the product. Let me see if I can explain in greater detail of my thought process and what I have done so far:

    The salesman selects a product that already has a "standard" price.

    The salesman then attaches that product to the Opportunity all using OOTB methods.

    Then a workflow is triggered to create a "Deal". I already have the "Total Amount" price from the Opportunity Price Line being transferred to the newly created Deal. As well as the name of the Opportunity, and a lookup for products. So when the Salesman (user) selects the newly created deal, he already sees the standard price (before negotiation) as well as the name of the opportunity he is working with. I do not really want a lookup for products, I want the product to already be there when the Deal is created.. OR at least the product ID OR some field that I can tie EVERYTHING together with.. the opportunity, the product, the deal.. because I eventually do want this final negotiated price to go to the quote, and then on to an invoice, and then on to a service queue and so on..

    Does this make more sense? Thanks again!!!

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: Tying 2 Entities together

    Hello Captain,

    Of course you can do it!

    So may I confirm first before I answer again.

    The 'deal' is like a negotiation history? But you don't want to use Quote to store it?

    Then..

    Is That your 'Deal' is having lookup field to Product and Opportunity?

    And you are still using Opportunity and put the Opportunity Product in the Opportunity?

    Any relationship between Opportunity product and your 'deal'?

    Thank you!

  • Community Member Profile Picture
    on at
    RE: Tying 2 Entities together

    Hello Aileen,

    I was able to add a lookup field prior to asking, but I am trying to eliminate as many clicks by a user as possible. I dont want a user clicking around from form to form looking for the same information.

    The "Deal" I am referring to is a custom entity I created where a user is given a final price of a product, but then is allowed to negotiate with the customer and the user can then do different calculations on the "Deal" form to achieve the real final price of a product.

    The product I am referring to is a vehicle, so I assume you can see how much the price of the product can change, based on other vehicle trade-ins and financing.

    I want to be able to "track" a product (vehicle) through CMS entirely. After the product is stored I want to be able to store it in a queue and contact the customer after a certain period of time an so on.. but where I am now is still far from that. I am still trying to figure it all out really... This is my first major CMS project, and yes I know I am a little over my head.. but I still think I can do it..  

    My thinking was to take the "Product ID" (or even another custom field I create on the product form) and transfer that field to every form associated with the opportunity and product. I created a workflow the automatically create the "Deal". Realistically I would like as much product detail to follow everything all the way to the "Deal" and beyond..

    Am I making sense? Do you think this type of design is feasible? I really appreciate your help!

  • Aileen Gusni Profile Picture
    44,524 on at
    RE: Tying 2 Entities together

    Hi Captain CRM,

    If you want to have a field connected from Product Id with another entity Deal, you need a lookup field.

    N:N is also possible, but Native N:N (relationship that create from Product -> Relationships -> N:N) wont create a field on it, instead will create new hidden intersection table, not a field.

    While if you create Manual N:N you can add more fields on it.

    May I know what Deal you are referring to?

    Your objective is to link Product with many Deal and many product with a Deal?

    Thanks.

  • Suggested answer
    mscrmba Profile Picture
    on at
    RE: Tying 2 Entities together

    I'd suggest you take a look at how opportunities and/or quotes are set up in CRM OOTB.  It sounds like you're creating a custom entity (Deal) for something that already exists OOTB.  

    You will see that Opportunities have an intersect entity called opportunity product (that allows you to store e.g. the unit price and quantity of product)

    In essence:

    1 Opportunity > to many Opportunity Products > to 1 Product.

    So you could create an intersect entity

    Then create a N:1 Relationship with each of the Product and Deal entities.

    Optional step:  You can then insert sub-grids of this information if you want to see them on the product and deal forms.

    Save and publish all your changes.

    Alternative solution:

    If you'll never need to be able to store e.g. the unit price and quantity of specific products associated with each deal then you could set up an N:N relationship instead.

    Go to Settings > Solution > Components > Entities > Deal

    Open up the form view

    Click on the left hand navigation related entities

    Click on New N:N button

    Select the Entity Name for the Other Entity (e.g. Product)

    If you want to be able to see associated records - you can add a sub-grid onto one or other or both of the form views.  

    Save and publish all your changes.

  • Bruno Lucas Profile Picture
    5,421 on at
    RE: Tying 2 Entities together

    yes. if you have a  custom entity called "Deal", you can add a new field of type lookup that will point to Product.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#2
ED-30091530-0 Profile Picture

ED-30091530-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans