Slaesforce FAQ

how to get the highest index number in salesforce

by Ms. Lisa Hudson DDS Published 2 years ago Updated 2 years ago
image

Salesforce List (Array) :How to Find the MAX value in a list 4:45 PM Update: There's a simple way as pointed out by Scott Hemmeter in his comment below. Just use the sort () method and the first element in the list is the MAX or MIN based upon your sort (DESC or ASC).

Full Answer

How to retrieve index of an element in list in Salesforce?

There is no method either in list or set class in salesforce to retireve the index of an element and the remove method requires an integer as a parameter which remove the entry at that particular index. If you need to know the index of an element in list or set, you need to loop through all of the collection elements and find it out.

What are custom indexes in Salesforce?

Salesforce also supports custom indexes on custom fields, with the exception of multi-select picklists, text area (long), text area (rich), non-deterministic formula fields, and encrypted text fields. External IDs cause an index to be created on that field, which is then considered by the Force.com query optimizer.

Is list () faster than square brackets in Salesforce?

I don't know if Salesforce changed its algorithms, but I just tested it, both in my Sandbox and Production, and it turns out the method List.get () is almost always faster than square brackets [i]. My first attempt, running List.get () prior to running square bracket:

How to find the index of an element in a list?

If you need to know the index of an element in list or set, you need to loop through all of the collection elements and find it out. Now, by end of loop you will have all the cases with desired values left in the map, you can collect them back using values () method and udpate them.

image

How to find the index of an element in a list?

If you need to know the index of an element in list or set, you need to loop through all of the collection elements and find it out. Now, by end of loop you will have all the cases with desired values left in the map, you can collect them back using values () method and udpate them.

Does Salesforce retire the index?

There is no method either in list or set class in salesforce to retireve the index of an element and the remove method requires an integer as a parameter which remove the entry at that particular index.

Index Tables

The Salesforce multitenant architecture makes the underlying data table for custom fields unsuitable for indexing. To overcome this limitation, the platform creates an index table that contains a copy of the data, along with information about the data types.

Standard and Custom Indexed Fields

The Force.com query optimizer maintains a table containing statistics about the distribution of data in each index. It uses this table to perform pre-queries to determine whether using the index can speed up the query.

Two-Column Custom Indexes

Two-column custom indexes are a specialized feature of the Salesforce platform. They are useful for list views and other situations in which you want to use one field to select the records to display and a second field to sort those records.

image
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9