Oh dear, what happened to January! It seems I blinked and missed the first month of the year. One of my goals for 2009 was to ensure I had at least 5 to 8 quality blog posts a month. Hmm I’ll have to work harder at that one!
Looking back at my 2008 posts, I seem to have a few that talk about Microsoft CRM’s workflow functionality and how I’ve used it to solve some real world problems. This was never intentional however it does show the power of the workflow functionality and hopefully the simplicity as well. I thought I’d carry on that theme for my first 2009 post and show how I’ve used workflow to create some simple audit tracking. Again this is a zero code example. I’m a firm believer in avoiding writing code unless it is absolutely necessary.
For this example I would like to track each time the estimated close date changes on an opportunity. I want to track who changed it and when. First I need create a new entity to store the audit data in. For this I’ve created a simple entity called Audit History with some additional fields as shown in the image below. Next I created a n:1 relationship between my new entity and the opportunity entity and update the form.
Now I’m ready to create the workflow against the Opportunity entity. I set the workflow to start both when the record is created and on the change of an attribute; namely the Estimated Close Date attribute. I also set the scope to Organisation so it will run for all users.
For my first step I want to check if the opportunity is being created or updated. To do this I create a Check Condition step and check if the opportunity Created On Date equals the Modified On Date. If they are equal I know the opportunity has been created, otherwise its being updated :)
Inside my Check Condition I create a Create Record step and create an Audit History record. Note for this step I set the Change Description to “Opportunity is Created” and copy the various fields from the related opportunity.
For the Default Action step I know if the workflow steps in here the opportunity is being updated so I create a Create Record step and create an Audit History record as above with the only difference being the Change Description which I set to “Estimated Close Date Updated”
The final result would then look like the below image.
I would recommend you set your security for the Audit History entity to be read only so the records cannot be changed. Hopefully this gives you some further ideas for simple audit tracking. For more advanced Auditing where you need to track changes to any field you will have to look at developing a plugin or use an ISV product like the c360 Audit tool.
No comments:
Post a Comment