2

I'm thinking through a solution to the question of: are our many users actually using Salesforce, and if so what are they doing in it?

I figure pretty much all end user activity boils down to record creation/updates. I'm picturing a report that says, 'Today User X created 1 Account, Updated 3 Accounts, created 2 contacts...' etc.

My question is, how feasible would that be to implement via Apex?

Imagine the obvious solution: to set up a trigger on every single object end users can edit, and have those update a new 'User Activity Log' object. Is there a solution that wouldn't require setting up a new trigger each time a new Object is created? I'd also be concerned about governors/storage limits, what with creating a new log record for every record created/changed.

Is there another way to catch changes to records other than object-specific triggers? Can I intercept DML statements in general?

2 Answers 2

3

There are several things you can do to find out what you need. (Independently or in conjunction)

  1. Salesforce provides an "Adoption Dashboard", you can install it and use their preferred metrics.
  2. You can run reports on your preferred objects and group them by "Created Date" and "Created By"
  3. You can enable "Field History Tracking" in some key objects (you can track up to 20 fields). Then you can Report on that.

Using one (or all three) of these approaches will help you get an idea of how much SFDC is being used.

2
  • Thanks Sebastian. My goal is to try and get an idea of who is using what - all in one place. Of course we could run reports on each object separately, but that doesn't give the kind of condensed oversight that I'm looking for
    – smohyee
    Jun 6, 2016 at 16:55
  • Then you're stuck with only two options. Either VF/Apex or a dashboard with all the reports together. Jun 6, 2016 at 16:57
2

Using Salesforce's native Reporting or other objects would seem to me to be a better use of available resources than to create a new solution to what you're asking. If field history tracking is enabled on all of your objects, the LastModifiedBy and LastModifedDate could be used to track the number of edits or records "touched" by a User during a specific period of time across all of your objects. Ditto for CreatedBy and CreatedDate.

That having been said, obviously, Salesforce's reporting is split out by object, so generating a report for ALL objects using their History could problematic. However, it wouldn't be difficult to obtain using SOQL to get it. You could presumably create a class that could compile it for all of the objects of interest to you. I'd expect it to be some kind of aggregrateResult query or a wrapper class depending on how you chose to approach it, but I don't see any reason you couldn't get it using that approach.

8
  • I like your idea of using SOQL, or rather SOSL, to query the lastmodified date/by fields across all objects. I could use queries like that to populate a new custom 'user usage log' object, rather than using triggers on every object.
    – smohyee
    Jun 6, 2016 at 16:57
  • I was actually referring to doing it with SOQL in a Class where you'd do an aggregrate result query. I'm not entirely certain that SOSL would provide the results you'd be looking for. With SOQL you could use subqueries or join the results of several queries together to create a class of your own in the results that get returned.
    – crmprogdev
    Jun 6, 2016 at 17:05
  • My concern with SOQL is having to query each object separately - mainly I'm concerned with having to keep track and create new queries every time I create a new custom object. But then, I supposed I could set up my apex to dynamically build a list of current objects and query each of them in turn... not sure how to do that, but I bet it can be done!
    – smohyee
    Jun 6, 2016 at 17:23
  • You'd create subqueries so it would still be a single query up to the query limit and could do it dynamically as you suggest. The subject is covered fairly well in either the Apex Code Developer Guide or in posts here if you search.
    – crmprogdev
    Jun 6, 2016 at 17:26
  • 1
    If there's a relationship that exists between objects, you can query them in a single query. You can use the Schema Child Relationship Class to help identify some of those.
    – crmprogdev
    Jun 14, 2016 at 19:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .