Activity Forums Salesforce® Discussions How to check if list contains the specified element in Salesforce ?

  • How to check if list contains the specified element in Salesforce ?

    Posted by Kirandeep on October 27, 2020 at 3:22 pm

    How to check if list contains the specified element in Salesforce ?

    Anuj replied 4 years ago 2 Members · 1 Reply
  • 1 Reply
  • Anuj

    Member
    October 27, 2020 at 3:28 pm
    1. Define a new Set. Set<String> mySet = new Set<String>();
    2. Use the Set. addAll() method to add all of the List elements to the set. mySet. addAll(myList); .
    3. Use the Set. contains() method to check the Set for the element you're looking for.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos