Apex Interview Questions Answers And Tutorial

266. What is apex scheduler?

Apex scheduler is used 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 interface, or the System.schedule method.

The Schedulable interface contains one method that must be implemented, execute.
global void execute(SchedulableContext sc){}
The implemented method must be declared as global or public.

The following example implements the Schedulable interface for a class called mergeNumbers:
global class scheduledMerge implements Schedulable{
global void execute(SchedulableContext SC) {
mergeNumbers M = new mergeNumbers();
   }
}
The following example uses the System.Schedule method to implement the above class.
scheduledMerge m = new scheduledMerge();
        String sch = '20 30 8 10 2 ?';
system.schedule('Merge Job', sch, m);
You can also use the Schedulable interface with batch Apex classes. The following example implements the Schedulable interface for a batch Apex class called batchable:
global class scheduledBatchable implements Schedulable{
global void execute(SchedulableContext sc) {
batchable b = new batchable();
database.executebatch(b);
   }
}

Use the SchedulableContext object to keep track of the scheduled job once it's scheduled. The SchedulableContext method getTriggerID returns the ID of the CronTrigger object associated with this scheduled job as a string. Use this method to track the progress of the scheduled job.
To stop execution of a job that was scheduled, use the System.abortJob method with the ID returned by the.getTriggerID method.



267. Write a syntax and structure of scheduler class?

Sample class

global class ScheduleDemo implements Schedulable{
            global void execute(SchedulableContext sc){
                        BatchClass b = new BatchClass();
                        database.executeBatch(b);
}
}


268. What is Scheduler class in Apex?

The Apex class which is programmed to run at pre defined interval.
Class must implement schedulable interface and it contains method named execute().
There are two ways to invoke scheduler:

1.     Using UI
2.     Using System.schedule (Schedule method of System class)
The classes which implements interface schedulable get the button texted with “Schedule”, when user clicks on that button; new interface opens to schedule the classes which implements that interface.


To see what happened to scheduled job, go to “Monitoring | Scheduled jobs “
Example of scheduling:
scheduledMerge m = new scheduledMerge();
String sch = '20 30 8 10 2 ?';
system.schedule('Merge Job', sch, m);

Here:
20 represents seconds
30 represents minutes
8 represents hour of the day
10 represents 10th day of month
2 represents month of the year
? represents day of the month

269. Write a apex code to send a email?

Sample code snippet to send an email using apex code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{‘talk2srikrishna@gmail.com’};
mail.setToAddress(toAddresses);
mail.setSubject(‘Sample Mail Subject’);
mail.setPlainTextBody(‘Hello World!’);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});

270. What are the aggregate functions supported by salesforce SOQL?

Following aggregate functions are supported by salesforce SOQL
1.     SUM()
2.     MIN()
3.     MAX()
4.     COUNT()
5.     AVG()
6.     COUNT_DISTINCT()

271. Write a sample aggregate query or explain how to write a aggregate queries?

The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];
Object avgAmt = ar[0].get(‘aver’);

272. Write a code to find the average Amount for all your opportunities by campaign?

AggregateResult[] arList = [select CampaignId, AVG(amount) from Opportunity group by CampaignId];
for(AggregateResult ar : arList){
            System.debug(‘CampaignId ’ + ar.get(‘CampaignId’));
            System.debug(‘Average Amount’ + ar.get(‘expr0’));

}

273. What are email services in salesforce and explain how we can use them in code?

Email services are automated processes that use apex class to process the contents, headers and attachment of an inbound email.

Sample code

Use Case: create a contact record if the inbound email subject is Create Contact and body contains contact name

global CreateContactFromEmail implements Messaging.InboundEmailHandler{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelop envelop){
            Messaging.InboundEmailResult res = new Messaging.InboundEmailResult();
            String strToCompare = ‘Create Contact’;
            If(email.subject.equalsIgnoreCase(strToCompare)){
                        Contact c = new Contact();
                        c.LastName = email.plainTextBody();
                        insert c;
                       
                        //save text attachments

for(Messaging.InboundEmail.TextAttachment att : email.textAttachments){
            Attachment a = new Attachment();
            a.Name = att.fileName;
            a.Body = att.Blob.valueOf(att.Body);
            a.ParentId = c.Id;
            insert attachment;
}
                       
//save binary attachments

for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
            Attachment attachment = new Attachment();
            attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
            attachment.ParentId = c.Id;
insert attachment;
}
}
res.Success = true;
return res;
}
}


274. What is the row limit for apex:dataTable and apex:pageBlockTable?

The data set for both apex:dataTable and apex:pageBlockTable can have up to 1000 items.

275. What is the difference between apex:pageMessages, apex:pageMessage, apex:Message and apex:Messages?

apex:PageMessages:

This component displays all messages that were generated for all components on the current page, presented using the salesforce styling. This will display both salesforce generated messages as well as custom messages added to the ApexPages class 

apex:PageMessage:

Apex:PageMessage is a component that adds single message on the page. This is used to display custom message using the salesforce formatting

apex:Message:

apex:Message is used to display an error on only a specific field. It is used to allow developers to place field specific errors in specific location.

apex:Messages:

apex:Messages is similar to apex:Message but it displays all errors


276. How can we hard delete a record using a Apex class/by code?

ALL ROWS key word can be used to get all the records including records in the recycle bin.
Below is the sample code to delete contact records from recycle bin

List<Contact> dContactList=[Select ID From Contact Where IsDeleted = true limit 199 ALL ROWS];
Database.emptyRecycleBin( dContactList );

278. Write a syntax and structure of batch class?

Sample class

global Class BatchDemo implements Database.Batchable<sObject>{

global Database.QueryLocator start(Database.BatchableContext bc){
            return Database.getQueryLocator(query);
}

global void execute(Database.BachableContext bc, List<sObjects> scope){
           
}

global void finish(Database.BachableContext bc){
                       
}
}

Below code will call the batch class

BatchDemo bd = new BatchDemo();
database.executebatch(bd);

279. What is batch apex?

Batch Apex is exposed as an interface that must be implemented by the developer. Batch jobs can be programmatically invoked at runtime using Apex.

Need of Batch Apex: - As you all might know about the salesforce governor limits on its data. When you want to fetch thousands of records or fire DML on thousands of rows on objects it is very complex in salesforce and it does not allow you to operate on more than certain number of records which satisfies the Governor limits.
But for medium to large enterprises, it is essential to manage thousands of records every day. Adding/editing/deleting them when needed.

Salesforce has come up with a powerful concept called Batch Apex. Batch Apex allows you to handle more number of records and manipulate them by using a specific syntax.
We have to create a global apex class which extends Database.Batchable Interface because of which the salesforce compiler will know, this class incorporates batch jobs. Below is a sample class which is designed to delete all the records of Account object (Lets say your organization contains more than 50 thousand records and you want to mass delete all of them).

Examples:-
global class deleteAccounts implements Database.Batchable
{
global final String Query;
global deleteAccounts(String q)
{
Query=q;
}

global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC,List scope)
{
List <Account> lstAccount = new list<Account>();
for(Sobject s : scope)
{
 Account a = (Account)s;
lstAccount.add(a);
}
Delete lstAccount;
}

global void finish(Database.BatchableContext BC)
{
                //Send an email to the User after your batch completes
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {‘sforce2009@gmail.com’};
mail.setToAddresses(toAddresses);
mail.setSubject('Apex Batch Job is done‘);
mail.setPlainTextBody('The batch Apex job processed ');
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}

//This is how the batch class is called.
id batchinstanceid = database.executeBatch(new deleteAccounts(‘select Id from Account’));

280. What are web service callouts?

Apex Code supports the ability to expose Apex methods as a Web service. Apex also supports the ability to invoke external web services and this will refer to as 'Callouts.' The former is involved in creating a web service that a client can invoke, while the latter is invoking an external web service.

281. What are wrapper classes?

A wrapper or container class is a class, a data structure, or an abstract data type whose instances are collections of other objects.

282. How do you hide header and sidebar on visualforce page?

Below is the code to hide sidebar and header

<apex:page showHeader="false" sidebar="false">

</apex:page>

283. What is the difference between standard and custom controller?

The standard controller is auto generated by SF for all objects.

Custom controllers are written by you and do what your code tells them to do.

284. How do you read parameter in visualforce page?

Below syntax can be used to read parameters in visualforce page

<apex:inputField value="{!$CurrentPage.parameters.Paramtervalue}"/>

Additional code:

If you're writing a custom controller, use the ApexPages global object variable and currentPage() and getParameters() methods to get query string parameters. For example, to get the value of the name query parameter in the URL: https://na1.salesforce.com/001/e?name=value, use the following line in your custom controller:
String value = ApexPages.currentPage().getParameters().get('name');
·If you're editing a page, use the $PageContext global variable in a merge field.
For example, suppose you want to add the Open Activities related list to an account detail page, but instead of showing the account's activities, you want to show the activities of a specified contact. To specify the contact, the following page looks for a query string parameter for the contact's ID under the name relatedId:
<apex:page standardController="Account">
<apex:pageBlock title="Hello {!$User.FirstName}!">
        You belong to the {!account.name} account.<br/>
        You're also a nice person.
</apex:pageBlock>
<apex:detail subject="{!account}" relatedList="false"/>
<apex:relatedList list="OpenActivities"
                   subject="{!$CurrentPage.parameters.relatedId}"/>
</apex:page>
For this related list to render in a saved page, valid account and contact IDs must be specified in the URL. For example, if 001D000000HRgU6 is the account ID and 003D000000OXDIx is the contact ID, use the URLhttps://na3.salesforce.com/apex/MyFirstPage?id=001D000000HRgU6& relatedId=003D000000OXDIx.
To set a query string parameter:
·       If you're writing a custom controller, use the setParameters() method with ApexPages.currentPage() to add a query parameter in a test method. For example:
String key = 'name';
String value = 'Caroline';
ApexPages.currentPage().setParameters().put(key, value);
Note
The setParameters() method is only valid inside test methods.
·       If you're editing a page, you can either construct a URL manually:
<apex:outputLink value="http://google.com/search?q={!account.name}">
    Search Google
</apex:outputLink>
Or you can use the <apex:param> tag as a child tag to write cleaner code:
<apex:outputLink value="http://google.com/search">
    Search Google
<apex:param name="q" value="{!account.name}"/>
</apex:outputLink>


285. How can we pass javascript variable to apex class?

VF Page (Use assign input variable to VF using $Component.FieldId)

<apex:page controller="Js_Test_Class">
<apex:form>
<script>
            function setVal()
            {
            document.getElementById("{!$Component.hdnField}").value = "TestValue";
            }
</script>
<apex:inputHidden id="hdnField" value="{!theValue}" />
<apex:commandButton value="Post Page" action="{!post}" />
</apex:form>
<script>
setVal();
</script>
</apex:page>

Controller (Declare setter and getter for the variable being used in VF page)
public class Js_Test_Class {
            public String theValue { get;set;}
public void post() {
System.Debug('The value is : ' + theValue);
    }
}

286. Is it possible to call apex method in javascript code? If yes, explain?

Yes, we can call apex methods using javascript. We can achieve this using ActionFunction. ActionFunction allow you to tie an apex method to a javascript function name and invoke synchronously. ActionFunction must be a child of apex:form component.

Example VF Page

<apex:page controller="t">
<script>
function myJavascriptFunc()
    {
alert('Entered Javascript') ;
CallApexMethod() ;
    }
</script>
<apex:form >
<apex:actionFunction name="CallApexMethod" action="{!myActionInController}" onComplete="alert('After apex method') ;"/>
<apex:pageBlock >
<apex:pageBlockButtons>
<apex:commandButton value="Hit Me" onclick="myJavascriptFunc() ;"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Example Controller

public class t
public PageReference myActionInController(){
return null ;
    }
}

287. What is commandLink? Explain the usage?

CommandLink is a link that executes an action defined by a controller, and then refreshes the current page or navigate to the different page based on the PageReference variable that is returned by the action.
commandLink component must be a child of an form component.

Example:
<apex:commandLink action=”{!save}” value=”Save” id=”theCommandLink”/>

288. What is outputLink? Explain the usage?

OutputLink is a link to URL. This component is rendered in HTML as an anchor tag with an href attribute. The body of the OutputLink is a text or image that displays as the link

Example:
<apex:outputLink value=”http://www.google.com” id=”theLink”>www.google.com</outputLink>

289. How to get URL parameters in Visuaforce page?

If the URL is something link this
https://<salesforce instance>/apex/getQueryStringParam?id=001d000000B1Gj5&cid=003d000000BIjFh
and if we want to read cid in our visualforce page then,

Use: $CurrentPage.parameters.cid
Or
If there is a single parameter in the URL string link this
https://xxx.visual.force.com/apex/NewPage?TestValue=value1&retURL=a0HS000000450UD

Then Use:
$CurrentPage.parameters.Paramtervalue

290. How to set URL parameters in Visuaforce page?

Setting a Query String parameter can be achieved by two ways.

One:
Construct a URL manually like,
<apex:outputLink value="http://google.com/search?q={!account.name}">
    Search Google
</apex:outputLink>

Two
<apex:outputLink value="http://google.com/search">
    Search Google
<apex:param name="q" value="{!account.name}"/>
</apex:outputLink>

291. How to get URL parameters in APEX class?

If the URL is something link this
https://<salesforce instance>/apex/getQueryStringParam?id=001d000000B1Gj5&cid=003d000000BIjFh
And if we want to read cid in our visualforce page then,

Use:
String id = ApexPages.currentPage().getParameters().get('id');
String id = ApexPages.currentPage().getParameters().get('cid');

292. How to set URL parameters in APEX class?

To set a URL parameter using Apex code use below syntax

String key = 'name';
String value = 'Caroline';
ApexPages.currentPage().getParameters().put(key, value);

Or

ApexPages.currentPage().getParameters().set(‘value’);


293. Explain how MVC architecture fit for Salesforce?

In salesforce, Apex Classes works as Controllers, Visualforce Pages works as View and Custom objects works as Model.
294. How to use actionFunction, actionSupport and actionPollar in salesforce?

actionFunction : provides support for invoking controller action methods directly from JavaScript code using an AJAXrequest

Used when we need to perform similar action on various events. Even though, you can use it in place of actionSupport as well where only event is related to only one control.

Example:
actionFunction: provides support for invoking controller action methods directly from JavaScript code using an AJAXrequest

Example :
<!-- Page: -->
<apex:page controller="exampleCon">
<apex:form>
<!-- Define the JavaScript function sayHello-->
<apex:actionFunction name="sayHello" action="{!sayHello}" rerender="out"
status="myStatus"/>
</apex:form>
<apex:outputPanel id="out">
<apex:outputText value="Hello "/>
<apex:actionStatus startText="requesting..." id="myStatus">
<apex:facet name="stop">{!username}</apex:facet>
</apex:actionStatus>
</apex:outputPanel>
<!-- Call the sayHello JavaScript function using a script element-->
<script>window.setTimeout(sayHello,2000)</script>
<p><apex:outputText value="Clicked? {!state}" id="showstate" /></p>
<!-- Add the onclick event listener to a panel. When clicked, the panel triggers
the methodOneInJavascript actionFunction with a param -->
<apex:outputPanel onclick="methodOneInJavascript('Yes!')" styleClass="btn">
Click Me
</apex:outputPanel>
<apex:form>
<apex:actionFunction action="{!methodOne}" name="methodOneInJavascript"
rerender="showstate">
<apex:param name="firstParam" assignTo="{!state}" value="" />
</apex:actionFunction>
</apex:form>
</apex:page>

/*** Controller ***/
public class exampleCon {
String uname;
public String getUsername() {
return uname;
}
public PageReference sayHello() {
uname = UserInfo.getName();
return null;
}
public void setState(String n) {
state = n;
}
public String getState() {
return state;
}
public PageReference methodOne() {
return null;
}
private String state = 'no';
}

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 mouseover.

Used when we want to perform an action on a particular event of any control like onchange of any text box or picklist.

Example:
<!-- Page: -->
<apex:page controller="exampleCon">
<apex:form>
<apex:outputpanel id="counter">
<apex:outputText value="Click Me!: {!count}"/>
<apex:actionSupport event="onclick"
action="{!incrementCounter}"
rerender="counter" status="counterStatus"/>
</apex:outputpanel>
<apex:actionStatus id="counterStatus"
startText=" (incrementing...)"
stopText=" (done)"/>
</apex:form>
</apex:page>


/*** Controller: ***/
public class exampleCon {
Integer count = 0;
public PageReference incrementCounter() {
count++;
return null;
}
public Integer getCount() {
return count;
}
}

 ActionPolor: A timer that sends an AJAX update request to the server according to a time interval that you specify. The update request can then result in a full or partial page update. You should avoid using this component with enhanced lists.

Used when we want to perform an action on server again and again for a particular time interval. 

Example:
<!-- Page -->
<apex:page controller="exampleCon">
<apex:form>
<apex:outputText value="Watch this counter: {!count}" id="counter"/>
<apex:actionPoller action="{!incrementCounter}" rerender="counter" interval="15"/>
</apex:form>
</apex:page>
/*** Controller: ***/
public class exampleCon {
Integer count = 0;
public PageReference incrementCounter() {
count++;
return null;
}






295. What is the difference between actionFunction and actionSupport tags?


Sl No

ActionSupport

ActionFunction
1)
Directly call action method without javascript
Call action method from javascript with AJAX
2)
It can be used to call action method on  single event
It can be used to call action method on different event
3)
It cannot be called from javascript function. It only invoke controller action methods from other Visualforce components
It defines a new JavaScript function which can then be called from within a block of JavaScript code.

296. How do you do File Upload using visualforce?

Below is the code sample of file upload in visualforce

<!-- Upload a file and put it in your personal documents folder-->

<!-- Page: -->

<apex:page standardController="Document" extensions="documentExt">
<apex:messages />
<apex:form id="theForm">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:inputFile value="{!document.body}" filename="{!document.name}"/>
<apex:commandButton value="Save" action="{!save}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

/*** Controller ***/
public class documentExt {
public documentExt(ApexPages.StandardController controller) {
        Document d = (Document) controller.getRecord();
        d.folderid = UserInfo.getUserId(); //this puts it in My Personal Documents
    }                
}

298. Explain Apex Data Types

Apex primitive data types include
• String
• Blob (for storing binary data)
• Boolean
• Date, DateTime and Time
• Integer, Long, Decimal, Double
• ID (Force.com database record identifier)


 Example:
• DateTime dt = System.now() + 1;
• Boolean isClosed = true;
• String sCapsFirstName = ‘Andrew’.toUpperCase();

Apex sObject Types
Sobject (object representing a Force.com standard or custom object)


Example:
• Account acct = new Account(); //Sobject example

Apex has the following types of collections
• Lists
• Maps
• Sets


Example:
• List myList = new List();
• myList.add(12); //Add the number 12 to the list
• myList.get(0); //Access to first integer stored in the List
Enums
• Enum (or enumerated list) is an abstract that stores one value of a finite set of specified identifiers.
• To define an Enum, use enum keyword in the variable declaration and then define the list of values.
• By creating this Enum, you have created a new data type called Season that can be used as any other data type.


Example:
• public enum Season {WINTER, SPRING, SUMMER, FALL}

299. Explain Apex Variables?

Local variables are declared with Java-style syntax.
For example:
• Integer i = 0;
• String str;
• Account a;
• Account[] accts;
• Set s;
• Map<ID, Account> m;

300. Explain Static Methods and Variables?

• Class methods and variables can be declared as static. Without this keyword, the default is to create instance methods and variables.
• Static methods are accessed through the class itself, not through an object of the class:

Example:
public class blogReaders {
public static boolean firstScript = false;
}

• Static methods are generally utility methods that do not depend on an instance. System methods are static.
• Use static variables to store data that is shared with in the class.
• All instances of the same class share a single copy of static variables.
• This can be a technique used for setting flags to prevent recursive


Wrapper Class With Example in Apex Salesforce

Wrapper Class in Apex Salesforce:
Wrapper class is collections of different data type, subject etc.

In following example  we are  bind Account ,Opportunity standard object. We query and perform

business logic on the Collection of elements across unrelated objects with the custom data type.


Visual Force Page:

<apex:page controller="wrapperDemoCtrl">

<apex:pageBlock title="Account From wrapper  Class">

   <apex:pageBlockTable value="{!wraccount}" var="wra">

   <apex:column value="{!wra.acc.Name}"/>

   </apex:pageBlockTable>

</apex:pageBlock>

<apex:pageBlock title="Opportunity From wrapper  Class">

   <apex:pageBlockTable value="{!wraoppn}" var="wropp">

   <apex:column value="{!wropp.op.Name}"/>

   </apex:pageBlockTable>

</apex:pageBlock>


</apex:page>

Controller :

public class wrapperDemoCtrl {

    public list<wrapperClass> wraplist{get;set;}
   
    public list<wrapperClass> getwraccount()
          {
            list<Account>acclist=[select Id,Name from Account limit 3];
            wraplist= new list<wrapperClass>();
            for(Account acn: acclist)
            {
            wraplist.add(new wrapperClass(acn));
            }
           return wraplist;
          }
    public list<wrapperClass> getwraoppn()
        {
         list<Opportunity>opplist=[select Id,Name from Opportunity limit 3];
         wraplist= new list<wrapperClass>();
         for(Opportunity opn:opplist )
         {
         wraplist.add(new wrapperClass(opn));
         }
         return wraplist;
        }
   
    public class wrapperClass{
   
        public Account acc {get;set;}
        public Opportunity op {get;set;}
       
        public wrapperClass(Account accn){
       
                 acc= accn;        
                     }
       public wrapperClass(Opportunity opn)
       {
         op=opn;
     
       }
    }
}

Salesforce Post Refresh Considerations Apex Scheduler Syntax and Send a Email Code


246. Write a syntax and structure of scheduler class?
Sample class

global class ScheduleDemo implements Schedulable{
    global void execute(SchedulableContext sc){
        BatchClass b = new BatchClass();
        database.executeBatch(b);
}
}

247. Write a apex code to send a email?

Sample code snippet to send an email using apex code

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{‘talk2srikrishna@gmail.com’};
mail.setToAddress(toAddresses);
mail.setSubject(‘Sample Mail Subject’);
mail.setPlainTextBody(‘Hello World!’);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});


248. What are the aggregate functions supported by salesforce SOQL?
Following aggregate functions are supported by salesforce SOQL
1.     SUM()
2.     MIN()
3.     MAX()
4.     COUNT()
5.     AVG()
6.     COUNT_DISTINCT()

249. Write a sample aggregate query or explain how to write a aggregate queries?
The return types of Aggregate functions are always an array of AggregateResult.

Sample Code

AggregateResult[] ar = [select AVG(Amount) aver from Opportunity];
Object avgAmt = ar[0].get(‘aver’);

250. Write a code to find the average Amount for all your opportunities by campaign?

AggregateResult[] arList = [select CampaignId, AVG(amount) from Opportunity group by CampaignId];
for(AggregateResult ar : arList){
    System.debug(‘CampaignId ’ + ar.get(‘CampaignId’));
    System.debug(‘Average Amount’ + ar.get(‘expr0’));

}

251. What are email services in salesforce and explain how we can use them in code?
Email services are automated processes that use apex class to process the contents, headers and attachment of an inbound email.

Sample code

Use Case: create a contact record if the inbound email subject is Create Contact and body contains contact name

global CreateContactFromEmail implements Messaging.InboundEmailHandler{
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelop envelop){
    Messaging.InboundEmailResult res = new Messaging.InboundEmailResult();
    String strToCompare = ‘Create Contact’;
    If(email.subject.equalsIgnoreCase(strToCompare)){
        Contact c = new Contact();
        c.LastName = email.plainTextBody();
        insert c;
       
        //save text attachments

for(Messaging.InboundEmail.TextAttachment att : email.textAttachments){
    Attachment a = new Attachment();
    a.Name = att.fileName;
    a.Body = att.Blob.valueOf(att.Body);
    a.ParentId = c.Id;
    insert attachment;
}
       
//save binary attachments

for (Messaging.Inboundemail.BinaryAttachment bAttachment : email.binaryAttachments) {
            Attachment attachment = new Attachment();
            attachment.Name = bAttachment.fileName;
            attachment.Body = bAttachment.body;
            attachment.ParentId = c.Id;
            insert attachment;
}
}
res.Success = true;
return res;
}
}

252. What is the relationship between Contact and Account objects in salesforce?
In Salesforce, Contacts is having a look up relationship with Accounts i.e., Simple relationship

253. What are different Organization Wide Defaults? Explain each of them?
Below are the different OWD values

Private
    If the OWD for an object is set to private, then only the owner, and users above that role in role hierarchy, can view, edit and report on those records

Public Read Only
    If the OWD for an object is set to Public Read Only, then all users can view and report on records but they cannot edit them. Only the record owner and the users above that role in the role hierarchy can edit the records

Public Read/Write
If the OWD for an object is set to Public Read/Write, then all users can view, edit and report on all records. But only owner of the record can delete the records.

Public Read/Write/Trfer
This is available only for Case and Lead objects
If the OWD for an object is set to Public Read/Write/Trfer then, all users can view, edit, trfer and report on all the records but only owner of the record can delete the records

Public Full Access
This is available only for Campaign object.
If the OWD for Campaigns are set Public Full Access then, all users can view, edit, delete and report on all records.

No Access, View Only or Use
This is available only for Price Book object.

If the OWD for Price Book is set Use then, all users can access the Price Book information and as well as using the Price Book configuration for Opportunities with Products.


If the OWD for Price Book is set View Only then, all users can access the Price Book information but not to use that Price Book detail in Opportunities with Products

If the OWD for Price Book is set No Access then, it restricts users from accessing information for Price Book and Prices.

Controlled By Parent
If the OWD for any object is set as Controlled By Parent, then user can perform an action on the record based on whether they can do the same on the parent record associated with it

254. Is it mandatory to select User License while creating permission sets? If not, what is the significance of selecting a User License?
It is not mandatory to select a User License while creating a permission sets.
If users with one type of license will use this permission set, then choose the same license that’s associate with them.
If you are planning to assign this permission set to multiple users with different licenses then, choose none.

255. Can we create a new profile without cloning an existing profiles?

No, we have to clone any one of the existing profiles to create a new profile


256. Please explain the use of Grant Access Using Hierarchies?

In Sharing settings, OWD settings, we have a check box Grant Access Using Hierarchies (for both standard and custom objects). If this check box is checked then it will give automatic access to the user’s data to other users in higher role of salesforce CRM Role Hierarchy.
If this check box is not checked then, only record owner and users granted access by OWD can gain the access.

257. What is the batch size limit (increment size for batch) in Data Loader?

Data Loader batch size limit is maximum of 200 per increment and if we selected Use Bulk API then maximum value is 10000

258. What is the difference between Export and Export All in the context of Data Loader?


Export enables user to export all the records for a particular object excluding the records in the recycle bin or soft deleted records.
Export All enables user to export all the records for a particular object including the records in the recycle bin or soft deleted records.

259. What are the post refresh considerations?


1.     New Organization ID is assigned to the refreshed sandbox every time it is refreshed. Hence we need to replace the hard coded organization id in our sandbox post refresh with newly created organization id.
2.     To ensure the uniqueness, in all user records, user name will be appended by sandbox name, if the resulting user name is not unique then, second round of modification is performed to prepend the user name with alpa numeric string to make sure the resulting username is unique.
3.     The copy process does not copy contact data to developer and configuration sandboxes. Therefore, customer portal users are not copied. These customer portal users need to be created manually on need basis.
4.     User email addresses are modified in sandbox to avoid sending any mail from sandbox such as notifications triggered by workflows and escalations rules.
5.     Newly created sandboxes have the default email deliverability setting System email only. We need to change this to All Email.
6.     If Server URL is hardcoded in the code, then we need to replace it with the newly created URL

260. What is the storage limit of Full Copy, Configuration Only and Developer sandboxes?
Full Copy Sandbox has the same storage limit as your production organization
Configuration Only sandbox has the storage limit of 500MB
Developer Sandbox has the storage limit of 10MB

261. What is the interval of refreshing of Full Copy, Configuration Only and Developer sandboxes?

Full Copy Sandbox can be refreshed once in 29 days
Configuration Sandbox can be refreshed once per day
Developer Sandbox can be refreshed once per day

262. What are the default sharing settings?

Default sharing settings are as follows
1.     Controlled By Parent
2.     Private
3.     Public Read Only
4.     Public ReadWrite
5.     Public Read/Write/Trfer (Only for Case and Lead objects)
6.     Public Full Access (Only for Campaign object)
7.     Grant Access Using Hierarchies

263. How many roles we can create for an organization?

We can create up to 500 roles for an organization

264. How many permission sets we can create for an organization?

We can create up to 1000 permission sets for an organization

265. How many types of custom tabs are available in salesforce?

There are 3 types of custom tabs are available in salesforce
1.     Custom Object Tabs
2.     Visualforce Tabs
3.     Web Tabs

What are Apex Governor Limits,email templates in Salesforce.com


224. What are the types of email templates available in salesforce.com?
1.     Text
2.     HTML with Letter Head
3.     Custom HTML
4.     Visual force
You can create four different types of email templates:
1) Text – All users can create or change text email templates.
2) HTML with letterhead – Administrators and users with the “Edit HTML Templates” permission can create HTML email templates based on a letterhead.
 3) Custom HTML – Administrators and users with the “Edit HTML Templates” permission can create custom HTML email templates without using a letterhead. You must either know HTML or obtain the HTML code to insert in your email template.
4) Visualforce – Administrators and developers can create templates using Visualforce. Visualforce email templates allow for advanced merging with a recipient’s data, where the content of a template can contain information from multiple records.

225. 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.
226. Can we create Roll up summary fields on child object of a Master-Detail relationship?
No, Roll up summary fields can only be created on the master object of the Master-Detail relationship
227. 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.
 228. How many types of the relationship fields available in Salesforce?
There are Four types of the Relationship fields available in Salesforce
1.     Master Detail
2.     Many to Many
3.     Lookup
4.     Hierarchical (It is available only on User Object, we cannot create this relationship)

229. 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.

230. Difference between Sandbox and Development environment?
Sandbox

The salesforce.com Sandbox environment is an exact copy of your salesforce.com instance. You can copy your live instance to a sandbox environment (but you have to perform manually from sandbox to developer edition) where you can test any changes, implementations, AppExchangeapps or updates. It can also be your hands-on training environment without risking your live data.
You can either copy your configuration and data into a sandbox environment or just the configuration. It acts exactly like your live instance, but be careful if you have workflow rules or automations because they will work in the sandbox as well.
I know that this sounds wonderful and if you don’t have it, you are dying to know how to get it. The problem is the cost. If you are on Unlimited Edition, then cost is not a problem because it comes included. But for Enterprise, Professional or Group Editions, you have to pay… and the price is hefty; anywhere between 25k-50k per year. For a lot of companies, that is more than they are paying for their live salesforce.com instance. So how do you test salesforce.com without Sandbox?  It is always suggested to develop application in sandbox instance then go for LIVE.
Developer Edition
Developer Edition was an edition created for development of integrations and apps, specifically for the AppExchange. It is also a great tool for testing/training in salesforce.com. What makes this a great tool is the fact that it is free. Anyone can get a Developer Edition of salesforce.com. It is a standard Enterprise Edition with very limited storage space. You cannot copy your configuration or data onto the Developer Edition, but you can customize it to match your instance’s look and feel. Once it is customized, you can use it for training, testing or anything else you want. It takes a little bit of work, but you can make it act and feel just like your live instance. The work is well worth it for the free price.

231. How to schedule export or take the backup of salesforce?

Step by Step Instruction:
Click Setup >Data Management > Data Export > Schedule Export.
Select the desired encoding for your export file. Leaving the default is fine.
Check the Include in export checkbox if you want to include attachments in the export (optional)
Leave the default Replace carriage returns with spaces if you want your export files to have spaces instead of carriage returns.
Select Weekly as the frequency for the exports.
Choose start and end dates. Set the end date to sometime in the distant future such as 20 years from the begin date.
Set the time of day for your scheduled export. The export is put in a job queue and the exact time of the export will depend on the amount of activity in the queue.
You can select the types of data to include in your export. It is best to include all data in your export file. This will make sure all your organizations data is exported.
Click Save.
Points to Remember:
Formula and roll-up summary fields are never included in exports.
Articles are not included from exports.
The export notification email is sent to the email address on file for the user who created the scheduled export. There is no way to indicate another email address. If as an Administrator you want the email to go to another person, have them grant you login access, login as them and schedule the data export.
Important:
Scheduled backup exports of your data are limited to weekly exports.
You have 48 hours from the time you are notified the backup is available to download the backup file.
The email notification for backups goes to the email address in Salesforce of the person logged in who schedules the backup
232. Do governor limits apply to sandbox instances?

Governor limits do apply to all Salesforce instances (trial, developer, and production or sandbox environments). However code coverage and successful execution of test classes is only enforced when deploying to a production environment.

233. What actions can be performed using Workflows?

Following workflow actions can be performed in a workflow:
1. Email Alert:
Email alerts are workflow and approval actions that are generated using an email template by a workflow rule or approval process and sent to designated recipients, either Salesforce users or others. Workflow alerts can be sent to any user or contact, as long as they have a valid email address.
2. Field Update:
Field updates are workflow and approval actions that specify the field you want updated and the new value for it. Depending on the type of field, you can choose to apply a specific value, make the value blank, or calculate a value based on a formula you create.
3. Task:
Assigns a task to a user you specify. You can specify the Subject, Status, Priority, and Due Date of the task. Tasks are workflow and approval actions that are triggered by workflow rules or approval processes.
4. Outbound Message:
An outbound message is a workflow, approval, or milestone action that sends the information you specify to an endpoint you designate, such as an external service. An outbound message sends the data in the specified fields in the form of a SOAP message to the endpoint.
234. How to delete an apex class or trigger in salesforce.com production environment?
In salesforce.com production environment the Del option is not displayed for classes & triggers. Follow the below steps to delete file in production:
•         Go to your sandbox (where you do your Trigger/Class development) and delete the Trigger/Class from there. Also delete the Test Methods that test the Class/Trigger.
•         Go to Eclipse and do a Refresh from Server. This will make the files disappear within Eclipse.
•         Then deploy to Production, ticking Delete next to the files in your Deployment Plan. (For safety, always Deselect All when deploying, then sort by Type. Only then tick which files to deploy, since choosing the wrong ones could cripple Production.)

235. What are governor limits in Salesforce.com?

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 that cannot be handled thereby terminating the request.
For more information please refer to the link:
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_gov_limits.htm
 
236. Which objects can be imported by Import Wizard?

Following objects can be imported using import wizard.
1. Accounts
2. Contacts
3. Leads
4. Solutions
5. Custom Objects

237. What is the difference between Role & Profile in salesforce.com?

Profile:
Profiles are set of permissions and setting which determines the objects, the fields of the object, tabs & apps the user can access. It also determines the page layout & record type accessible to the user. Profile is a required field while user creation.
Role:
Role control the level of visibility/access to organization’s data at the record level. Users at any given role can view, edit & report on data accessible to all the users below them in role hierarchy. Role is not a required field while user creation.
Example:
Let’s take an example of a software company Ajanya.com. It has two profiles Developer & Tester and two roles Trainee & Manager. Let’s consider that Defect is a custom object.
By using Profile we can ensure that Defect can by created only by user with Tester profile and User with Developer profile can only edit the defect description.
By using Roles we can ensure that the user with Profile Developer & Role Manager can view the Defects assigned to user with profile Developer & Role Trainee.

238. What are different portals in Salesforce.com?
Partner Portal:
A partner portal allows partner users to log in to Salesforce.com through a separate website than non-partner users. Partner users can only view & edit data that has been made available to them. An organization can have multiple partner portals.
For partner portal best practices please refer link:
https://ap1.salesforce.com/help/doc/en/partner_portal_best_practices.htm
Customer Portal:
Customer Portal provides an online support channel for customers allowing them to resolve their inquiries without contacting a customer service representative. An organization can have multiple customer portals.  
   
239. What is the use of Salesforce.com Sites?

Force.com Sites enables you to create public websites and applications that are directly integrated with your Salesforce organization without requiring users to log in with a username and password. You can publicly expose any information stored in your organization through a branded URL of your choice. Sites are hosted on Force.com servers and built on native Visualforce pages. You can user authentication to a public site using customer portal.

240. How to import attachments using Data Loader in salesforce?
Please follow the instructions below.

1. Create an AttachmentList.csv file with the following column headers:
•         ParentId - ID of the record to which the attachment should be associated
•         Name - Name of the attachment
•         ContentType - Format of the extension (e.g. .xls, .pdf, etc)
•         OwnerID - ID for the owner of the attachment
•         Body - File path to the Attachment on your local machine (C:\Attachments\FileName.pdf)
2. Log in to the Data Loader.
3. Select the "Insert" command.
4. In the 'Select Sforce Object' step, select the ‘Attachments’ object. This object is not displayed by default hence check the ‘Show all Sforce Objects' checkbox.
5. Choose the AttachmentList.csv file.
6. In the mapping step, map the following fields:
•         Parent ID
•         Name
•         Owner ID
•         Body - Make sure to map the Body column which you created previously with the file extension. This is how you designate the file and location of the attachments to be inserted.
7. Click "OK" to start the upload.

241. What are groups in SFDC and what is their use in salesforce?

Groups are set of users. They can contain individual users, other groups, the users in a particular role or territory, or the users in a particular role or territory plus all of the users below that role or territory in the hierarchy.
There are two types of groups:
•         Public groups: Only administrators can create public groups. They can be used by everyone in the organization.
•         Personal groups: Each user can create groups for their personal use.
You can use groups in the following ways:
•         To set up default sharing access via a sharing rule
•         To share your records with other users
•         To specify that you want to synchronize contacts owned by others users
•         To add multiple users to a Salesforce CRM Content library
•         To assign users to specific actions in Salesforce Knowledge

242. What is the difference between public cloud & private cloud in salesforce? Is salesforce.com a public cloud or private cloud?

Public Cloud: Could services are provided "as a service" over the Internet with little or no control over the underlying technology infrastructure. More than one tenant can use the same resources.
Private Cloud: This also offers activities and functions "as a service" but is deployed over a company intranet or hosted datacenter. This is private product for a company or organization offering advance security.
Salesforce.com: Is a public cloud as it is hosted on salesforce.com data centers and data of more than one tenant resides on same servers.

243. What is the difference between custom controller and extension in salesforce?

Custom Controller: A custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Use custom controllers when you want your Visualforce page to run entirely in system mode, which does not enforce the permissions and field-level security of the current user.
Controller extension: A controller extension is an Apex class that extends the functionality of a standard or custom controller. Use controller extensions when:
•         You want to leverage the built-in functionality of a standard controller but override one or more actions, such as edit, view, save, or delete.
•         You want to add new actions.
•         You want to build a Visualforce page that respects user permissions. Although a controller extension class executes in system mode, if a controller extension extends a standard controller, the logic from the standard controller does not execute in system mode. Instead, it executes in user mode, in which permissions, field-level security, and sharing rules of the current user apply.
A controller extension is any Apex class containing a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName, whereCustomControllerName is the name of a custom controller you want to extend.
Note: Although custom controllers and controller extension classes execute in system mode and thereby ignore user permissions and field-level security, you can choose whether they respect a user's organization-wide defaults, role hierarchy, and sharing rules by using the with sharing keywords in the class definition.

244. What are different kinds of reports?

1. Tabular: Tabular reports are the simplest and fastest way to look at data. Similar to a spreadsheet, they consist simply of an ordered set of fields in columns, with each matching record listed in a row. Tabular reports are best for creating lists of records or a list with a single grand total. They can't be used to create groups of data or charts, and can't be used in dashboards unless rows are limited. Examples include contact mailing lists and activity reports.
2. Summary: Summary reports are similar to tabular reports, but also allow users to group rows of data, view subtotals, and create charts. They can be used as the source report for dashboard components. Use this type for a report to show subtotals based on the value of a particular field or when you want to create a hierarchical list, such as all opportunities for your team, subtotaled by Stage and Owner. Summary reports with no groupings show as tabular reports on the report run page.
3. Matrix: Matrix reports are similar to summary reports but allow you to group and summarize data by both rows and columns. They can be used as the source report for dashboard components. Use this type for comparing related totals, especially if you have large amounts of data to summarize and you need to compare values in several different fields, or you want to look at data by date and by product, person, or geography. Matrix reports without at least one row and one column grouping show as summary reports on the report run page.
4. Joined: Joined reports let you create multiple report blocks that provide different views of your data. Each block acts like a “sub-report,” with its own fields, columns, sorting, and filtering. A joined report can even contain data from different report types.

245. What are different kinds of dashboard component?

1. Chart: Use a chart when you want to show data graphically.
2. Gauge: Use a gauge when you have a single value that you want to show within a range of custom values.
3. Metric: Use a metric when you have one key value to display.
•         Enter metric labels directly on components by clicking the empty text field next to the grand total.
•         Metric components placed directly above and below each other in a dashboard column are displayed together as a single component.
4. Table: Use a table to show a set of report data in column form.
5. Visualforce Page: Use a Visualforce page when you want to create a custom component or show information not available in another component type
6. Custom S-Control: Custom S-Controls can contain any type of content that you can display or run in a browser, for example, a Java applet, an ActiveX control, an Excel file, or a custom HTML Web form\

Salesforce Master Detail Relationship And Look up Relationship

201. While creating new profile for user, which existing profile should be copied?
If the new user is not System administrator then copy from “Standard User” profile.

202. Who can run reports?

Users with permission “Run Report” and access to report folder can only run the report.

203. What is Difference between “Printable View” and “Export Details“button on report?

Printable View:
Formatting, grouping and subtotals are persisted.

Export Details:

Formatting, grouping and subtotals are lost.

204. What is the use of “floating report header”?

If you have long tabular report, you can make the column header visible on each page as you scroll, by enabling floating report headers.

205. How to enable “floating report header”?

Go to “Setup | App Setup | Customize | Report and Dashboard | User Interface Settings“.
Click on checkbox “Enable Floating Report Headers”.


206. Which permission is required to set the running user other than you in dashboard?

“View All Data” in profile.

207. Who can access “drag and drop dashboard”?

User with permission “manage dashboard”.

208. Which type of report can be used for dashboard components?

Summary and matrix report.

209. How many types of dashboard components are available?

Chart, Table, Metric, Gauge, and Visualforce


210. What is the difference between External ID and Unique ID?
External ID

This is a field that usually references an ID from another (external) system. For instance, if the customer has an Oracle Financials system that they will be linking with salesforce.com, it may be easier for them to be able to refer to the Oracle ID of account records from within salesforce. So they would create an external ID in salesforce.com and they would load the Oracle ID into that field for each account. They can then refer to that ID field, rather than the salesforce.com id.


Additionally, if you have an external ID field, the field becomes searchable in the sidebar search. You also can use the upsert API call with the extenal ID to refer to records.
You can have multiple records with the same external ID (though it is not recommended, as it will defeat the purpose of the external id).

External Id available for Text, Number and Email field types
External Id is used in upsert operations.
•         If external id is absent or not matched then insert happens.
•         If external id matched once then record will be updated.
•         If external id is matched multiple times then error occurs.

Unique ID field

This is a setting for the field that will prevent you from using the same value in multiple records for the unique field. So if I create a 5 character text field and make it unique, and I create a record with the value “12345″ it will not be able to create another record with that same value in the unique field. If I try to do so, I will get an error saying that the value is already in use.
Often, External Ids are set with the unique property so that the IDs will be unique to each record.

211. In Profile settings, what is difference between “Modify All Data” and “Modify All”?

Modify All Data: Create, edit, and delete all organization data, regardless of sharing settings.

Modify All: Give Read, Add, Delete permission to selected Object, Create permission is not included in Modify All  permission.

212. Explain Permission sets?

A permission set is a collection of settings and permissions that give users access to various tools and functions. The settings and permissions in permission sets are also found in profiles, but permission sets extend users’ functional access without changing their profiles.

For example, to give users access to a custom object, create a permission set, enable the required permissions for the object, and assign the permission set to the users. You never have to change profiles, or create a profile for a single use case. While users can have only one profile, they can have multiple permission sets.
Permission sets include settings for:
•         Assigned apps
•         Object settings, which include:
•         Tab settings
•         Object permissions
•         Field permissions
•         App permissions
•         Apex class access
•         Visualforce page access
•         System permissions

•         Service providers (only if you’ve enabled Salesforce as an identity provider)


213. What is Master Detail relationship and look up relationship in Salesforce?

Master Detail relationship is the Parent child relationship. In which Master represents Parent and detail represents Child. If Parent is deleted then Child also gets deleted. Rollup summary fields can only be created on Master records which will calculate the SUM, COUNT, MIN, MAX of the Child records.

Look up relationship is something like “has-a” (Containership) relationship, where one record has reference to other records. When one record is deleted then there is no impact on other records.


214. Can we convert the lookup relationship to Master Detail relationship?

We can convert the lookup relationship to master detail relationship if and only if all the existing record has valid lookup field.

215. How to delete the User from Salesforce?
As per now, salesforce does not allow deleting any user; however you can deactivate the user.
216. How to delete Users data from Salesforce?
To delete the Users Data go to Setup | Administration Setup | Data Management |  Mass Delete Record, from there select the objects like Account, Lead etc and in criteria select the users name and delete all records of that user related to particular object.
217. How to restrict the user to see any record let’s say opportunity?
Set up opportunity sharing to be private.  If both users are admins or have view all records on opportunity, then that overrides private sharing.
218. What is difference between WhoId and WhatId in the Data Model of Task ?
WhoID refers to people things. So that would be typically a Lead ID or a Contact ID
WhatID refers to object type things. That would typically be an Account ID or an Opportunity ID

219. Where is the option of the report for the “Custom Object with related object” and what are the conditions to generate related reports?

If the parent object is the standard object provided by the salesforce like “Account”, “Contact” then the report will be in there section with related custom object.
If both objects are the custom then the report will be in “Other Reports” Sections.

Following are the conditions to get the report of related objects:
•         On both the objects, Reports option must be enabled
•         The relationship between both of them must be “Master – detail relationship”.

220. How you can provide the User Login (Authentication) in Public sites created by Salesforce?

We can provide the authentication on public sites using “Customer Portal”.

221. What is the dynamic Apex?

Dynamic Apex enables developers to create more flexible applications by providing them with the ability to “Access sObject and field describe information”, “Write Dynamic SOQL Queries”, “Write Dynamic SOSL Queries” and “Dynamic DML”.

222. 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.

223. 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.

Dynamic Dashboard,Time Based Workflow,Master-Detail relationship in Salesforce

181. How can you determine that email is actually sent or not from the salesforce?

There is an Email log that you could use. It’s available in the setup menu under Monitoring.
It’s only for the past 30 days and you would have to manually check it.
From the email log page: “Email logs describe all emails sent through salesforce.com and can be used to help identify the status of an email delivery. Email logs are CSV files that provide information such as the email address of each email sender and its recipient, the date and time each email was sent, and any error code associated with each email. Logs are only available for the past 30 days.”

182. In salesforce which fields are indexed automatically?

 The following fields are indexed by default:
•         primary keys (Id, Name and Owner fields),
•         foreign keys (lookup or master-detail relationship fields),
•         audit dates (such as LastModifiedDate),
•         Custom fields marked as External ID or Unique

183. Give any scenario when you cannot change the currency field type to numeric type.
When the field is used either in Apex class or trigger

184. Consider a scenario where you have created a Visualforce page and Controller. You want to restrict the controller action for users which are logged in using “Grant Login Access”. How to achieve this?

When System admin logged in on the behalf of any other user, On upper right corner message is displayed that user is logged-in on behalf of some other user. In Visualforce page we can search for the element with class name present or not? If the element with that Class name exist means logged-in user is not an actual user.

185. How to get the debug log of Connection user in salesforce to salesforce Integration?

When configuring Debug Logs, you cannot choose a Salesforce to Salesforce Connection User from the User Lookup, but there is a workaround to achieve this.

To begin capturing Debug Logs for a Connection User open the following URL in your browser:
https://XXX.salesforce.com/p/setup/layout/AddApexDebugLogUser?retURL=%2Fsetup%2Fui%2FlistApexTraces.apexp&UserLookupInput_lkid=YYYYYYYYYYYYYY
&UserLookupInput=Connection%20User
Replace XXX with your salesforce instance, UserLookupInput_lkid is the ID of the Connection User and UserLookupInput is the User name. You can find the user ID of the connection user, by inspecting the CreatedById for a record created by this user. (eg. via eclipse or Force.com explorer)


186. We have a “Time Based Workflow” and there is Action scheduled to be executed. If we Deactivate the workflow, Scheduled actions will be removed from queue or not?

Even after deactivation of workflow, its action will be active in queue.

187. We have “Time Based Workflow” and there is action scheduled to be executed. Can we delete that workflow?
If a workflow has any pending time dependent action, then we cannot delete the workflow.

188. How to clear the Time based workflow action queue?

Two ways to achieve this:
1. Make criteria false for all those records.
2. Navigate to “Set up | Monitoring | Time Based Workflow”, search for scheduled actions and remove from queue.

189. While creating workflow on Task, what difference observed on available actions?

“Send Email” action is not available while creating workflow on task.

190. When loading data into date fields such as Opportunity Close Date using the Data Loader, the date displayed in the application is sometimes one day earlier than the date in the file. What may be the reason and solution?
The reason for this is that fields such as Close Date are actually date/time fields. When a date is loaded without specifying the time, the time is defaulted to 00:00 – midnight. When another user is in a time zone which is behind the current user’s time zone, the date will show on the previous day.
For example:
20 August 2008 00:00 in Paris is 19 August 2008 23:00 in London
Similar issues can arise when daylight savings time begins or ends.
Two simple solutions to this are:
1) Specify a time as well as a date when loading dates using the Data Loader. Or
2) Switch your PC’s time zone to Hawaiian time before starting up the Data Loader.

191. Explain dynamic Dashboard.

Dashboard which is running under current logged in user permission is known as “dynamic Dashboard”. At the most 3 dynamic dashboards can be built. This is available in Unlimited, Enterprise and Developer edition. This type of dashboard cannot be scheduled for refresh. IT must be scheduled manually.

192. What is analytic Snapshot in salesforce?

Analytic snapshot capture and store the data at pre decided intervals. It captures data from report and saves in custom object as per schedule. It only supports tabular and summary report as asource report. It does not support matrix report. The field type in target object must be same as source report object field.

193. What are the features of “Manage Members” in campaign records?

Campaign members are created from lead, contact, or person account records. Salesforce provides a variety of ways in which you can manage your campaign members. You can add and update up to 50,000 campaign members at a time through lead, contact, and person account reports; you can search for and add or edit multiple leads and contacts from the Manage Members page; you can add an unlimited number of leads and contacts using a CSV import file; or you can add members to a campaign one at a time from contact or lead detail pages.

194. If I want Object level accesses then what should i use from Salesforce security model?

Profile

195. In OWD (Organization wide sharing), can I change the setting “Grant Access Using Hierarchies” for Standard Objects?

You cannot change it for Standard Objects However for Custom Objects it’s possible.

196. What is Mandatory while creating User, Role or Profile?


It’s Profile.

197.In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?


No

198. In case of Master-Detail relationship, on Update of child record can we update the field of Parent record using workflow rule?

Yes, Master Fields are also available for “Criteria evaluation”.

199. While setting OWD (Organization wide sharing), can we change/modify the setting of child record in case of Master-Detail relationship?

No, Child record is controlled by the Parents setting.

200. How to hide the “App Setup” Menu from user’s setup page?

In Profile, remove access “View Setup and Configuration”.

What is Sharing Rules,Sandbox and Developer Editions,External ID in salesforce

161. Best Practices of Creating Contact Sharing Rules?

• Account Org-Wide Default must be set to at least “Public Read Only” in order to set the Contact Org-Wide Default to “Public Read/Write”.
• To share ALL contacts in the system with a group of users or a specific role, create a sharing rule that uses the “All Internal Users” (or “Entire Organization”) public group as the owned by option.
• Use “Roles and Subordinates” over “Roles” where possible to minimize the number of sharing rules.

162. What is a Public Group?

Public group is a grouping of:
• Users
• Public Groups (nesting)
• Roles
• Roles and Subordinates
• Mixture of any of these elements

Used in Sharing Rules – for simplification (when more than a few roles need to be shared to)
Also used when defining access to Folders and List Views
For example, if a new user is assigned a role that belongs to an existing public group, that user will be
automatically added to the public group

163. What is Manual Sharing?

Manual sharing is granting record access, one-off basis
Owner, anyone above owner in role hierarchy and administrator can manually share records
Available on Contacts, Leads, Cases, Accounts and Opportunity records and Custom Objects
Like sharing rules, irrelevant for Public Read/Write organizations

164. What are Folders in salesforce?


Folders are used for organizing email templates, documents, reports and dashboards
Access is defined – Read or Read/Write
Access is explicit – does NOT roll up through role hierarchy

Notes:
You can modify the contents of a folder if the folder access level is set to Read/Write.
Only users with the “Manage Public Documents” or “Manage Public Templates” can delete or change a Read Only folder.
The Documents tab does NOT contain version control capabilities
To search documents, users must use Documents search. The sidebar search does NOT search Documents, Solutions, Products, and Reports but does search Assets and Custom Objects
The Create New Folder link will only be visible to users with the “Manage Public Documents” permission
The size limit for documents uploaded is 5MB. The size limit for document filenames is 255 characters including the file extension

165. What are the difference between Sandbox and Developer Editions?


Sandbox    Developer Edition
The salesforce.com Sandbox environment is an exact copy of your salesforce.com instance.    Developer Edition was an edition created for development of integrations and apps, specifically for the AppExchange.
You can copy your live instance to a sandbox environment.    You have to perform manually from sandbox to developer edition.
You can either copy your configuration and data into a sandbox environment or just the configuration.    You cannot copy your configuration or data onto the Developer Edition, but you can customize it to match your instance’s look and feel.

166. How to restrict the user to see any record let’s say CASES?

Set up cases sharing to be private.  If both users are admins or have view all records on cases, then that overrides private sharing.

167. What is External ID?

External ID is a field or flag on any custom field of type Text, Number or Email
External ID is Case INSENSITIVE
External ID are restricted to Three ID fields per object
External ID can be Custom fields only.

168. What are Relative Dates?

Related dates are dates used in Views and Reports for filtering.
These are dynamic date range, based on current date
Examples: This Week, Next Month, Last 90 Days
Available Relative Date Filters (not case sensitive)

• Today
• Yesterday
• Tomorrow
• This Week
• Last Week
• Next Week
• This Month
• Last Month
• Next Month
• Last x Days
• Next x Days
• Quarter
• Year
• Fiscal Quarter
• Fiscal Year

169. How is Role Different from the Profile?


Roles and Profiles are two different concepts in Salesforce.com, Some of the basic differences are:
•         Profile helps to put restrictions on the Object where as the Role helps in opening the records to the users above the Role hierarchy
•         Profile manages the Salesforce.com License, Tabs Settings, Record types, Page layouts, General Settings, Administrator Settings etc; Role hierarchy does not do any of these things
•         Profile is Mandatory, Role is not

170. What are the different ways of making a field mandatory?
In salesforce we can make fields mandatory by 3 ways

1. Page Layout: - Field can be made mandatory from the page layout when it needs to be made mandatory for a set of users
2. Field Level Security: - Field can be made mandatory from the FLS when it needs to be made mandatory for all the users in the Organization and even from the API’s
3. Validation Rule: - Field can be made mandatory from the Validation Rule when it needs to be made mandatory for user who is using the same Page layout used by other users
Salesforce.com recommends using the Page Layout option for making the field mandatory.

171. What are the Different Ways in which leads can be created in salesforce.com?

Some of the ways in which leads can be generated and created in salesforce.com are
•         Walk In to a company: User comes to the company office and then Salesforce.com rep manually creates the Lead
•         Data Base bought by the company and then leads loaded via Data Loader/Import Wizard in salesforce.com
•         Leads created because of the Campaigns, Seminars, and Tradeshows
•         Web to Lead: Users registering on the website of the company.
•         Email to Lead & SMS to Lead can be custom build for the Organization

172. Can a Contact be part of Partner Portal as well as Customer Portal in salesforce.com?

Yes, a contact can be part of a Partner Portal as well as Customer portal in salesforce.com.
Customer Portal and Partner portal depend on the user object and are not related to the contact object.
So to enable both portals for a Contact we need to create two users which will utilize two different salesforce.com licenses, one license for Customer portal and other for Partner portal.
Both users created for a same contact will have two different profiles, One for Customer portal and other for Partner Portal.

173. When are the Record types used?

Record Types are used in the following two cases
•         To assign the different Page layouts to different users based on their profiles
•         To enable different sets of Standard/Custom Picklist values for two different users using the same page layout

174. What are Profile Components?

Profiles Components:
•         Which standard and custom apps users can view
•         Which tabs users can view
•         Which record types are available to users
•         Which page layouts users see
•         Object permissions that allow users to create, read, edit, and delete records
•         Which fields within objects users can view and edit
•         Permissions that allow users to manage the system and apps within it
•         Which Apex classes and Visualforce pages users can access
•         Which desktop clients users can access
•         The hours during which and IP addresses from which users can log in
•         Which service providers users can access (if Salesforce is enabled as an identity provider)

175. Explain Profile Vs Permission Sets Permissions and Access Settings?

The following table shows the types of permissions and access settings that are specified in profiles and permission sets. Some profile settings aren’t included in permission sets.

Permission or Setting Type    In Profiles?    In Permission Sets?
Assigned apps    TRUE    TRUE
Tab settings    TRUE    TRUE
Record type assignments    TRUE   
Page layout assignments    TRUE   
Object permissions    TRUE    TRUE
Field permissions    TRUE    TRUE
User permissions (app and system)    TRUE    TRUE
Apex class access    TRUE    TRUE
Visualforce page access    TRUE    TRUE
Service provider access (if Salesforce is enabled as an identity provider)    TRUE    TRUE
Desktop client access    TRUE   
Login hours    TRUE   
Login IP ranges    TRUE   

176. What are the Standard Profiles available in Salesforce?


There are Six (6) Standard Profiles available in salesforce (EE/UE and PE)
•    Standard User – Can view, edit, and delete their own records
•    Solution Manager – Standard User permissions + Can manage published solutions + Can manage categories
•         Marketing User – Standard User permissions + Can import leads for the organization
•         Contract Manager – Standard User permissions + Can edit, approve, activate, and delete contracts
•         Read-Only – Can only view records
•         System Administrator – “Super User,” can customize and administer the application

177. What are Standard Business Objects?
Standard Business objects are mentioned below.
Object    Description
Campaigns    A Campaign is any marketing project that you want to plan, manage, and track in Salesforce.
Leads    A Lead is any person, organization or company that may be interested in your products. Sometimes Leads are referred to as Prospects or Suspects. Leads are not yet customers.
Accounts    An Account is an organization, individual or company involved with your business such as customers, competitors and partners that you wish to track in Salesforce
Contacts    A Contact is any individual or influencer associated with an account that you want to track in Salesforce
Opportunities    An Opportunity is any potential revenue-generating event (“sales deal” ) that you want to
track in Salesforce
Cases    A case is a detailed description of a customer’s feedback, problem or question
Solutions    A solution is a detailed description of a customer issue and the resolution of that issue. The
collection of your organization’s solutions is sometimes referred to as the solution knowledge base
Forecasts    A forecast is your best estimate of how much revenue you can generate in a quarter
Documents   
Reports    Reports are summaries and analyses of your data, which you can display or print
Dashboards    Dashboards give you a real-time snapshot of corporate metrics and key performance
indicators. A dashboard is a group of different charts (or components) that graphically display your custom
report data
Calendar and Task    Activities are both tasks and scheduled calendar events. You can define and track activities for many different objects, including campaigns, accounts, contacts, and leads
Products    Products are the individual items that you sell on your opportunities. (Please note that Products are available in EE/UE and Developer and in PE for an additional fee.)   
   
178. What is a Company Profile?

Company profile contains core information for your company.
Below are the key information includes in company profile

• Language, Locale and Time Zone
• Licenses
• Storage and Used Space
• Fiscal Year
• Primary Contact and Address information
• Manage Currencies

179. What is a Fiscal Year in Salesforce?

Financial year in salesforce is used for an organizations financial planning.
This is usually a year in length and impacts forecasts, quotas and reports


Salesforce allows two types:
•       Standard Fiscal Years are periods that follow the Gregorian calendar, but can start on the first day of any month of the year. (A Gregorian Year is a calendar based on a 12 Month Structure and is used throughout
much of the world.)
•       Custom Fiscal Years are for companies that break down their fiscal years, quarters and weeks in to custom fiscal periods based on their financial planning requirements.

180. Can we use Custom financial year in forecasting?

We can NOT use Custom financial year in forecasting. But Customizable Forecasting must be enabled for use with Custom Fiscal Years