0
votes

I have 2 custom entities ex: Building and Business in CRM on-premise. Building has multiple Units/Suite #'s and each Unit/Suite# is occupied by a Business. If a Building Unit/Suite is under renovation, then the Business has to be temporarily closed.

How can i automatically update Business Open/Close when Building Unit/Suite status changes? The update does not need to happen instantly. I need search around 20000 records to update the correct Business entity. Also there are fields in Business like start and end date which is retrieved from Building and Closure duration is updated with end(minus)start date.

Is Plugins the only way and how can i achieve it using plugins! How difficult would it be, impact on server and i am mid level C# dev. Please provide any links in the right direction. The env is 2011 on-prem

Thank you very much !!!

1

1 Answers

1
votes

A straightforward solution can be built with a plugin. A synchronous plugin can update the status changes to the Business entity immediately and (in the PreOperation or PostOperation stage of the Update message) even within the same database transaction.

Generally speaking, with plugins you can build the most efficient and seamlessly integrated business logic possible.

However, often you can actually achieve pretty much the same using a workflow. Some advantages of building workflows:

  1. Does not require a skilled software developer to build;
  2. Workflows can be modified ('configured') quickly.
  3. Execution of workflows can be postponed (e.g. until a condition is met or a date has passed).

Some downsides of workflows are:

  1. In CRM 2011 your code always runs asynchronously, outside of the original database transaction;
  2. Some time may pass until the action takes place; the user does not get immediate feedback;
  3. Querying and selecting related data is limited to n:1 relationships (from the n-side to the 1-side, not vice versa);
  4. Execution of workflows requires more resources than plugins;
  5. Extensive use of workflows can easily lead to spaghetti systems that are really hard to maintain and perform bad.

In your scenario it looks like the requirements for selecting the appropriate Business record are too complex to handle in a workflow. In a workflow you basically can only navigate from one record to the other by following lookup references on the record at hand. This means you can only get from one record to the other when there is a n:1 relationship and when you navigate from the n-side to the 1-side.

In plugins you do not have this limitation; there you can write a QueryExpression or Linq-query to get the records you need. So, in your case a plugin seems to be the right choice to me.