Category Archives: Salesforce

Dynamic Getting sObject Picklist Values on Lightning Component

In this example we will fetch Picklist field “Industry” values from “Account” object and set in ui:inputSelect on Lightning Component.

Apex Class:

public class GetPicklistValuesController {
    public static List <String> getPicklistValues(sObject obj, String fld) {
        List <String> pList = new list <String>();
        //Get the object type of the SObject.
        Schema.sObjectType objType = obj.getSObjectType();

        //Describe the SObject using its object type.
        Schema.DescribeSObjectResult objDescribe = objType.getDescribe();

        //Get a map of fields for the SObject
        Map<String, Schema.SObjectField> fieldMap = objDescribe.fields.getMap();

        //Get the list of picklist values for this field.
        List<Schema.PicklistEntry > values = fieldMap.get(fld).getDescribe().getPickListValues();

        //Add these values to the selectoption list.
        for (Schema.PicklistEntry a: values) {
        return pList;


<aura:component controller="GetPicklistValuesController" access="global" implements="force:appHostable">
    <aura:attribute name="objInfo" type="account" default="{sobjectType : 'Account'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>    
    <div class="slds-form-element">
        <label class="slds-form-element__label" for="select-01">Select Industry</label>
        <div class="slds-select_container">
            <ui:inputSelect  aura:id="accIndustry" class="slds-select"  change="{!c.onPicklistChange}"/>

Component Helper:

    fetchPickListVal: function(component, fieldName, elementId) {
        var action = component.get("c.getPicklistValues");
            "obj": component.get("v.objInfo"),
            "fld": fieldName
        var opts = [];
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state == "SUCCESS") {
                var allValues = response.getReturnValue();
                    class: "optionClass",
                    label: "--- None ---",
                    value: ""
                for (var i = 0; i < allValues.length; i++) {
                        class: "optionClass",
                        label: allValues[i],
                        value: allValues[i]
                component.find(elementId).set("v.options", opts);

Component Controller:

    doInit: function(component, event, helper) {
        helper.fetchPickListVal(component, 'Industry', 'accIndustry');
    onPicklistChange: function(component, event, helper) {
        //get the value of select option

Lightning App:

<aura:application extends="ltng:outApp" access="global">
    <c:TestComponent />


How to open a new Tab using PageReference in apex class?

We can use apex:commandLink to redirect a visualforce page in a new Tab URL using PageReference in apex class.

Sample Code:

VF Page:

<apex:page controller="SampleleRedirect">
	<apex:form >
		<apex:pageblock >
			<apex:commandlink action="{!redirect}" target="_blank">
				<apex:commandButton value="Open in New Tab"/>

Apex Controller:

public class SampleleRedirect {   

	public SampleleRedirect() {

	public pageReference redirect() {
		PageReference pageRef = new PageReference('');
		return pageRef;

Synchronous and Asynchronous call in Salesforce

In Synchronous process the thread waits for the task to be completed and then moves to the next task Sequentially. All the tasks are completed in a single thread.

Controller Extension
Custom Controller

In Asynchronous call, the thread will not wait until it completes its tasks before proceeding to next. In a Asynchronous call, the tasks are run in different threads all together.

@future Annotation

Types of Sandboxes in

Sandbox is a copy of the production organization. You can create multiple copies of your organization in separate environments for different purposes such as development, testing and training, without compromising the data and applications in your production organization.

Following are the different types of Sandboxes in
Developer Sandbox: A Developer sandbox is intended for development and testing in an isolated environment. A Developer Sandbox includes a copy of your production org’s configuration (metadata).

Developer Pro Sandbox: A Developer Pro sandbox is intended for development and testing in an isolated environment and can host larger data sets than a Developer sandbox. A Developer Pro sandbox includes a copy of your production org’s configuration (metadata). Use a Developer Pro sandbox to handle more development and quality assurance tasks and for integration testing or user training.

Partial Copy Sandbox: A Partial Copy sandbox is intended to be used as a testing environment. This environment includes a copy of your production org’s configuration (metadata) and a sample of your production org’s data as defined by a sandbox template. Use a Partial Copy sandbox for quality assurance tasks such as user acceptance testing, integration testing, and training.

Full Sandbox: A Full sandbox is intended to be used as a testing environment. Only Full sandboxes support performance testing, load testing, and staging. Full sandboxes are a replica of your production org, including all data, such as object records and attachments, and metadata. The length of the refresh interval makes it difficult to use Full sandboxes for development.

Sandboxes Available Per Edition:

Sandbox Type Professional Edition Performance Edition Unlimited Edition Enterprise Edition
Developer Sandbox 10 (change sets not available) 100 100 25
Developer Pro Sandbox 5 5
Partial Copy Sandbox 1 1 1
Full Sandbox 1 1

Note: You can buy more sandboxes for any edition except Developer Sandbox, which is bundled with add-on sandboxes of other types.

Sandbox Feature Quick Reference:

Sandbox Type Refresh Interval Storage Limit What’s Copied Sandbox Templates
Developer Sandbox 1 day Data storage: 200 MB File storage: 200 MB Metadata only Not available
Developer Pro Sandbox 1 day Data storage: 1 GBFile storage: 1 GB Metadata only Not available
Partial Copy Sandbox 5 days Data storage: 5 GBFile storage: 5 GB Metadata and sample data Required
Full Sandbox 29 days Same as your production org Metadata and all data Available