Formula Field & Validation Rule Inline Comments

Did you know that you can add comments directly into the body of your Salesforce formula field and validation rules? NO? One can do so by surrounding the comment with /* and */. In Apex and other programming languages, this is the multiline commenting syntax.

I’ve used this for two primary reasons. 1) To provide some inline comments so someone knows why a certain condition is being used and to provide additional context. My first recommendation is to put this information in the description but not everyone reads it!

2) To temporarily comment out parts of the body while developing and testing in a sandbox to revise the body as needed. Prior to discovering inline comments, I’d copy the formula to somewhere else for a backup, make changes, and then revert as needed. Now that’s not needed and it saves a bit of time.

Hope that helps and if you have other reasons, let me know in a comment below!

Formula Field Example

Validation Rule Example