1

So here is the scenario, I have a 1:N relationship between Opportunity entity and a custom entity called Split Percentage. Usually the owner of an opportunity is the 100% owner of the Revenue from the opportunity. In reality, you may have more than one sales person or owner of the opportunity.

To cater this I created a custom entity with a look up to Opportunity. There is a sub-grid that shows the associated view on the Opportunity form. There are 3 parts to it. For now I can do things with business rules and workflow:

  1. When a new Opportunity is created a new record is created in Split Percentage entity with the owner's name assigned 100 percent split and value of estimated revenue from an opportunity.
  2. If anyone wants to add a new sales person to this opportunity, they add it through the grid in Opportunity form. You add percentage of split this new sales person should have e.g. 10% and their estimated revenue will be calculated e.g. 10% of $1000 is $100 which is the value assigned to that record.

Now the third part is where I am stuck at, deducting the value assigned to the new sales person from the total revenue of the owner. In the example above the value of owner should change from $1000 to $900.

I am not sure how to update the Estimated Revenue of the owner every time a new sales person is added to the Opportunity.

hkhan
  • 843
  • 2
  • 19
  • 45

1 Answers1

2

You can achieve this in post-create & post-update plugin on split percentage entity.

Whenever a new record is created in split percentage entity, plugin will trigger & update the owner’s split percentage record value based on the opportunity owner attribute. You have to retrieve the related child entity by proper filtering using fetchxml or QueryExpression and update back using service.Update

You have to recalculate in post update as well, if there is any change in % for non-owner records. Again you have to retrieve the related child entity by proper filtering using fetchxml or QueryExpression and update back using service.Update

  • point me to the right direction to learn about post and pre plugin updates sir and is there no way to do it OOB? – hkhan Nov 02 '18 at 00:41
  • @hkhan OOB will not help in this scenario. start here: https://www.tutorialspoint.com/microsoft_crm/microsoft_crm_plugins.htm – Arun Vinoth-Precog Tech - MVP Nov 02 '18 at 00:48
  • I am working on developing a plug-in. At this point logically I cannot understand how I will get the owner record that is created in Split Percentage entity and update it. There are number of records in Split Percentage that are associated with Opportunity. How will I get the owner's record and make sure only that is updated when a new salesperson is added. – hkhan Nov 02 '18 at 22:56
  • @hkhan on create of split percentage, target entity will have related opportunity, so retrieve the owner column of oppty in service.Retrieve and then get the split percentage of owner by service.RetrieveMultiple using owner & oppty filter. Then update that record after calculation – Arun Vinoth-Precog Tech - MVP Nov 02 '18 at 23:01
  • 1
    @hkhan pls ask a separate question with relevant code You tried & any specific issue. SO terms are specific, it’s q&a site and not a forum. Too broad questions are off topic. Close this question by upvoting/accepting the answer if it helped you. In the new question you can refer this question for context – Arun Vinoth-Precog Tech - MVP Nov 02 '18 at 23:11