The Microsoft Dynamics CRM Blog
News and views from the Microsoft Dynamics CRM Team

Tapping into Microsoft CRM updates via workflow

Tapping into Microsoft CRM updates via workflow

  • Comments 6

Scenario:

Nancy is Salesperson. She would like to log all changes that are made to the rating of a lead for future reference (e.g. à from warm to hot or warm to cold).

Approach:

In Workflow Manager, while creating a rule, if a user inserts a “wait for” condition for a specific attribute then it gets evaluated each time system detects an update event. Hence a simple way to track updates on lead rating would be to create a manual workflow that traps the modified date at the beginning of workflow execution and waits until the current modified date is different from the trapped date at the beginning of execution.

In most cases we don’t want to detect every update. What we are interested in are the value updates of a particular field.  Lets say we are want to add a note on the lead when ever the lead rating gets updated. Below steps detail on how to achieve it.

Steps:

  1. Register the .NET assemblies that enable echo functions (described in earlier blog).
  2. Create a workflow rule named “Lead Rating Tracker” on lead as Manual Rule.
  3. Defines a temporary variable in order to trap attribute value at the beginning of workflow definition.
  4. Insert a wait condition that waits until rating value under temporary variable is not equal to current rating value.
  5. When this condition is satisfied, insert an action that adds a note to the record using dynamic fields that refer to initial value and current value for lead rating.
  6. In order to ensure, that workflow goes back to waiting for further changes, call the same rule as a subprocess to itself.
  7. Activate the workflow.
  8. Create another workflow rules as “lead rating change log” on lead create event and call “Lead Rating Tracker” rule in it as subprocess.

Workflow Logic:

  1. The workflow logic for “Lead Rating Tracker” would look like as follows:
    [Manual Rule

Echo Picklist: old lead rating

Wait

Lead.rating on <> old lead rating

End wait

Note: Lead rating changed from {!old lead rating} to {!lead.rating}

If

Lead.status <> open

Then

stop

Else

Exec: Lead Rating Tracker                               ß this is to loop…

End if]

  1. The workflow logic for “lead rating change log” would look like as follows:
    [On lead create

Exec: Lead Rating Tracker]

NOTE à

  • Workflow will not be able to detect all the changes if the lead rating is changes very rapidly i.e. before the workflow gets time to loop back. For regular usage it should be good.
  • It is recommended that you test the workflow rules in a test environment before you put it in production.
- Shashi Ranjan
  • PingBack from http://blogs.msdn.com/crm/archive/2006/08/23/714766.aspx
  • Good idea.

    But what will you do if the workflow is waiting for a change and thead is deleted. The workflow will wait forever...
  • If the entity is deleted, all the workflow rules processing for that entity will get aborted and deleted. But yes if the entity is deactivated they will continue to wait. for that you can create a custom .net assembly that will abort all running workflow instances when the entity is deactivated.

  • If the item is deleted then all the wf instances are aborted and deleted too. But yes if the item is deactivated then the wf instance will wait for ever. To overcome that situation you can write a small custom .net assemlby action to abort all running wf instances when the items is deactivated.

  • Can you please explain Step 4 ?

    i.e Insert a wait condition that waits until rating value under temporary variable is not equal to current rating value.

  • PingBack from http://firepitidea.info/story.php?id=1050

Page 1 of 1 (6 items)
Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post