latest Post

Access "Last Access Date" of each User Directly in CRM.

Since CRM 2011  when Microsoft first offered the ability to Audit User Access, I have been waiting for them to offer a simple OOB solution to be able to view the last Access Date of a user from a field on the user form. Rolling on 7 years to Dynamics365 this is still not possible.

Those users who are experienced in CRM Auditing will know Audit Logs cannot be exported or queried using advanced find meaning if any data manipulation is needed on the logs then a 3rd party tool is required or some custom code to export the logs and be able to manipulate the data.

For years now to be able to check user adoption and monitor user licences I have been exporting the logs to excel using either the XRM toolbox solution or writing a fetchxml query and manipulating the data to get a list of users who havent logged in over a period of time. I have always wanted to get round to automating this process so I could simply view the users last access date directly on user profile and thats exactly what I have done. 

To accomplish this task I first wrote the below FetchXML query. The below query returns all Audit logs of type "User Access via Web" in the below code this is referenced by value 64. For a full list of codes for each type click here.  It then also filters out any logs which either were not created today or is not  created before a passed in date parameter. This is because I want to either run it nightly for only todays logs but also have the option to run it as a one off to search all audit logs for a time period.  Finally it filters out disabled users as I am not interested in updating those users. 

Then using SSIS and the KingswaysoftCRM source connector I downloaded the the records returned from the query and stored them in a local SQL database. I then manipulated the data with a simple SQL query to return the Last Login Date for each user.





I  then created a new custom field in CRM on the OOB user entity "Last Access Date" and added it the form. 


I then used the above SQL Query as my source component in my SSIS package to loop through each user and update the corresponding CRM user record with the last access date.  

Now putting that all together I created the below SSIS package.

SSIS Control Flows 

The below shows the SSIS control flow steps in my SSIS package which starts by truncating the local sql table with the user audit logs.



Data Flow 1

First data flow which queries CRM using the above Fetch query and outputs the data to a local SQL table.


Data Flow 2

Second data flow task which uses the SQL query above as the source and loops through each record and updates the corresponding CRM users last access date field.


Finally once the package has ran we have the last access date field populated. 


This SSIS package is then scheduled to run each night to automatically update the last access date for each user and that's how simple it is to get the last access date for each user updated automatically. 

Now I finally got round to this I bet in the next release its added as standard!! haha :-)
Recommended Posts × +

4 comments:

  1. If you're running a small business, the installation of the computer at the office can put pressure on your pocket, but at TrueTech we understand this problem and deliver you computer rentals services all over in Gurgaon at an economic or affordable price. For more information, you can also visit our website.
    For More Info :- http://www.truetechservices.in/#

    ReplyDelete
  2. Laptop On Rent
    Rent Foxxy offers you electronic gadgets for rent like as laptop, mobile phones, TV and many other of electronic. So get any gadget for rent on your requirement.Rentfoxxy is a rental basis company which is provide laptop on rent in Gurgaon, delhi, noida, and Bangalore.
    For More Info :- https://rentfoxxy.com/

    ReplyDelete
  3. Refurbished laptop in Gurgaon
    Buy refurbished laptops online at best price in Gurgaon. We have wide range of buy refurbished laptops in gurgaon.
    Efoxxy is an ecommerce based company providing genuine certified refurbished products with exceptional service and warranty. We are an authorized seller of affordable and professionally refurbished laptops. We give products at the lowest price across all sites available in the market. All products get analyzed and any defects and are renewed to original working conditions either by our experts or product manufacturer.
    For More Info :- http://efoxxy.com/

    ReplyDelete
  4. I promise to share this testimony all over the world once my boyfriend returns back to me, and today with all due respect I want to thank DR.ONIHA for bringing joy and happiness to my relationship and my family. I want to inform you all that there is a spell caster that is real and genuine. I never believed in any of these things until I lost my boyfriend, I required help until I found a great spell caster, And he cast a love spell for me, and he assured me that I will get my boyfriend back in two days after the spell has been cast. Three days later, my phone rang, and so shockingly, it was my boyfriend who has not called me for the past 6 years now, and made an apology for the heart break, and told me that he is ready to be my backbone till the rest of his life with me. DR.ONIHA released him to know how much I loved and wanted him. And opened his eyes to picture how much we have shared together. As I`m writing this testimony right now I`m the happiest girl on earth and me and my boyfriend are living a happy life and our love is now stronger than how it was even before our break up. So that`s why I promised to share my testimony all over the universe. All thanks goes to DR.ONIHA for the excessive work that he has done for me. Below is the email address in any situation you are undergoing, it may be a heart break, and I assure you that as he has done mine for me, he will definitely help you too.
    EMAIL: ONIHASPELLTEMPLE@GMAIL.COM
    CALL/WHATSAPP : +16692213962.
    Website: http://onihaspells.com. 

    ReplyDelete