Contains/IndexOf Method For Lists - Ideas - Salesforce Trailblazer Community
Trailblazer Community

All Ideas

Idea Details

Post an Idea
This idea has been delivered and can no longer be voted or commented on. If you’d like to add to this conversation, please post a new idea.
1,190  Points voting closed
Delivered in Spring 18
Delivered in Spring 18

Contains/IndexOf Method For Lists

Salesforce Platform, Apex & Visualforce

It would be nice to have either a contains or indexOf method for a List collection.

Instead of this code:

for(Id IdToUse: ListOfIDs) {
   if(IdToUse == IdToCompare) { return true; }
return false;

You could simply use this:

return (ListOfIDs.indexOf(IdToCompare) > -1);

It would make working with Lists a lot more efficient.

· Flag

Latest Comment from Salesforce

  • Chris Peterson - 2 years ago

    List.contains(Object) and List.indexOf(Object) are now available in Spring18. Make sure your apex classes are on API v42.0.
  • Upvotes
  • Downvotes



from AppExchange


No results found.

Help us to keep IdeaExchange clean by pointing out overlapping ideas. We'll investigate your suggestion and merge the ideas if it makes sense.



Thanks for your merge suggestion. We will review it shortly and merge the ideas if applicable.

Salesforce takes abuse situations very seriously. Examples of abuse include but are not limited to posting of offensive language or fraudulent statements. To help us process your request as quickly as possible, please fill out the form below describing the situation. For privacy and security reasons, the final outcome of an abuse case may not be revealed to the person who reported it.


Thank you for your feedback. We take abuse seriously and will investigate this issue and take appropriate action.