salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.44k stars 2.07k forks source link

Inconsistent application of trim function on name & varchar fields #10339

Closed SinergiaCRM closed 2 months ago

SinergiaCRM commented 8 months ago

Issue

In SuiteCRM, an issue has been detected with the handling of varchar type fields, especially those for first and last names. These fields, when filled out through web forms, retain additional spaces at the beginning or end. This results in difficulties in correctly locating these records in searches. For example, if the first_name field includes additional spaces, it will not be properly found when searching by full_name if it is written with only one space between the first and last name. Additionally, it has been observed that some SuiteCRM modules, like Invoices or Spots, as well as modules created in the Module Builder, maintain these spaces at the beginning or end when creating a new record via the edit view. In contrast, the original modules from SugarCRM do apply the trim function, removing these spaces.

Expected Behavior

It is expected that the trim method be uniformly applied to all name and last name type fields in the CRM, regardless of the module or method used for data entry (edit view, inline editing, import, web form, etc.). This should ensure that there are no additional spaces in these fields, facilitating the search and management of records.

Current Behavior

Currently, the name and last name fields that are received through forms do not apply the trim method, unlike what happens in the CRM's edit view. This leads to names containing extra spaces, which complicates the search for people in the system (for example, Alvaro Gonzalez would not be properly found due to the extra spaces). Additionally, an uneven application of the trim method has been observed when saving records in different CRM modules, depending on the module and the method used.

Proposed Solution

It is proposed to implement the trim function at a central point in the CRM's code flow, ensuring its uniform application in all name and varchar fields of all modules, regardless of the data entry method. This implementation should reflect the practice already established in the original modules from SugarCRM, applied in the edit view.

Steps to Reproduce

  1. Enter or edit records in different CRM modules using various methods (edit view, inline editing, import, web forms, etc.).
  2. Observe the lack of application of the trim method in name and last name fields from forms.
  3. Verify the inconsistent application of the trim method in different modules and saving methods.

Your Environment

gunnicom commented 8 months ago

I would even go one step further: trim each and every value before saving.

We have the same problem too, sometimes and I see no case in which you would need spaces or line feeds in the beginning or end of any field.