0

On the Account object I have a field called Postal Zip Code. If Postal Zip Code is more than 5 characters long (e.g. "12345678"), I have to truncate to 5 characters (e.g. "12345"). How can I do so using Validation Rules?

1
  • 3
    you cannot use validation rule to update field values. it has to be either workflow field update or a process builder. validation rules are used to prevent / stop entering incorrect values. Mar 6, 2017 at 11:16

2 Answers 2

7

Assuming you want to take the first 5 digits from the zipcode field to use in the validation rule, you can use the LEFT function to do that. As per the Salesforce documentation, the LEFT(text, num_chars) function Returns the specified number of characters from the beginning of a text string.

TRIM(LEFT(zipcode, 5))
0

You could probably use the formula from above answer (Trim(Left(BillingPostalCode,5)) in a formula field, then use a flow or process builder to grab the value from the formula field and plug it into the zipcode field. You definitely can not use validation rules to update fields.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .