Opened 4 years ago
Last modified 4 years ago
#2624 new defect
Remove leading and trailing spaces from cooperator fields
| Reported by: | Stacey | Owned by: | Benjamin Haag |
|---|---|---|---|
| Priority: | medium | Milestone: | |
| Component: | Database, Data Updates | Version: | N/A |
| Severity: | Keywords: | ||
| Cc: | Database Engine: | N/A | |
| Operating System: | N/A |
Description
Automatically remove leading and trailing spaces entered by a user in cooperator record text fields. Also 'clean up' existing records by using TRIM to remove currently hidden leading and trailing spaces.
Specifically focus on fields commonly used as search criteria (Last Name, First Name, Organization, Address line 1, etc.)
Searching for names and finding related cooperator records when processing web orders in the OW challenging since these are all different:
" Smith"
"Smith "
"Smith"
The OW web order processing of the coop record in the coop wizard is initially based on the default search criteria checkboxes (Last Name, Geography) and cannot find a CT coop record of "Smith" since the PW requestor entered their name as "Smith ". When a web cooperator has leading or trailing spaces on every single field and the CT record does not, there is no text-based 'matching field' to sort on.
As part of the super coop group, I have used TRIM on GG coop record fields to 'clean up' as many existing records as possible but some records still remain.
These 4 CT coop records need the last name TRIMmed to remove spaces:
( @cooperator.last_name LIKE '% ' OR @cooperator.last_name LIKE ' %' )
184942
184985
185248
185313
15 cooperator.first_name
12 cooperator.organization
477 web_cooperator.first_name
335 web_cooperator.last_name
829 web_cooperator.organization

Benjamin mentioned that we may want to trim all characters that produce "whitespace" since LTRIM and RTRIM aren't failsafe in SQL Server. In an email chain on 9/29/22 he mentioned that we may need something like:
select LTRIM(RTRIM(REPLACE(REPLACE(REPLACE(REPLACE(Name, CHAR(10), CHAR(32)),CHAR(13), CHAR(32)),CHAR(160), CHAR(32)),CHAR(9),CHAR(32))))