Salesforce Development Interview Questions


 

What is Developer Console?

We can use a developer console to create, debug and test applications in your salesforce organization. Click on your name --> Developer Console.

Debug --> click on Open Execute Anonymous window.

What is Anonymous Block?

Anonymous Block is an Apex code that does not get stored in metadata, but that can be compiled and executed using Developer console, Force.com IDE,

You can use anonymous blocks to quickly evaluate Apex on the fly, such as in Developer console or Force.com IDE.

What is SOQL(Salesforce Object Query language)?

 SOQL retrieves the records from the database by using "SELECT" keyword.

  By using SOQL, we can retrieve the data from single object or from multiple objects that are   related to each other.

  SOQL uses the SELECT statement combined with filtering statements to return sets of data,         which may optionally be recorded.

  SOQL query is enclosed between square brackets.

Ex: Account a = [Select ID, Name from Account where Name = 'acc1'];

Relationship queries

Using relationship queries, we can retrieve the related objects data using the SOQL query.

Parent-to-child and child-to-parent relationships exist between many types of objects.

Child to Parent Relationship:

Contact c = [Select FirstName, LastName, Account.Name, Account.Industry from Contact where id = 'xxxxxxxxxxx'];

System.debug('Account Name:'+ c.Account.Name);

Parent to Child Relationship:

Account a = [Select Name,(Select Contact.FirstName, Contact.LastName from Account.Contacts) from Account where id = 'XXXXXXXXX'];

System.debug('Name:' +a.name);

Primitive DataTypes:

Integer, Double, Long, Date, DateTime, String, ID and Boolean etc.

Boolean: A value that can only be assigned true, false or null

Ex: Boolean Activ = True;

Date: that indicates a particular day. Date value contain no information about time

date dt =  date.newIstance(2014,05,02);

Time and date Time:

Time t = time.newInstance(11,30,3,3); ---> 11:30:03:0003Z

DateTime dt = datetime.Now();

Date dt1 = Date.Today();

Time t = DateTime.now().time();

Date  dt = date.Today(); -- 2014-06-01 00:00:00

Date dt30 = dt.addDays(30); -- 2014-07-01 00:00:00

Integer i=1;

Long L = 2145335687L;

Double d = 3.14159;

Decimal dec = 19.23

Boolean x= null;

Decimal d;

String s1 = 'Salesforce tutorial';

What is trust.salesforce.com?

In trust.salesforce.com, we can find the status of salesforce instances & maintenance status.

Trust.salesforce.com is a community provided by salesforce to know real time status system performance & security.

In this community we can find,

Live & recent system performance data.

Planned maintenance information.

We can know about security details like threats, recent email threats,

best practices & Report suspicious email.

In salesforce, instance starts with NA(Ex: NA0,NA1... etc) represents NorthAmerica Instance, Instance starts with AP(ex:ap0,ap1....) represents APAC(Asia Pacific) and instance starts with EU (Eu0, EU1,.. etc) represents EMEA. We will also find sandbox status in this community. Sandbox instances starts with CS.

If you want to find the instance your salesforce environment, then log into your salesforce account.And refer URL to find the instance.

Packages in salesforce?

A package is a bundle/collection/Container of list of components or related application. We can distribute these package to other salesforce organization and users. There are two types of package.

1. UnManaged Package

2. Managed Package

Unmanaged package: is used to distribute open source applications to provide developers with the basic functionality.we can edit unmanaged package components after installing the unmanaged package in a salesforce organizatin.

The developer who created unmanaged package has no control on installed components, can't edit & can't upgrade.

Managed Package: is used to distribute and sell application to customers. By using the appexchange developers can sell and manage user based licences

Managed packages are fully upgradable.

To ensure seamless upgrades, certain destructive changes, like removing objects or fields, cannot be performed.

Salesforce Collections:

we have 3 types of salesforce collections.

They are

LIST

SET

MAP

List --- Is an ordered collection of elements which will allow duplicates.

List<Datatype> listName =  new list<datatype>();

the data type allows both primitive datatypes and non-primitive datatypes.

Methods in List:

List<String> colors =  new List<String>();

colors.add('Red');

colors.add('White');

          colors.add('Black'); (OR)

List<String> colors= new List<String> {'Red','White','Black'}

string getcolor = colors.get(1);

colors.set(1,'Green');

colors.size();

colors.clear();

Inserting 100 contacts in contacts object.

Public class contactinsertion{

List<contact> contactlist = new list<contact>();

public void methodname(){

for(integer i=0;i<100;i++){

contact cont = new contact(lastname= 'contact'+i);

contlist.add(cont);

}

insert contactList;

}

}

Set ---- Set is an unordered collection of elements which will not allow duplicates.

set<datatype> setName=new set<datatype>();

data types allows only primitive datatypes and SObjects.

we cannot get the retrieve the data based on index because set does not have index.

MAP -- is a key-value pairs.

map<datatype,datatype> mapName = new map<datatype,datatype>(); 

put --> map.put(key,value)

get --> map.get(key);

keyset() -- map.keyset()

values()-- map.values()

size -- map.size()

With Sharing AND Without Sharing?

Use with sharing keywords when declaring a class to enforce the sharing rules that apply to the current user.

Use without sharing keywords when declaring a class to ensure that the sharing rules for the current user are not enforced.

Interface:

An interface is like a class in which none ofthe methods have been implemented -- the method signatures are there, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.

SOSL:

List<LIst<Sobject>> Searchlist = [Find 'map*' IN ALL FIELDS RETURNING Account, Contact];

System.debug(Searchlist);

List<List<Sobject>> searchlist = [Find 'map*' IN ALL FIELDS RETURNING Account(ID,Name),Contact,Opportunity,Lead];

Triggers:

Apex can be invoked through the use od triggers.

A trigger is a functional action which gets fired on particular events.

A trigger is an Apex code that executes before or after the following types of operations.

Insert.... Update..... Delete... Undelete

Triggers can be divided into two types.

1.Before triggers :  Used to update or validate record values before they are saved to database.

2. After Triggers : used to access field values that are set by database and to affect changes in other records.

Trigger Events:

Before insert    Before Update   Before Delete  

After Insert     After Update    After Delete    After Undelete

Before insert triggers are used mainly for validation rules --- Data screening   Data Insert

After insert triggers are used mainly for Workflow rules.

Trigger Syntax:

Trigger triggerName on Object(Events){

            Code Block

 }

Trigger events can be comma separated list of events.

Trigger Context Variables:

Trigger.new

Trigger.Old

Trigger.NewMap

Trigger.OldMap

Trigger.Isafter

Trigger.IsBefore

Trigger.IsInsert

Trigger.IsUpdate

Trigger.IsDelete

Trigger.IsUndelete.

What is Bulk Triggers?

By default all the triggers are bulk triggers and can process multiple records at a time. We should always plan on processing more than one record at a time.

Order of Execution?

It is an order that follows when a particular record is inserted, updated or upserted.The order of execution is in the following order.

1. System Validations.

2. Before triggers.

3. Custom validations

4. Record gets saved to the database, but not yet committed.

5. All after triggers executes

6. Assignment rules

7. Auto-response rules

8. Workflow rules

9. Workflow feld updates, the record is update again.

10. If the record was updated with workflow field update, before and after triggers fire one more time.

11. Escalation rules

12. Commits to database.

Governor Limits in Salesforce :

As apex runs in multitenant environment. The apex runtime engine strictly enforces a number of limits. These limits are call GovernorLimits.

if Some apex code ever exceeds a limit, the associated governor issues a runtime exception that cannot be handled.

Total No.of SOQL queries :100

Total no.of records retrieved :50000

SOSL : 20

Records retrieved by SOSL : 250

DML Statements issued :150

Total no. of methods with Future annotations allowed per Apex :10

Total classes that can be scheduled concurrently :25

What is View State in salesforce?

It is the cache memory that is recorded during the transactions i.e., sending the request and recieving the request.

The view state of the page is composed of all the data that is necessary to maintain the stage of the controller during the server requests(like sending or receiving data). Performance of the page can depend on efficiently managing the view state. The view state tab in the development mode footer provides the information about the view state of your visualforce pages as it interacts with Salesforce.

The view state limit is 135KB.

Note: Minimize number of form on a page.  Use apex:actionRegion instead of using 2 or more forms.

 Refine your SOQL to only retrieve the data needed by the page.

All public and private data members present in Standard, Custom and Controller extensions are saved.

The transient variables are not passed to view state and therefore not stored in View State.

Transient keyword in salesforce:

Use transient keyword to declare instance variables that cannot be saved, and should not be transmitted as part of view state for a visualforce page.

ex: transient Integer total;

Apex Flex Queue:

Submit up to 100 batch jobs simultaneously. This enhancement provides you more flexibility in managing your batch jobs.

Previously, you could submit only up to five batch jobs simultaneously. The Apex flex queue enables you to submit up to 100 batch jobs for execution. Any jobs that are submitted for execution are in holding status and are placed in the Apex flex queue. Up to 100 batch jobs can be in the holding status. When system resources become available, the system picks up jobs from the top of the Apex flex queue and moves them to the batch job queue. The system can process up to five queued or active jobs simultaneously. The status of these moved jobs changes from Holding to Queued.

Navigation:from Setup click Jobs > Apex Flex Queue.

Single Sign-On

Single Sign-On is a process that allows network users to access all authorized network resources without having to separately log in to each resource. Single Sign-On also enables your organization to integrate with an external identity management system or perform web-based single sign-on to Force.com. Single Sign-On enables multiple types of authentication integration, but the most common are:

Use an existing directory of user names and passwords, such as Active Directory or LDAP, for Salesforce users

Allow seamless sign-on to Force.com applications, eliminating the need for explicit user log on actions

What is an annotation?

Annotatins are defined with an initial @ Symbol, followed by the appropriate keyword.

To add an annotatin to a method, specify it immediately before the method or class definition.

@Deprecated

@Future

@Istest

@Read-only

@RemoteAction

@Deprecated Use the deprecated to identify methods classes, exceptions, enums, interfaces or variables that can no longer be referenced in subsequent releases of the managed package.

This is useful when we are refactoring the in managed package.

syntax:@Deprecated

public void methodname(String a){}

Unamanaged packages cannot conain code that uses the deprecated keyword.

Future Annotation:

Use the future annotation to identify methods that are executed asynchronously.

When we specify @future, method executes when salesforce had available resources.

Methods with future annotation must be static methods and can only return a void type.

To make a method in a class execute asynchronously define the method with the future annotation.

Methods with the future annotation must be static methods, and can only return a void type. The specified parameters must be primitive data types, arrays of primitive data types, or collections of primitive data types. Methods with the future annotation cannot take sObjects or objects as arguments.

@IsTest Annotatioin:

Use the istest annotation to define classes or individual methods that only contain code used for testing application. The istest annotation is similiar to creating methods declared a testmethod.

Classes defined with the istest annotation do not count against organization limit of 2MB for all apex code individual methods defined with the istest annotation do count against organization limits.

Classes and methdos defined as istest can be either private or public classes defined as istest must be top leve classses

Syntax:@Istest

public class testclassnaem{

            static testmethod void methodname(){

            // Apex code

            }

            static testmethod void methodname2(){

            // Apex code

            }

}

What to test in APex:

Single record

Bulk records

Positive scenarios

Negative scenarios

Restricted user.

What is a recursive trigger?

A recursive trigger is a trigger which makes a record to create/update and that record will inturn makes the trigger to fire again is called a Recursive trigger.

We can stop this Recursive trigger by using Static keyword for the Methods.

Batch Apex:

To use Batch Apex, we must write an Apex class that implements the salesforce provided interface Database.Batchable and then invoke the class programatically.

The database.batchable interface contains three methods that must be implemented.

  • Start method
  • Execute method
  • Finish Method

Start method:

The start method is called at the beginning of a batch apex job.

use the start method to collect the records or objects to be passed to the interface method execute.

This method returns either a Database.QueryLocator object or an iterable that contains the records or objects being passed into the job.

Use the Database.QueryLocator object when we are using a simple query(SELECT) to generate the scope of objects used in the batch job. If we use a query locator object, the governor limit for the total number of records retrieved by SOQL queries is bypassed. It allows upto 50Million records.

global Database.QueryLocator Start(Database.BatchableContext BC)

Execute method:

The execute method is called for each batch of records passed to the method. Use this method to do all required processing for each chunk of data.

his method takes the following.

A reference to the Database.Batchablecontext object.

A list of sobject records such as List<Sobject>

Global void execute(Database.batchablecontext BC, List<P>)

Finish method:

The finish method is called after all the batches processed. Use this method to send confirmation emails or execute post processing operations.

global void finish(Database.BatchableContext BC){}

Execution in Developer Console:

BatchClassName b = new BatchClassName();

database.executeBatch(b);

Schedule Apex:

Apex Scheduler is helpful to invoke apex classes to run at specific times, first implement the "Schedulable" interface for the class then specify the schedule using either the schedule apex page in the salesforce user interfaces or the system schedule method.

global void execute(){

}

Note :Salesforce only adds the process to the queue at the scheduled time actual execution may be delayed based on service availability.

Two ways to schedule a Schedule apex

1. Apex classes --> Schedule Apex

2. Scheduling in ScheduleApex.

System.schedule(instance of schedule Apex).

Using S-controls for UI(User Interfacing)

The tool that allows application developers to display custom links(HTML) in a detail page or custom tab. this provides more flexibility for the fields and page layouts.

But,Executes from within a browserm causing poor performance if displaying or updating values for more than a few records at a time.

Note:S coontrols are suppressed by vf pages. After March 2010 organizations that have never created S-controls as well as new organization. won't be allowed ot create them.

Existing S-controls will remail and can still be edited.

What are trigger best practices?

Trigger best practices include below things

1.  Avoid DML, SOQLs in for loops

2.  Have one trigger per object

3.  Have a helper class to hold the logic of the trigger

4.  Avoid recursion

What are the difference between 15 digit id and 18 digit id?

Difference between 15 digit ID and 18 digit ID is,

15 digit id is case sensitive

18 digit id is case insensitive

Last 3 characters of the 18 digit id represent the checksum of the capitalization of the first 15 digits.

What is traction workbench in salesforce?

Traction workbench is a salesforce feature for implementing the language in multiple languages. i.e not just the data but also all your configurations and customizations that you do as part of the implementation.

Can I have custom development within the Salesforce.com platform?

Yes, there are a number of different programming solutions available depending on the type of development required. There is the FORCE.COM development environment and typically Apex and Java languages that can be used.

Can I integrate my email from Outlook or other mail solutions?

Yes, there are a number of standard off the shelf tools that allow emails and contact information to be synchronized with data in Salesforce.com

Where is my data being stored?

Depending on your geographical location, Salesforce.com will store your data in a number of hosted facilities in North America, Europe or the Asia Pacific.

Are there Apps that perform different functions and services in Salesforce.com?

Yes, Salesforce has its own marketplace with currently over 1500 cloud computing and business applications to download and install.

Whatis the difference between Customer portal and Partner portal?

Traditionally Partner Portal is part of companies Partner Channel Sales efforts.

What are the Action components in vf page ?

apex:actionFunction> : A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request/

apex:action Status>: This component is used for displaying different values depending on whether the process is in progressing or completed

apex:actionSupport>: A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouse over.

apex:actionPoller>: this component specifies a timer that sends an Ajax update request to Force.com according to a time interval that we specify.

How can we query Acrticle?

SELECT Title, Summary FROM KnowledgeArticleVersion WHERE PublishStatus='Online' AND Language = 'en_US' WITH DATA CATEGORY Geography__c ABOVE_OR_BELOW europe__c AND Product__c BELOW All__c

SELECT Id FROM KnowledgeArticleVersion WHERE PublishStatus='Archived' AND IsLatestVersion=false AND KnowledgeArticleId='kA1D00000001PQ6KAM'

Rest Integration description

Account Management System.

It is a kind of validating data between SFDC and ODS.

Our business is doing their sales applications using Salesforce Account management.

It(PSL Limited) has its own ODS system.

ODS means Overall Database storage System.

User will have a custome Visual force page to enter the address info related to Account.

Then he has to click on button. That button will initiate the call out to ODS System.

This call will invoke ODS Service. ODS will take Address info from Salesforce and validate.After validation the user may proceed for creation of Account.

Email Service:

An Apex class that acts as an inbound email handler simply needs to implement the Messaging.InboundEmailHandler interface. The interface defines a single method:

The message contents are available through the email argument, and the envelope stores the to and from address.

Here is an example that shows how you can use these objects to access different fields in the incoming email. This class processes incoming email as follows:

 Create a new Account record with the email subject as the account name

Generate contacts based on the names on the cc-list

Save the text and binary attachments Store the email body as a note



 

Post a Comment

0 Comments