SFDO-Community/Salesforce-Indicators

Contains is NOT case sensitive [BUG]

annaloughnanrad opened this issue · 1 comments

At the extension level (where I have picked it up):
using the provided option Indicator Item Extension,
Contains Text

if you do not enter the text value as in the field, extension will not be activated.

EG
Contains Text "partner" will not display partner icon, but
Contains Text "Partner" will display icon.

Tested against Type on Account on dev org with values such as "Technology Partner"

IMHO not necessarily an issue as long as it is made crystal clear in the documentation - I am used to searching with contains being case sensitive on some platforms but for Indicators Jodie said the intent was for it to be case insensitive!

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
Add any other context about the problem here.

Thanks for this!

We will have a fix in the works already (without realizing this bug) when we add support for other matching criteria

  • Equals
  • Does Not Equal
  • Starts With

For interested parties - the code is here where we will be converting to lowercase and then comparing (even for Equals, based on feedback from the Oct 2023 Chicago Sprint team) :

if(extension.ContainsText) {
let fieldValue = dataValue.toLowerCase();
let compareValue = extension.ContainsText.toLowerCase();
// console.log('Value',dataValue + ' ' + extension.TextOperator + ' ' + compareValue); // Retain for debug purposes
if(extension.TextOperator === 'Contains'){
match = fieldValue.includes(compareValue);
// console.log('Contains', fieldValue.includes(compareValue));
} else if (extension.TextOperator === 'Does Not Equal') {
match = fieldValue != compareValue;
// console.log('Not equal', fieldValue != compareValue);
} else if (extension.TextOperator === 'Equals') {
match = fieldValue === compareValue;
// console.log('Equal', fieldValue === compareValue);
} else if (extension.TextOperator === 'Starts With'){
match = fieldValue.startsWith(compareValue);
// console.log('Start with', fieldValue.startsWith(compareValue));
} else {
match = fieldValue.includes(compareValue);
// console.log('Else', fieldValue.includes(compareValue));
}
}