Quantcast
Viewing latest article 14
Browse Latest Browse All 20

How-to series: Change activities’ status when closing opportunities

Okay, this post is a response to a good question made by someone on the Microsoft Dynamics CRM forum (for Partners).

The initial question was:

“Hi All,

When an opportunity is cancelled, the activities (tasks, appointments, etc.) are not being flagged as cancelled and staying considered as “open” items. We need to  find a solution that when an opportunity is closed (or cancelled) that all associated activities tied to that opportunity be deleted. Can i automate the above process? I tried using workflow, but i am not able to trigger an Activity record.

Regards,

VP”

A response from Dylan Haskins pointed to a really cool workflow plugin called ‘Distributed Workflow’ and available on Codeplex here.

In this post, I will show how to use this plugin in the particular situation stated above.

  1. Download the plugin (which is basically a DLL) and copy it on your CRM server
  2. Launch the ‘Plugin Registration tool’, given with the Microsoft Dynamics CRM SDK (available here)
  3. In the registration tool, you simply need to register the plugin and that’s it!Image may be NSFW.
    Clik here to view.
    Plugin registration tool
  4. When this step is done, a new workflow step will be available in your workflow rules:Image may be NSFW.
    Clik here to view.
    New workflow step
  5. So, let’s create a new workflow rule that will target an opportunity, but first you have to know the type of relationship between an activity and an opportunity: start by going to the “1:N relationships” in the opportunity entity and write down the name of the relations between the various activities and the opportunity Image may be NSFW.
    Clik here to view.
    1:N Relationships
  6. Now create a new workflow rule against the phone call entity and simply add a workflow step that changes the phone call’s status to ‘Cancelled’; this workflow rule must be available to run ‘on demand’. Publish itImage may be NSFW.
    Clik here to view.
    Phone call workflow
  7. Now that you have your ‘related’ workflow rule, let’s create another one but this time you must target the opportunity entityImage may be NSFW.
    Clik here to view.
    Workflow rule opportunity

  8. This workflow should run whenever you change the opportunities’ status reason to ‘Cancelled’, so we should first verify the status reason and then launch the ‘on demand’ workflow rule, based on the 1:N relationship. Don’t forget to publish your workflow once it is done.Image may be NSFW.
    Clik here to view.
    Workflow steps opportunity

  9. In our case, the ‘Distribute Workflow (1:N)’ properties should be set to this:Image may be NSFW.
    Clik here to view.
    Distribute workflow settings

Before the workflow rules were deployed, this is what it looked like when an opportunity was closed or cancelled:

Image may be NSFW.
Clik here to view.
Open activities

You can see that all the activities are still open!

Now that we have deployed our new workflow rules, this is what it looks like (which is much better Image may be NSFW.
Clik here to view.
Smile
):

Workflow running

Image may be NSFW.
Clik here to view.
Workflow running

Phone call activity now cancelled as well!

Image may be NSFW.
Clik here to view.
Cancelled activities

NOTE: If you want to cancel other activity types, you have to repeat the steps 5 & 6 to create a workflow rule for each activity type; then, you would modify the opportunity workflow rule to take into account the other ‘on demand’ workflows

HTH!


Viewing latest article 14
Browse Latest Browse All 20

Trending Articles