A requirement came up where the sales managers wanted to be able to see who had viewed an opportunity in Dynamics CRM. At first, I looked at using the auditing functionality, but I could only see examples of this working with creating, updating & deleting records – please comment if I’ve missed something. So with this in mind, I looked at other alternatives.
For this example I created a new entity to store the records. The entity is called ‘new_opportunityviewhistory’ and I will be using the field ‘new_name’ to store information.
It is possible to create the REST query yourself, but why re-invent the wheel when an awesome tool such as CRM Rest Builder has been created. Please read the official documentation for installation information and how to use the product, I will only be covering how to create the query that will be used in this example.
|CRM REST Builder|
The above setup will give us the query required to create a new record, this can then be placed into a function that can be called on page load.
This script can then be put into a web resource to make it available to the form.
|Dynamics CRM Web Resource|
Once the web resource has been created the form can then be updated to use the function on page load. This will then create the record and show that the user has viewed a record.
Now every time the opportunity form is opened a new record will be created in the opportunity view history entity, allowing us to see who has been viewing opportunities. Further improvements would include either a link to the original record or some way of identifying the record.
|Advanced Find showing 3 records created|