19 June 2014

Salesforce Login Types

For some reason I could not find any public salesforce documentation or KB articles that discusses what each of the login types means in the Login History page. So I asked support to understand each and they provided me with the table below which I'm sharing to help anyone who may be needing it.

Login Type Description
Application UI login
Chatter Communities External User Community User Login
Other Apex API Other Apex API
Partner Product Partner Integration Login
Remote Access 2.0 OAuth 2.0 login ( for example, connected app login)
SAML Chatter Communities 
External User SSO
Community User Login from Single-Sign-On
SAML Idp Initiated SSO SAML Single-Sign-On with login initiated 
from Idp(Identity Provider) side
SAML Sfdc Initiated SSO SAML Single-Sign-On with login initiated 
from Salesforce side, redirect to Idp then 
login after got Idp's SAML response
SYNC Login from SYNC client

16 June 2014

Unlocking the power of custom settings for data loading

Common use case when doing data load is to not to execute anything from the environment such as workflows, validation rules or apex triggers. This can only be achieve if (1) you have migrated only object you are targeting to do data load while workflow and triggers are not yet deployed or (2), workflows and triggers are inactivated which is somehow a hassle to admin or developers as they have to manually deactivate the workflow and worst deploy the inactivated triggers or (3), you explicitly includes user to skip on the workflow criteria or apex codes on triggers. Custom Settings can be used to hold configurations specific to user for skipping such automations.

Below is a sample custom settings I created with 3 fields.


I also created a small apex class that will interface with this custom settings and will be used on apex triggers.

public class AutoSkipSettings {
    
    public static boolean skipTrigger(){
        boolean skipTrigger = false; 
     
        Automation_Skip_Settings__c userSkipSetting = 
             Automation_Skip_Settings__c.getValues(UserInfo.getUserId());
        
        if(userSkipSetting <> null && userSkipSetting.Skip_Trigger__c){
            skipTrigger = true;
        }

        return skipTrigger;
    }
    
}

The apex triggers basically just extracts the custom setting value for the user and return the value of the checkbox. In this case, I'm returning the value of the Skip_Trigger__c field. Now we are ready to use the custom settings on validation and workflow rule criteria and apex trigger.

On the validation or workflow rule, the custom setting fields will be available as a global variable. Note that for workflow rule, you need to select 'formula evaluates to true' on the rule criteria section.


On any apex trigger, use the apex class created above.

trigger TestAccountTrigger on Account (before update) {
    
    if(!AutoSkipSettings.skipTrigger()){
    // do anything here
    }
    
}

Additional Notes:
  • The reason why we used hierarchy type for custom setting is so that we can have a default organization level value. 
  • The custom setting is much better than using custom object so that we save 1 SOQL query on the code and reference the field as global variable on formula