Microsoft Dynamics 365 Blog

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

We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!