Salesforce OAuth Endpoints

Endpoint Type OAuth Endpoint Description
OAuth 2.0 authorization endpoint https://login.salesforce.com/services/oauth2/authorize The Salesforce instance’s OAuth 2.0 authorization endpoint. Connected apps send OAuth
authorization requests to this endpoint.
OAuth 2.0 token endpoint https://login.salesforce.com/services/oauth2/token The Salesforce instance’s OAuth 2.0 token endpoint. Connected apps send OAuth token
requests to this endpoint.
Revoke endpoint https://login.salesforce.com/services/oauth2/revoke The Salesforce instance’s OAuth 2.0 revoke endpoint. Send requests to this endpoint
to revoke a connected app’s access.
Profile information endpoint https://login.salesforce.com/services/oauth2/userinfo The OpenID Connect OAuth 2.0 user profile information endpoint. OpenID Connect
defines the UserInfo endpoint to get a user’s profile information.
Dynamic client registration endpoint https://hostname/services/oauth2/register The OpenID Connect dynamic client registration endpoint. Send requests to this
endpoint to automatically register connected apps with Salesforce.
Introspection endpoint https://hostname/services/oauth2/introspect The OpenID Connect token introspection endpoint. Send requests to this endpoint to
check the current state of an OAuth 2.0 access or refresh token.
OpenID connect discovery endpoint https://login.salesforce.com/.well-known/openid-configuration The OpenID Connect discovery endpoint. Send queries to this endpoint for information
about the Salesforce OpenID Connect configuration.
Authentication configuration endpoint https://hostname/.well-known/auth-configuration The authentication configuration endpoint. Send queries to this endpoint for
information about an org’s SAML single sign-on and authentication provider settings.

Get Dependent Picklist Values in Apex

Sample Code:

//Pass dependent field parameter e.g.: Account.YourDependentField__c
public static Map<Object,List<String>> getDependentPicklistValues(Schema.sObjectField dependentField){
        Map<Object,List<String>> dependentPicklistValues = new Map<Object,List<String>>();
		//Get dependent field result
        Schema.DescribeFieldResult dependentFieldResult = dependentField.getDescribe();
		//Get dependent field controlling field 
        Schema.sObjectField controllerField = dependentFieldResult.getController();
		//Check controlling field is not null
        if(controllerField == null){
            return null;
        } 
		//Get controlling field result
        Schema.DescribeFieldResult controllerFieldResult = controllerField.getDescribe();
		//Get controlling field picklist values if controlling field is not a checkbox
        List<Schema.PicklistEntry> controllerValues = (controllerFieldResult.getType() == Schema.DisplayType.Boolean ? null : controllerFieldResult.getPicklistValues());
        
		//It is used to decode the characters of the validFor fields. 
        String base64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
        
        for (Schema.PicklistEntry entry : dependentFieldResult.getPicklistValues()){
            if (entry.isActive()){
			//The PicklistEntry is serialized and deserialized using the Apex JSON class and it will check to have a 'validFor' field
                List<String> base64chars = String.valueOf(((Map<String,Object>)JSON.deserializeUntyped(JSON.serialize(entry))).get('validFor')).split('');
                for (Integer i = 0; i < controllerValues.size(); i++){
                    Object controllerValue = (controllerValues == null ? (Object) (i == 1) : (Object) (controllerValues[i].isActive() ? controllerValues[i].getLabel() : null));
                    Integer bitIndex = i / 6;
                    Integer bitShift = 5 - Math.mod(i, 6 );
                    if(controllerValue == null || (base64map.indexOf(base64chars[bitIndex]) & (1 << bitShift)) == 0){
                        continue;
                    } 
                    if (!dependentPicklistValues.containsKey(controllerValue)){
                        dependentPicklistValues.put(controllerValue, new List<String>());
                    }
                    dependentPicklistValues.get(controllerValue).add(entry.getLabel());
                }
            }
        }
        return dependentPicklistValues;
    }

Database.Upsert – Get Which Records are Inserted or Updated Based on External Id

Sample Code:

Database.UpsertResult[] results = Database.upsert(accList, Account.ExternalId__c);
for(Integer i = 0, i < results.size(); i++) {
    if(results[i].isSuccess()) {
        if(results[i].isCreated()) {
            System.debug(accList[i].ExternalId__c +' was created');
        } else {
            System.debug(accList[i].ExternalId__c +' was updated');
        }
    }
}

InputField datePicker is missing when standardStylesheets are disabled in Visualforce Page

Sample Code:

<apex:page standardController="Opportunity" showHeader="false" standardStylesheets="false" docType="html-5.0">
   <apex:form id="frm">
      <apex:pageBlock title="Opportunity">
         <apex:pageBlockSection title="Opportunity Information" collapsible="false">
            <apex:inputField value="{!Opportunity.ClosedDate}" showDatePicker="false" type="datetime-local" />
         </apex:pageBlockSection>
         <apex:pageBlockButtons>
            <apex:commandButton value="Save" action="{!save}"/>
         </apex:pageBlockButtons>
      </apex:pageBlock>
   </apex:form>
</apex:page>