ANS-1747 · SUITESCRIPT DEVELOPMENT

How to Resolve Address Field Discrepancies in NetSuite Text Boxes

Address field comparisons can be unreliable due to varying carriage return characters, requiring specific string manipulation for accurate data validation.

Short answer

Address field discrepancies often stem from inconsistent carriage return characters (n, r, rn). To ensure accurate string comparisons, these characters should be removed using JavaScript regular expressions. This method standardizes the string content, allowing for reliable validation and matching between address text boxes and individual address fields in NetSuite.

Scenario

Users may encounter situations where the content of an address text box does not precisely match the concatenated values of individual address fields, even when the visible text appears identical. This discrepancy can lead to validation failures or incorrect data comparisons within NetSuite, often due to hidden special characters.

Solution

The core issue arises from the unpredictable nature of carriage return characters ("n", "r", "rn") that can vary across different systems, browsers, or regional settings. These characters should be excluded from string comparisons to ensure accuracy.To address this, implement a regular expression (REGEX) to remove all carriage return and newline characters from the strings before comparison. For example, when comparing addres1 and address2 fields, the following JavaScript REGEX can be used:

if(addres1.replace(/r/g, '').replace(/n/g, '') address2.replace(/r/g, '').replace(/n/g, ''))

Modern browser debuggers may display special characters differently, and their capabilities for visualizing non-printable characters like carriage returns can vary.Alternatively, the JavaScript function charCodeAt() can be used to check the character codes of special characters, though this method can be more tedious for comprehensive string cleaning.

Expert NetSuite Support

Need help with this NetSuite issue?

SuiteScript Development consulting and configuration support

Talk to a consultant