7

You're using the 18-digit Id, while validation rules don't support that (see this idea). It will support 15-digit Id, but as mentioned in the comment, avoid hard-coding your record type Id. You can rely on DeveloperName of the record type. It's similar to the API name of a custom field, is unique, and gives you some benefits over the Id: It will stay the ...


6

That's because SFDC matches the whole field against your REGEX, your whole Email__c is not only ';.+$', plus $ is a special character, so you need something like this REGEX( Email__c, '.*[;.+$].*') If you're only interested in ; character then put it like this '.*;.*' Another point is that if you are only curious about ; character you can use CONTAINS(...


5

What you're looking for is actually a NOR operation (NOT-OR). Unlike AND, this will only return true when none of the conditions are met. I also shuffled around the operations to make them more performant and legible. However, this changed some of the operations, so let's go over it in pieces. AND( ISNEW(), NOT(Converted_Lead_Contact__c), ... ) ...


5

You can create a Unique field (Unique_Course_Student_Relationship__c) on the junction object and populate it with a concatenation of StudentId and CourseId through a workflow on create. CASESAFEID(StudentId) + CASESAFEID(CourseId) This will ensure that there's never two junction records with the same Student and Course as the value of that field needs to be ...


5

Just use ABS. ABS(/*calculation*/) <> 1


5

$ is used for Global Variables. These are used in all kinds of formulas, including formula fields, validation rules, Process Builder, etc. They are used exactly as you would any other kind of variable, they just have special meaning in context (e.g. referencing the user's profile via $Profile).


5

You are missing a , at Job_Number__c ,CONTAINS(Job_Number__c '#') Should be ,CONTAINS(Job_Number__c, '#')


5

Treating validation formulas like they were normal code and applying indentation tends to really help out on issues like this. Doing that would look like this AND( Sync_to_system__c, OR( CONTAINS(Job_Name__c , '\\'), CONTAINS(Job_Name__c , '/'), CONTAINS(Job_Name__c , ':'), CONTAINS(Job_Name__c , '<'), ...


4

The AND logical function is described as this: Returns a TRUE response if all values are true; returns a FALSE response if one or more values are false. The logic operators and functions in Salesforce formulas (and thus validation rules) are similar to Reverse Polish Notation in math: The operator comes first, then you comma-separate everything that the ...


3

Validations only know about your current record. They don't know about other records in the object. You will need to write code to query other records, and put the validation check in that code. For example in a trigger.


3

Yes, regex can do this. NOT(REGEX(SomeCustomField__c, '^(?s)\\d{9}(\\s+\\d{9})$')) || REGEX(SomeCustomField__c, '(?s)(\\d{9}).*\\1') The trick here is that we go in to "single line mode" (?s) to allow . to match newlines, then we check each nine-digit string (\\d{9}) with any intervening characters (.*), followed by the same group again (\\1).


3

You could use ISNEW() function: Checks if the formula is running during the creation of a new record and returns TRUE if it is. If an existing record is being updated, this function returns FALSE. I.E. AND(ISNEW(), Name = 'Mike'). If you have this validation on Account object you cannot create a new Account with Name = Mike, but you can change the name of ...


3

Validation rules continue to mess with my mind to this day. The thing that keeps tripping me up is that if a validation rule evaluates to true, then the validation rule prevents the dml from completing. It feels like the opposite of what I've been conditioned (through education and experience) to think. If we want to except certain situations from triggering ...


3

You want to check if it contains non-numbers, so that's what you need to do. The rule should look like: REGEX({!phone_private}, "[^0-9 ]+") The ^ operator at the beginning of a character class inverts the character matching, so only 0 through 9, and space, would be allowed.


3

This is somewhat subjective, so opinion based, but my recommendation is to have dedicated validation rules for specific checks. It means the user can be guided better, and you can have the validation associated with a field. In terms of best practice, where possible have the validation only apply to initial setting and subsequent changes of the values of ...


3

The Name corresponds to the label of the role in the UI. You can see that type of information in UserRole. Required. Name of the role. Corresponds to Label on the user interface. What you're looking for is DeveloperName $Profile.Name = "Case Manager" && $UserRole.DeveloperName <> 'Lead_Case_Manager' && CONTAINS(TEXT(...


3

Your current validation rule says the following Block the user if the all of the following is true: Status__c = 'N/A' NHPMS__Re_Admit__c IS CHANGED NHPMS__Discharge_Date__c IS CHANGED Next_Appointment__c IS CHANGED In your screenshot, only #1, #3, and #4 are true. You are not changing NHPMS__Re_Admit__c so the validation rule does not block you. Based on ...


3

When using escape sequences like \b in regex in Salesforce, you need to add an extra backslash so "\\]?\\b(?:word)\\b\\]?" in that REGEX() function would be syntactically correct, though perhaps not semantically correct. Perhaps you meant for that (?:word) to be (?:\\w)? If you want to match a literal backslash, you need 4 backslashes \\\\


3

Your use of AND and OR is incorrect. It should look like: AND( OR( ISPICKVAL( Why_lost__c , "Better competitive solution"), ISPICKVAL( Why_lost__c ,"missing features"), ISPICKVAL( Why_lost__c , "Competitor") ), ISPICKVAL( StageName , "Closed Lost"), OR( ISBLANK( What_features_did_you_need__c ), ...


3

You can heavily optimize this code with REGEX, not to mention some of your conditions are nonsensical, specifically, a field cannot start with or end with a space character. Here's a revised version: Sync_to_system__c && REGEX(Job_Name__c, '(.*(\\.$))|(.*[\\/:<>|*?+#].*)')


2

You simply need to use backreferences: REGEX(Name,'.*(.)\\1{3}.*') Which reads as follows: .* Any number of preceding characters ( Start numbered capture group . Any one specific character ) End numbered capture group \\1 Backreference to capture group 1 {3} Repeated 3 times (four total instances of the same character .* Any number of subsequent ...


2

In a way, validation rules work the opposite way of how we programmers normally think. If the conditions evaluate to true, the validation rule is tripped and prevents dml from ocurring on that record (and you'll either get a validation exception or an error noted in the database.saveresult if you are using allOrNone = false). So if you want to enforce this ...


2

This is a basic syntax issue. You are trying to use = operator with two values. May be you wanted to write this, assuming Address field is a text field, AND(NOT(Address = "P.O. Box"), NOT(Address = "PO Box")) As updated if Address is a address type then check for their postal code values is ISBLANK https://help.salesforce.com/articleView?...


2

The Salesforce help/documentation does not longer clearly describe this usage of the CONTAINS function. But the old version used to contain this example: Example 2: a. CONTAINS("CA:NV:FL:NY",BillingState) Will return TRUE if BillingState is CA,NV,V,L,FL:NY or any exact match of "CA:NV:FL:NY". NOTE: when using contains with the multiple ...


2

Can you try this one and see if it works in your scenario? REGEX(Manager_Notes__c , ".*\\b\\d{3}-?\\d{2}-?\\d{4}|\\d{9}\\b.*")


2

This is not a perfect solution for reasons listed below but should be useful to many and can be extended for the edge cases NOT(REGEX(MyField__c, '(' & 'YESTERDAY|' & 'TODAY|' & 'TOMORROW|' & 'LAST_WEEK|' & 'THIS_WEEK|' & 'NEXT_WEEK|' & 'LAST_MONTH|' & 'THIS_MONTH|' & '...


2

You can write a before trigger on the junction object and check if the combination already exists. If yes then use addError to throw an error.


2

The most basic version of that formula would be: Not(IsPickVal(Course_Name__c, 'Java')) && IsBlank(Duration__c) Which says that "If course name is not Java, and Duration is blank, show an error." For the other fields that are always required, simply mark them as required on the page layout so the users have an expectation of which fields ...


2

Maybe you can use the concatenation of FirstName and LastName fields, no idea why Name is not available ($User.FirstName & ' ' & $User.LastName) != $Label.USER_MANAGER But I would recommend you to use a Field to hold if a user is a manager


2

Right-click on the validation rules folder for the object, and click SFDX: Retrieve Source from Org.


Only top voted, non community-wiki answers of a minimum length are eligible