Salesforce関連の記事を書いています。

  1. Salesforce

Salesforce input rule of “No half-width katakana” + “Only specific symbols allowed”.

There are often situations where you do not want half-width katakana characters to be used when entering data.
In Salesforce, there are situations where you want to control in detail the characters that can be used when inputting data.
For example, the following is a case in which you do not want to use half-width katakana in customer names or product names.

  • You do not want half-width katakana characters to be used in customer names or product names.
  • You want to unify data by limiting the allowed symbols.
  • You need to strictly control character types for external system integration.

In this case, take the custom item ” Registration Name (RegistrationName__c)” as an example,
We will create an input rule that controls input according to the following conditions.


Requirement

  1. All single-byte katakana characters are prohibited
  2. Symbols must be “. (period)” and “- (hyphen)” are only allowed.
  3. Do not generate an error if an item is left blank (optional input)

Organizing Character Types

First, let’s organize how to express each character type in regular expressions.

Character Type Regular Expression Explanation
Half-width katakanaWo-P Aiueo…including the muddled and semi-muddled marks
Period. Symbol “. Specify
hyphen- Specify symbol “-“.

Point
Half-width katakana characters can be specified together with [wo-P].
Only “period” and “hyphen” symbols are specified separately.


Entry Rules for Completed Forms

The following are the input rules for the completed form.

IF(
    ISBLANK(RegistrationName__c), FALSE,
    FALSE,
    OR(
        REGEX(RegistrationName__c, ".*[wo-p].*"),
        NOT(REGEX(RegistrationName__c, "^[a-zA-Z0-9.-] $"))
    )
)

Breaking down and explaining the meaning of the formula

This formula consists of three major parts.


1. Blank cells do not make an error.

ISBLANK(RegistrationName__c)
  • If the item is blank, no input rule is applied.
  • This setting is for optional input items.

2. Do not use half-width katakana characters

REGEX(RegistrationName__c, ".*[wo-p].*")
  • Returns TRUE if the input contains at least one half-width Katakana character.
  • This will result in an error if half-width katakana characters are included.

3. Checks for unauthorized symbols

NOT(REGEX(RegistrationName__c, "^[a-zA-Z0-9.-] $"))

This part checks “whether the characters entered contain anything other than the allowed list.

  • a-zA-Z0-9 → Only alphanumeric characters allowed
  • . and - → period and hyphen and - → periods and hyphens allowed
  • → Repeat one or more characters
  • ^ and $ → Check if the entire input consists of this range

The result is an error if there is even one character other than alphanumeric, period, or hyphen.


4. Summarize by OR Condition

OR( Condition A, Condition B )
  • Returns an error if half-width katakana characters are included or if unauthorized characters are included.
  • This enables **”Half-width Katakana prohibited” + “Only specific symbols permitted “** at the same time.

Processing Flow

The final processing is done in the following order.

  1. Check if the item is blank
    → If blank, do not generate an error
  2. Check whether half-width katakana characters are included
    → Error if it is included
  3. Check for unauthorized symbols and characters
    → Error if included
  4. If any of the above apply, an error message is displayed.

Sample Input and Results

Input value Judgment Reason
TANAKA OK English letters only
tanaka-01 OK (alphanumeric characters and hyphens) Alphanumeric and hyphen
tanaka.01 Alphanumeric characters and a hyphen Alphanumeric characters and a period
Tanaka NG Including half-width katakana
tanaka_01 NG Underscore _ is not allowed
Tanaka NG Kanji characters are not permitted

Conclusion

What we have achieved with this formula is as follows

  • Half-width katakana is completely prohibited
  • Only periods and hyphens are allowed for symbols
  • No error if the item is blank

In actual practice, this can be applied to control the following

  • Add symbols to be allowed (e.g. , allow)
  • Prohibit Japanese and double-byte characters
  • Match a specific string pattern exactly

With regular expressions, you can flexibly control input content on Salesforce,
smooth system integration while maintaining data quality.

Salesforce recent post

  1. Salesforce input rule of “No half-width…

  2. How to get the text of a related list in Sale…

  3. How to Improve Business Efficiency by Automat…

  4. How to automatically lock closed business mee…

  5. Changes and impact on how Account Engagement …

関連記事

PAGE TOP