What is an external ID in Salesforce?

When importing custom objects, solutions, or person accounts, you can use external IDs to prevent duplicate records from being created as a result of the import operation. An external ID is a custom field that has the “External ID” attribute, meaning that it contains unique record identifiers from a system outside of Salesforce. When you select this option, the import wizard will detect existing records in Salesforce that have the same external ID. Note that this operation is not case-sensitive - for example, “ABC” will be matched with “abc”. However, there is an exception: if the custom field has the separate “Unique” attribute and the case-sensitive option for that attribute is selected, uppercase and lowercase letters will not be considered identical.


The fields with below data types can only be external Id

1. Number
2. Text
3. Email

When a field is made as external Id, the field will be automatically indexed. Additionally, if you have an external ID field, the field becomes searchable in the sidebar search. You also can use the upsert API call with the extenal ID to refer to records.

If we create External Id field, it will be indexed by default by Salesforce.

During upsert operation,

1. If External Ids are matched, it will update the record.

2. If External Ids are not matched, it will create a new record.

3. If External Ids are matched more than once, it will throw an error.

Setting Read-Only Mode for an Entire Page

To enable read-only mode for an entire page, set the readOnly attribute on the <apex:page> component to true.

For example, here is a simple page that will be processed in read-only mode:
1<apex:page controller="SummaryStatsController" readOnly="true">
2    <p>Here is a statistic: {!veryLargeSummaryStat}</p>
3</apex:page>
The controller for this page is also simple, but illustrates how you can calculate summary statistics for display on a page:
1public class SummaryStatsController {
2    public Integer getVeryLargeSummaryStat() {
3        Integer closedOpportunityStats =
4            [SELECT COUNT() FROM Opportunity WHERE Opportunity.IsClosed = true];
5        return closedOpportunityStats;
6    }
7}
Normally, queries for a single Visualforce page request may not retrieve more than 50,000 rows. In read-only mode, this limit is relaxed to allow querying up to 1,000,000 rows.
In addition to querying many more rows, the readOnly attribute also increases the maximum number of items in a collection that can be iterated over using components such as <apex:dataTable><apex:dataList>, and <apex:repeat>. This limit increased from 1,000 items to 10,000. Here is a simple controller and page demonstrating this:
1public class MerchandiseController {
2
3    public List<Merchandise__c> getAllMerchandise() {
4        List<Merchandise__c> theMerchandise =
5            [SELECT Name, Price__c FROM Merchandise__c LIMIT 10000];
6        return(theMerchandise);
7    }
8}
01<apex:page controller="MerchandiseController" readOnly="true">
02    <p>Here is all the merchandise we have:</p>
03    <apex:dataTable value="{!AllMerchandise}" var="product">
04        <apex:column>
05            <apex:facet name="header">Product</apex:facet>
06            <apex:outputText value="{!product.Name}" />
07        </apex:column>
08        <apex:column>
09            <apex:facet name="header">Price</apex:facet>
10            <apex:outputText value="{!product.Price__c}" />
11        </apex:column>
12    </apex:dataTable>
13</apex:page>
While Visualforce pages that use read-only mode for the entire page can’t use data manipulation language (DML) operations, they can call getter, setter, and action methods which affect form and other user interface elements on the page, make additional read-only queries, and so on.

Counters