Salesforce Interview Questions with Answers


1. What is Apex
Ans: It is the in-house technology of salesforce.com which is similar to Java programming with object oriented concepts and to write our own custom logic.

2. What is S-Control ?
Ans: S-Controls are the predominant salesforce.com widgets which are completely based on Javascript. These are hosted by salesforce but executed at client side. S-Controls are superseded by Visualforce now.

3. What is a Visualforce Page ?
Ans: Visualforce is the new markup language from salesforce, by using which, We can render the standard styles of salesforce. We can still use HTML here in Visualforce. Each visualforce tag always begins with “apex” namespace. All the design part can be acomplished by using Visualforce Markup Language and the business logic can be written in custom controllers associated with the Page.

4. Will Visual force still supports the merge fields usage like S-control ?
Ans: Yes. Just like S-Controls, Visualforce Pages support embedded merge fields, like the {!$User.FirstName} used in the example.

5. Where to write Visualforce code ?
Ans: You can write the code basically in 3 ways.
  1. setup->App Setup->Develop->Pages and create new Visulaforce page.
  2. Setup -> My Personal Information -> Personal Information -> Edit check the checkbox development mode. When you run the page like this, https://ap1.salesforce.com/apex/MyTestPage. you will find the Page editor at the bottom of the page. You can write you page as well as the controller class associated with it, there it self.
  3. Using EclipseIDE you can create the Visulaforce page and write the code.

6.What are Apex Governor Limits?
Governor limits are runtime limits enforced by the Apex runtime engine. Because Apex runs in a shared, multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that code does not monopolize shared resources. Types of limits that Apex enforces are resources like memory, database resources, number of script statements to avoid infinite loops, and number of records being processed. If code exceeds a limit, the associated governor issues a runtime exception.
10. Do governor limits apply to sandbox instances?
Ans : Governor limits do apply to all Salesforce instances (trial, developer, production or sandbox environments). However code coverage and successful execution of test classes is only enforced when deploying to a production environment.

11. What is difference in ISNULL and ISBLANK?
ISNULL:
  • Determines if an expression is null (blank) and returns TRUE if it is. If it contains a value, this function returns FALSE.
  • Text fields are never null, so using this function with a text field always returns false. For example, the formula field IF(ISNULL(new__c) 1, 0) is always zero regardless of the value in the New field. For text fields, use the ISBLANK function instead.
  • Multi-select picklist fields are never null in s-controls, buttons, and email templates, so using this function with a multi-select picklist field in those contexts always returns false.
  • Empty date and date/time fields always return true when referenced in ISNULL functions.
  • Choose Treat blank fields as blanks for your formula when referencing a number, percent, or currency field in an ISNULL function. Choosing Treat blank fields as zeroes gives blank fields the value of zero so none of them will be null.
  • Merge fields can be handled as blanks, which can affect the results of components like s-controls because they can call this function.
  • When using a validation rule to ensure that a number field contains a specific value, use the ISNULL function to include fields that do not contain any value. For example, to validate that a custom field contains a value of ’1,’ use the following validation rule to display an error if the field is blank or any other number: OR(ISNULL(field__c), field__c<>1)
ISBLANK:
  • Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.
  • Use ISBLANK instead of ISNULL in new formulas. ISBLANK has the same functionality as ISNULL, but also supports text fields. Salesforce.com will continue to support ISNULL, so you do not need to change any existing formulas.
  • A field is not empty if it contains a character, blank space, or zero. For example, a field that contains a space inserted with the spacebar is not empty.
  • Use the BLANKVALUE function to return a specified string if the field does not have a value; use the ISBLANK function if you only want to check if the field has a value.
  • If you use this function with a numeric field, the function only returns TRUE if the field has no value and is not configured to treat blank fields as zeroes.

12. Is it possible to write the Apex code from user Interface?
You can add, edit, or delete Apex using the Salesforce.com user interface only in a Developer Edition organization, a Salesforce.com Enterprise Edition trial organization, or sandbox organization. In a Salesforce.com production organization, you can only make changes to Apex by using the Metadata API ,
deploy
call, the Force.com IDE, or theForce.com Migration Tool. The Force.com IDE and Force.com Migration Tool are free resources provided by salesforce.com to support its users and partners, but are not considered part of our Services for purposes of the salesforce.com Master Subscription Agreement.

13. When you can’t add Time dependent action in Workflow rule?
You can’t add time-dependent actions to a rule if you choose Every time a record is created or edited.


14. What are the types of email templates available in salesforce.com?
  1. Text
  2. HTML with Letter Head
  3. Custom HTML
  4. Visual force
15. What are the different Salesforce.com Editions and Limits?

16. What is Roll up summary field in Salesforce?
Roll up summary field in salesforce calculates the Count, Sum, Min or Max of particular field of any child record. Thus, we can say that Roll up summary field can only be created on Master object. 

17. What will happen if the Account is deleted?
If the Account is deleted then Contact, Opportunity will also be deleted from Salesforce which are related to that Account.
From the database perspective, check below image of child relationships of Account:
Account Child relationship in salesforce
Account Child relationship in salesforce
If we use schema builder, released in Winter 12 it would look like:
Account Contact and Opportunity of salesforce in schema builder
Account Contact and Opportunity of salesforce in schema builder

18. How many types of the relationship fields available in Salesforce?
Ans :
  1. Master Detail
  2. Many to Many
  3. Lookup
  4. Hierarchical (It is available only on User Object, we cannot create this relationship)

19. How to create many to many relationships between object?
Creating many to many relationship in salesforce is little tricky. You cannot create this type of relationship directly. Follow below steps to create this type of relationship.
Create both objects which should be interlinked.
Create one custom object (also called as junction object), which should have autonumber as unique identification and create two master relationships for both objects, no need create tab for this object.
Now on both object, add this field as related list.


Add Chart button is disable on my report screen

Scenario:
   You are creating a new/modifying a report and need to add a chart to the chart but you see the "Add Chart" button is disable... How to enable it? See Screenshot

Solution:
  1. Make sure your report is a summary or matrix report. Tabular will not work.
  2. Make sure you have the report grouped. <== where it states "Drop a field here to create a grouping" See Screenshot




  1. It should have a field there.
  2. Once you do that then Add Chart will get enabled...See Screenshot
Regards,

How to limit which values in a picklist appear depending on record type on Salesforce.com

Scenario:
  You have set up a record type on Salesforce.com for an Object. Now you need to set different picklist values to appear for different record type selections.
Solution:
Very Simple:
  1. Go to Setup | Customize for Standard Objects or Create for Custom Objects | Click on Record types
  2. Then select the record type that you need to change
  3. You'll see a section Picklists Available for Editing
  4. You can specify which values should appear for the record type
See Screenshot for Account object record type:

Validation Rules Using 'AND' 'OR' Functionality Within Salesforce.com

Hi all:
  Scenario:
   Need to write a validation rule if a certain checkbox is check, either one field or another field has to be filled in. So it is one or the other.

Solution:
To utilize And and OR functionality within the Validation rule.

Create these fields on the Account object or substitute your fields.
Discount Applicable | Attribute: Checkbox
Amount: Currency
Percentage: Number (10,2)
Error should appear at top of Page stating: Since Discount Applicable is true then Amount OR Percentage is required.

Go to Setup | Customize | Object (Account) | Validation Rules | New 

Breakdown the validation Rule:
Discount Applicable = True
This is a must to have so it would go under AND requirement.
Amount is blank OR Percentage is Blank. this is the OR part of the validation rule.

Putting it together:
Start off with OR( then place in the AND functionality within the OR functionality), You can see the formula below where I start off with the OR Statement then the Final should always be there...

OR(
AND(ISBLANK(If_Yes_Percentage__c), 
ISBLANK(If_Yes_Amount__c), Is_There_a_Discount_Applicable__c = True))

This is it... Hope this helps..
Thanks

How to use Substring in Apex Code - Force.com

Hi everyone:

Scenario:
We have a string value to be copied from one field in a Standard object to the Custom Object Standard field "Name". Yes you can do this in a formula field but if the objects are not related directly you can not.

So, a little bit about Custom Object regarding the standard field "Name". 
Name field in a custom object its length is 80 MAX. No one can change the attribute on this field to go over 80 length.
So since we are utilizing code to do the update, Apex will not automatically cut off the string if it is more then 80. It will submit an error.

Solution:
We utilized substring method in Apex to accomplish anything more then 80 characters going into the name.
Substring Method - "Returns a new String that begins with the character at the specifiedstartIndex and extends to the character at endIndex - 1." Click Here for more on String Methods

To clarify this, if we have a string such as 'ABC' length is 3 characters. If you place this in a substring and you wanted the first 2 characters, it would be 'ABC'.substring(1,3) = 'AB' ... Make it mathically easier, 3-1=2 which gets you the first 2 characters in your string.

Now the catch in code, you would need utilize the actually name of the field instead of placing it in a string.
String ProdName;

Product2 prod = [ SELECT p.ProductCode, p.Name, p.Id, 
FROM Product2 p 
WHERE p.Id =: oppLineItem.PricebookEntry.Product2Id];
 
if(prod.Name.length()>80){


//This would get the first 90 characters of the string
ProdName = prod.Name.SubString(0,80); customobject__c.Name = prodName; }
I hope this helps... 
A little lesson in code sometime does not hurt anyone.
Thanks

Admins Setup - Salesforce for Outlook 2010 - Create Case & Add Email Functionality

Hi welcome back:
Scenario:
The entire department or company is migrating to Windows 7 and Outlook 2010. But they were utilizing outlook for connect before hand. Which had the bells and whistles of creating a case, add email, and attachments to email with the pop-ups...
Now you need to test, research, and implement the new way but before you can do that you need some guidance to how to teach your self the EASY WAY...

Solution:
   Step 1: Configure your Outlook 2010 for your email.
   Step 2: For Create Case Functionality you must have Email to Case Settings Enabled and setup.
To do so please navigate to:

Setup | App Setup | Customize |  Cases | Email-to-Case

Step 3:  Click on Enable Email-to-Case Checkbox to true. If you like please take the time to enable the other options if you must for your instance. These are org-wide settings, make sure you get a consensus among your peers before you do so.

Click Save.  

Step 4: Set up a Outlook Configuration in Salesforce, if you are doing this as a test then I suggest going into your Sandbox environment so it does not mess with production data.
To set up your Outlook Configuration Navigate to:

Setup | Administration Setup | Desktop Administration | Outlook Configuration

Click on New Outlook Configuration Button
Under "Basic Information" Section:

Create a Name for your Configuration: I will be testing the create case Functionality so my Configuration will be "Create Case"
Click on Active Check-box
Best Practice is to place in a description of the configuration you are creating.

Under "Assign Users and Profiles" Section:
You can add individual users here or drop down Search to Profiles and select profiles.

NOTE: A profile or User can be part of one configuration. Not more then one.
Let's select the System Administrator Profile.

Under "Data Settings" Section:
Click on Add Email Check-box
Click on Create Case Check-box
Once you click on Create Case - you must configure a "Create Case Destination", So lets click on "Create a new case destination" It shall bring up a box that states it will navigate you automatically to the create case destination area where you can set this up but it will save the configuration as well. Click on Save and Continue on the pop-up box.


This will take you to Email-to-Case Routing Information page

Which is under the case section:
Setup | App Setup | Customize |  Cases | Email-to-Case

Under "Routing Information"
Place in a routing Name: Create Case

Under "Email Settings"
Place in any acceptable emails that can come in thru the create case method. Leave this blank right now.

Under "Case Settings"
3 Mandatory fields are here:
Case Owner ==> this can be an individual user or a queue
Case Priority ==> High/Medium/Low
Case Origin ==> Phone/Web/Email/ Anything that you have in there.

You must fill it out before anything and then click save.


 Once you click Save it will take you back to the Outlook Configuration Page where you started.
Navigate to "Data Settings"
Click on Create Case Check-box
Now click on Choose an Existing Create case Destination
Select the Destination method you just created.


Under the Sync Direction for Contacts, Task, and Events lets for now do "Don't Sync"
Click Save.

This would be it for Administrators to set up the user.

Thanks

Easy way of Alphabetizing Salesforce Picklist Values

Scenario:
the business needed to see the picklist values in alphabetically. But there were so many values about 100 of them.

Solution:
Standard Object:
    Go to Setup | App Setup |  Customize | The standard Object | Fields | The Picklist or Multi-select Picklist Field
Custom Object:
    Go to Setup | App Setup |  Create | Object | Fields | The Picklist or Multi-select Picklist Field

Click Reorder button on the Picklist Field under the Picklist Values Section

You shall see a checkbox there "Sort values alphabetically, not in the order entered. Values will be displayed alphabetically everywhere." Then click Save.


Click on it and it shall place the values for you in alphabetical order.


Thanks
Hope this helps