Who has all the Answers?

Over the past week or so, I’ve found myself getting involved in the Salesforce Answers community at success.salesforce.com. I say I ‘found myself’ getting involved because I initially checked it out just to respond to a few questions but soon discovered that it can get quite addictive. ‘Hey, another best answer in the bag! I’m now up to 36,574th place – woohoo!’

Anyway, whilst answering some questions and reading the comments of others, I’ve come across a question of my own that I want to put out there.

Many of the questions being posed on the community revolve around people wanting to create validation rules and workflows based on a certain type of user doing something. To do that, your validation or workflow rule is going to need to refer to the current user’s profile or role.

So, I fired in an answer to one such question which referenced a formula something like ‘AND(ISPICKVAL(Your_field__c, ‘Your restricted value’), NOT($UserRole.Name == ‘Your allowed user role’))’. And that worked, but I soon received a reply suggesting it may be better to use $UserRole.Id instead of $UserRole.Name, as the ID is fixed and the rule will therefore still work if the name is ever modified.

That makes perfect sense: you’re future-proofing your logic. So, for the next few questions of a similar nature, the answers I gave referenced the role or profile’s ID instead of its name.

But almost immediately another member of the community responded to one example to say that my formula could be improved by using the name attribute instead of the ID, because that way the rule will also work as expected in the sandbox (where IDs are not identical).

And that makes sense too. Plus, the name is naturally more human-readable, which helps, especially if more than one user is administering the system.

So what’s the ‘correct’ answer? Both options have their merits, but does one win out over the other? Or is there no right or wrong answer? Is it just a judgement call? We’d love to hear your thoughts.

Oh and if you haven’t checked out the Answers community, do so right now. It’s amazing how many Salesforce users could benefit from your help. And although it’s a bit of fun racking up points, you do also feel a real sense of achievement and pride when you help someone fix that issue they were stuck on.

It’s a great way of paying it forward, and with every solution you give you feel a little like you’re balancing out a previous misdeed. And if that were really how it worked, I’d hate to think what SteveMo had been getting up to in a past life…

Leave a Reply

%d bloggers like this: