15 votes
Accepted

Is Apex Sometimes Case Sensitive?

Yes. Collection membership is case sensitive. This applies to Sets: If the set contains String elements, the elements are case-sensitive. Two set elements that differ only by case are considered ...
David Reed's user avatar
  • 92.8k
10 votes
Accepted

How to make use of formula function like "Contains" as case insensitive

<apex:outputPanel rendered="{!contains(UPPER(wrap1.acc.Name),UPPER(wrap2.acc2))}"> Convert all to upper / lower case
Eric's user avatar
  • 54.2k
10 votes
Accepted

How to check if a string contains an element from a list

A shorter version of your code just checks the domain directly: Boolean found = domainNames.contains(email.split('@',2)[1]); There's other ways to do this, too, but this is probably the most ...
sfdcfox's user avatar
  • 491k
7 votes

Is Apex Sometimes Case Sensitive?

Map keys and contains checks (and the same with Set or List) are always case sensitive, with the one exception of describes such as fields.getMap() or Schema.getGlobalDescribe(). However, as soon as ...
Adrian Larson's user avatar
  • 150k
6 votes

Is Apex Sometimes Case Sensitive?

From SF docs on Mapss: Map keys of type String are case-sensitive. Two keys that differ only by the case are considered unique and have corresponding distinct Map entries. Subsequently, the Map ...
Pranay Jaiswal's user avatar
5 votes
Accepted

list.contains in salesforce not working with wrapper class

The List.contains method works exactly like Set.contains. As mentioned in the comments, you need to implement equals and hashCode if you want to use custom types in this sort of comparison. Below is a ...
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Database.Batchable List Record Id

Replace = with ==, single equals is for assignment and double for comparison.
Raul's user avatar
  • 18.8k
4 votes

Is Apex Sometimes Case Sensitive?

This is not Apex case sensitivity but a String case sensitivity. You are comparing String values in the Set and thus it will always evaluate based on its equality which is case sensitive. So if your ...
Jayant Das's user avatar
  • 30.6k
4 votes

How to check if a string contains an element from a list

If you have control over the type of domainNames, you should consider changing its type to Set<string>. Sets hash their values, so checking whether they contain a particular value takes the ...
IllusiveBrian's user avatar
4 votes
Accepted

Checking if sequence of CHAR are in String

I think that case sensitivity is a bit of a red herring here. What distinguishes a COO from occurrences of the same letters is the context around it. To pick those up, you need something like a ...
Aidan's user avatar
  • 13.7k
4 votes
Accepted

How do I remove repeating parts?

We usually move the reusable piece of code to a common utility method. You can create a private method that will return the sanitized comment back. private static String getSanitizedComment(String ...
Pranay Jaiswal's user avatar
3 votes
Accepted

Set.contains() not working

As mentioned in Using Custom Types in Map Keys and Sets, you need to override hashCode and equals in order to have Set work correctly with your custom class. For example: public Integer hashCode() { ...
sfdcfox's user avatar
  • 491k
3 votes
Accepted

does apex class api version impacts new features

Contains method was introduced recently; I guess in version 42.0. To use the it, you would have to upgrade API version of the class. Note: Salesforce recommends to upgrade the API version after ...
Raul's user avatar
  • 18.8k
3 votes
Accepted

soql contains on multiple values

You can use a Collection of type String to find values using like: String[] cities = 'atl%,por%,bos%'.split(','); Account[] accounts = [select id, billingcity from account where billingcity like :...
sfdcfox's user avatar
  • 491k
3 votes

How can I add a "contains" criteria in a SOQL query?

That would only find emails addresses that are only '.com'. To match with email address values that are have one or more characters before the '.com' text, you need to add a wildcard %. Try using '%....
Peter Luo's user avatar
  • 140
2 votes

soql contains on multiple values

You can use like this: Set<String> billingCityNames = new Set<String>{'%atl%', 'por%', 'bos%'}; select id, billingcity from account where billingcity like :billingCityNames or you can ...
Santanu Boral's user avatar
2 votes
Accepted

Method does not exist or incorrect signature?

Use a Map instead: Map<Id, MyObject__c> records = new Map<Id, MyObject__c>(); for (WrapperClass wrapper : wrappers) { if (!records.containsKey(wrapper.getId()) { records....
Adrian Larson's user avatar
  • 150k
2 votes
Accepted

Use Contains to compare a field value

Use the String.contains() method like so: global class TerminateInboundEmailHandler implements Messaging.InboundEmailHandler { global Messaging.InboundEmailResult handleInboundEmail(Messaging....
Aaron P.'s user avatar
  • 1,677
2 votes
Accepted

'Attempt to de-reference a null object' with Field__c.contains()

You are assuming that toolsMap.get(g.Id).HelpText__c always returns a value. This may not be true. So whenever it returns null, your current code will fail as you observe. A refactored version of ...
Jayant Das's user avatar
  • 30.6k
2 votes

Is Apex Sometimes Case Sensitive?

In addition to the map/set answers and not specifically Apex but relevant in Apex use of SOQL: Platform Encryption deterministic encryption When you use case-sensitive deterministic encryption, ...
cropredy's user avatar
  • 71.3k
2 votes
Accepted

How to find all records where a textfield contains "04/06/2020" twice?

As Phil W mentioned, you cannot filter long text fields in SOQL. You can vote for the idea to allow this. You didn't really specify the context for this. If it's a trigger context, then you already ...
Kris Goncalves's user avatar
2 votes
Accepted

IF AND OR together in one formula

Your OR/AND was all confused, it should have been OR(A,AND(B,C),AND(D,E)). I realize this looks weird, as you were probably expecting it to look like A OR(B AND C)OR(D AND E), but that's not how ...
sfdcfox's user avatar
  • 491k
2 votes

How to avoid Case Sensitive Contains check in formula field

You need to use the LOWER function as follows. IF(CONTAINS(LOWER(Title), "chief architect"),"Architect")
Damecek's user avatar
  • 1,938
2 votes
Accepted

Get element from list which contains element from another list

Unfortunately, since the second string is looking for a partial text match, I don't see a way to avoid looping over each element to compare them. If you had a full text element match, the inner loop ...
JimG's user avatar
  • 743
2 votes
Accepted

Why .contains only returns true if it is an exact match in the app, but works fine in developer console?

It appears from your debug statements and the code you have, that the inputs were actually surrounded by quotes: “12345” and “1234”, rather than 12345 and 1234. In this case, neither string will ...
sfdcfox's user avatar
  • 491k
1 vote
Accepted

VisualForce - If Contains Or

You can separate the different options using multiple CONTAINS functions in an OR function: <apex:outputText rendered="{!IF(OR(CONTAINS(Intake__c.Personal_Care__c, 'Toileting'), CONTAINS(...
Instread's user avatar
  • 633
1 vote

How to Blank Date value in Date formula field?

It's an old question so I don't know if you managed to fix it but you just need to change Null and Today() in your formula : IF((CONTAINS(TEXT(StageName),"closed")),Today(),NULL)
Romain Corone's user avatar
1 vote

How to find all records where a textfield contains "04/06/2020" twice?

Taking Kris's answer a little further, if the context is outside the Account trigger, in order to get a set of candidate Accounts that may be what you are looking for - i.e. ones that include the ...
Phil W's user avatar
  • 36.2k
1 vote

Checking if sequence of CHAR are in String

The examples you gave are incorrect. Since you were using containsIgnoreCase(), the case is (unsurprisingly) ignored. Since "Coordinator" does, in fact, contain "coo", the containsIgnoreCase() method ...
Derek F's user avatar
  • 61.5k
1 vote
Accepted

Set contains (Field name from Map<String, Schema.SObjectField> fieldMap) not working

The field map returns keys in all lowercase, but you're using proper-casing. This is what's causing the problem. A better alternative would be to make sure the field is in the describe map. This ...
sfdcfox's user avatar
  • 491k

Only top scored, non community-wiki answers of a minimum length are eligible