A: If you mean “when was an Activity last completed for it?”, I got a great solution for you.
But first, make sure NOT to use Salesforce’s built-in “Last Activity” field (API Name: LastActivityDate). It behaves really strangely, like allowing “Last Activity” to occur in the future.1
4) In a Report that has both Activities and the object you’re rolling up to (like Accounts), create a Custom Summary Formula (I named it Days Since Last Activity MARKED Complete) with this formula
You’re done! The Custom Summary Formula field enables reporting when someone last completed an Activity for an Account, Contact, Opportunity, Lead, Case, etc. . .
“Activities with Accounts” Report, with Custom Summary Field “Days Since Last Activity MARKED Complete”
1 Q: How can Last Activity Date occur in the future? A:Salesforce Help explains that Last Activity Date is either
The latest Due Date of the Closed Tasks on a record, or
The latest Date of Events on a record.
Out-of-box, Salesforce allows both
completed Tasks to have Due Dates in the future or
Events to have Dates in the future
. . . so either Tasks or Events can render, say, an Opportunity’s “Last Activity” in the future. wtf.
2 Q: Why are these fields needed? A: Two reasons:
Reports can’t roll dates up to parent records, so we need to convert “Date MARKED Complete” into the numeric “Days Since MARKED Complete”.
Reports’ Custom Summary Formulas treat nulls as zeroes, so we need an arbitrary, large error value–I’m using 999 here–to disqualify null “Days Since MARKED Complete” from MIN calculations.
spfy-where-used leverages the “Simple Salesforce” Python library and Tooling API calls to generate a spreadsheet of all custom fields’ “Where Is this Used?” results.
Update the config.py file in the resources subdirectory to reflect your org’s username, password, and security token.
Sadly, “Where Is this Used?” doesn’t cover Workflow or Data Validation. 😐
For reports that need to bucket by hours—not days, weeks, or months—create a formula like this.
It returns a date+time string in 'YY: MM/DD HHh format (like '22: 03/23 09h), which is the longest string I could fit in a graph label without Salesforce truncating it.
It uses the American schedule for Daylight Saving. I haven’t yet tweaked it for European Daylight Saving, which diverges from American DS for about six weeks each year
It’s formatted for the the United States’ Central time zone—if you’re in a different US timezone, tweak the 5/24 and 6/24 terms
Q: How can I use declarative configuration to generate random numbers in Salesforce?
A: The following field formula generates a number from 1 to 100 based on each record’s ID. It isn’t random, but with enough records created gradually over time I hope it’ll produce a reasonable-ish distribution between 1 and 100.
The two FIND() functions in the heart of the formula take the 14th and 15th characters of the Salesforce ID and convert them into a number between 0 and 3843 (which is the highest two-digit number in base62).
The three outer operations—the * 99, / 3843, and + 1—are what’s used to convert
Testing it out, I just inserted 5000 Leads using Data Loader, which I thought would produce a uniform distribution of numbers (again, not random, but uniform).
As you can see, something (in how Salesforce processed the insert job, I guess) led to a doubly-high bulge between 62 and 95, and half the number of 1s and 100s:
My friend Chris Robertson applied it to a table with 3,906 records and got this:
. . . eh, still not great. Let me know what you get!
Better yet, let me know if you have any luck generating random numbers declaratively, say using other “random” number generators like CreatedDate and/or LastModifiedDate. I had no luck with them.