Bypassing Data Validation, the Clever Way

Q: “How do I make a Salesforce record bypass Data Validation?”

A: The Clever Way:

  1. create a checkbox field on the desired object called “Toggle Me to Bypass Validation” (or something like it); and
  2. change your Validation Rules on the desired object to ignore records where “Toggle Me to Bypass Validation” has changed–add a clause like NOT(ISCHANGED(Toggle_Me_to_Bypass_Validation__c)).

You’re done!


In the pastfolks implemented this the Adequate Way:

  1. create a checkbox called “Bypass Validation Rules for this Record” (or something like it);
  2. change your Validation Rules to ignore records where “Bypass Data Validation for this Record” is TRUE–add a clause like NOT(Bypass_Validation_Rules_for_this_Record__c); and
  3. create a Flow or Apex Trigger to change “Bypass Data Validation for this Record” back to FALSE whenever it’s set to TRUE.

The problem with this approach: step 3.

  • The Flow or Apex Trigger changes the record AGAIN, which–depending on your config–could cause logic to re-run. suboptimal.
  • The Clever Way only touches the record once.
  • If you need to programmatically bypass Validation Rules for an existing record, set the record’s “Toggle Me to Bypass Validation” to NOT(Toggle_Me_to_Bypass_Validation__c) in your Flow or Apex logic.

Props to Hanna Martynenko for the idea!

Post-Hyperforce Fallout

A headsup for anyone whose Production org hasn’t been upgraded to Hyperforce yet: after cutover, all our integration users had to re-authenticate. Made for a lively Monday in the office.


Also, this formula field (Number 18, 0) causes any Hyperforce org’s Report to return a “Number Too Large” error. . .

FIND(MID(Id, 15, 1), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") * 100000000

. . . but it works fine in

  • Page Layouts and
  • non-Hyperforce Reports.

What’s up with that? I’ve logged it as a question, too.

Kudosync ETL Lives!

If anyone out there still has Microsoft Access, well, today’s your lucky day. I’ve reuploaded Kudosync, my poor-man’s ETL tool.

Here’s the dedicated page (with all the documentation I wrote. . . three Tarantino movies ago).

A feature I added awhile ago: the ability to combine Salesforce SOQL with Access SQL–in the example below, you can see the Contact query

SELECT Id, AccountId
FROM Contact
WHERE AccountId IN ([SELECT Id FROM tbl01_Account])

. . . the SELECT Id FROM tbl01_Account bit refers to data from a previously-extracted table.

nifty!

The Salesforce Commandments: A Work in Progress

The Salesforce Commandments, a list of guiding principles for administrators, developers, architects, and consultants working in Salesforce
  1. You shall work under executives’ blessing
  • If the executives don’t use Salesforce, leave
  1. You shall track projects, requests, and bugs in tickets
  • If you don’t track tickets, start
  1. You shall gather requirements before developing
  • If you are not allowed to gather requirements, leave
  1. You shall develop in environments with a lifecycle
  • If you develop in Production, stop
  1. You shall favor customer needs over design
  • If you disregard customer needs, get over yourself
  1. You shall master one datum in one place
  • If you modify a datum in multiple places, consolidate
  1. You shall not lie in the data
  • If you lie in the data, redesign

There’s no shortage of Salesforce Commandments out there, but I like these seven because I

  • wrote them from my own hard-won experiences
  • recommend a course-of-action for each
  • ditched pretentious language (“thou shalt”? no thanks)
  • commit to revising them if I meet a sufficiently-compelling case (suggestions welcome!)

I first put it together in 2015ish, got it into its current shape in 2020, and presented it at an OpFocus DevOps roundtable in 2021.

Props to Steve O’Neal for the phrase “lie in the data”! Captures an important concept and sounds juuust a smidge Biblical.

Migrating Process Builder to Flow: The Third Way

Q: How can I migrate Processes to Flows?

A: SalesforceBen documents two ways (1. Salesforce’s own Migrate to Flow capability, and 2. Unofficial SF’s ConvertToFlow).

But I see a weakness: if either fails to digest a Process, it poops out halfway through and leaves me nothing to build on.

A third way is called for! If Migrate to Flow and ConvertToFlow don’t work for ya, try a little URL hacking:

  1. Open Developer Console, flip to the Query Editor tab, and check the “Use Tooling API” checkbox
  2. run the following query:

SELECT Id, DeveloperName, MasterLabel, Description, LatestVersionId, ActiveVersionId
FROM FlowDefinition
ORDER BY DeveloperName

  1. replace the 301 ID in the URL below with any Flow Definition Version ID from step 2 above:

https://na1.salesforce.com/builder_platform_interaction/flowBuilder.app?flowId=301abcdefghijklAAA

or, if you’re working in a Sandbox:

https://cs1.salesforce.com/builder_platform_interaction/flowBuilder.app?flowId=301abcdefghijklAAA

And pow, hey wow, whaddaya know, you’ve taken a Process like this

and converted it into a Flow like this (after you toggle from “Free-Form” to “Auto-Layout”):

. . . I still haven’t figured out how to save it as a BeforeSave. Because it came from a Process, it seems locked into being an AfterSave, ugh. Still working on that!

How Many Profiles Should I Have?

Q: With the advent (and ever-increasing features) of Permission Sets, how many Profiles should I assign my users to?

A: Louise Lockie’s terrific Dreamforce ’23 presentation, Architect a Permission-Set-Led Security Model (pp 29-34), advocates slimming down to three Profiles:

  • System Administrator (standard or custom)
  • API/Integration Profile (custom, using “Salesforce Integration” User License)
  • User Profile (custom, cloned from “Minimum Access – Salesforce” Profile)

The latter two Profiles should grant

  1. the barest-bones permissions and object/field access (when in doubt, leave it out!), with
  2. whatever Login/Session/Password settings adhere to your organization’s security policy.

Everything else can be granted by Permission Sets. Don’t forget to leverage features like

  • Permission Set Groups — to define a collection of Permission Sets that apply to a generalized Role like Sales Rep, Customer Support Rep, or Sales Manager. (Don’t forget the power of muting!)
  • User Access Policies — to assign Permission Sets and Permission Set Groups programmatically (eg, “if user has a ‘Sales Rep’ Role, assign them the ‘Sales Rep’ Permission Set Group”).

Three more random thoughts:

  1. User Access Policies is the feature I have really high hopes for. Programmatically assigning Permissions is huge. Sadly, at least as of this writing (2023-11-14), the feature still has some glaring omissions. In particular,
    • it doesn’t support OR boolean logic,
    • nor does it support specifying multiple values for fields like Department.
  2. I encourage you to name API/Integration Users with a consistent naming scheme that makes ’em easy to pick out. Personally, I set such users’
    • First Name to null, and
    • Last Name to “API User: [System]”, like “API User: NetSuite”.
  3. Supporting materials from Louise Leckie’s presentation can be found at bit.ly/PS-LL. So gratifying to see someone else is a Bitly fan!

How Much Am I Paying Salesforce to Hide Data from Me?

A lot. Beware “Archived Activities”: Salesforce’s quiet policy of hiding Task and Event records from end users after a year.*

Remember Salesforce storage is wildly expensive, hundreds or thousands of times more what it costs to store data in other clouds.

Archive-and-purge old Activities from Salesforce or pay the price!


* The specifics: any

  1. Event created more than 365 days ago,
  2. Closed-Task-with-a-due-date due more than 365 days ago, or
  3. Closed-Task-without-a-due-date created more than 365 days ago

disappears from Reports, Dashboards, and Related Lists. (You can see them by clicking “View All” buttons/links. In my experience, almost no one does that.)

I was also surprised to learn–just today!–that Salesforce enables customers to increase the 365-day threshold. The setting is called “Archive Days”, although beware performance degradation if you increase this too much.

Wordle Counter: “Which Word Should I Play Next?”

Long story short: make a copy of this spreadsheet to speed up your Wordle-solving!


The gory details: If you obsess over Wordle like I do, you’ve probably run into the conundrum of

  • having narrowed the answer to a smallish set of words, but
  • being unsure which word to play next.

My friend Dave and I are convinced: the best approach is to list all the candidate words, count the number of times each letter appears in all the candidates, and play the word whose letters appears in the most candidates.

Not difficult, but time-consuming! Save yourself time by entering the words in the Wordle Counter, and letting it do the counting for you.

Example: today (September 26th, 2023), I was staring at this after two turns:1

I came up with five possible words:
FOCAL
LOCAL
LOYAL
MODAL
VOCAL

. . . but which one’s the best to play next?

1] I pasted those five words into Wordle Counter’s “Input: Word List” tab:

2] then on the “Input: Parameters” tab I told Wordle Counter which letters I wanted to count (and activating the “Count by WORD?” setting prevents a duplicate letter from being double-counted within a single word):

And voila, Wordle Counter tells me how many times letters appear in those spots:

. . . and how many times each of those letters appears in my candidate words:

Armed with that information, I played the highest-freq word LOCAL and guaranteed getting the answer in two or fewer guesses:

try it out!2

  1. RAISE as my first play? Yup, I’m convinced, after looking at Wikipedia’s entry on letter frequencies (and sorting the table by descending order of letters in dictionary words), that RAISE is your best play. Come at me, bro. ↩︎
  2. I’m still tweaking it. I’m not sure it’s working right in every situation, but I’m really proud of some of the ARRAYFORMULA() logic. ↩︎