Monday, July 24, 2017

Q)
Q)Relationships in salesforce?
Q)How to call javasript remoting in salesforce ,Advantages of js remoting?
Q)Inside for loop
for(account acc : trigger.new){
  Insert acc;
}
A)To many dml statements-151
Q)How call image in static resource with zip folder ,How to call?
Q)How to give color for inputtext using javascript?
Q)How to call webservice method as vfpage method to xeternal system?
Q)Can you write controller structer from AngularJS?
Q)How to call REST API class in salesforce?
Q)did you work on responsive vfpage?
A)NO,Means any mobile ,tab related css frameworks.
Q)Can we call javascript remoting in communities ?
Q)Did you implimented any javascript remoting -Which schenario?
Q)For using AngularJS is for which framework?
   CSS framework or Javascript framework?
Q)Can you grid panel in using Angular JS?Like column as small,medium,large,XL?
Q)If have user ,they don't have any access on object xyz.But he has implimented vfpage,Even he can see xyz object records also How?
A)Using without sharing.
Q)If have process builder have multiple rules why we need to go to Trigger.
Q)

What is the difference between force.com and Salesforce.com?
 Salesforce.com:- (SAAS) Software as a service ,Company and the pre-built applications offered by the company, most notably the CRM software.
Force.com :-  Platform-as-a-Service (PaaS) offering from the same company that allows you to build
your own applications and/or customize the standard applications.

What are Governor Limits in Force.com? Why do we need 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.

What are Setup and NonSetup objects in Force.com?
Setup objects are objects that are used to interact with the metadata. One common example is the User object.
Non-Setup Objects are Every other objects like those which are native(Standard Objects) and Custom Objects fall into the category of Non-Setup Objects.

What is MIxed_DML_Operation error? How do you resolve that?
 There you cannot perform DML on what salesforce calls setup objects(User in this case) and non-setup object in the same context.
You should use @future class to avoid this error.

Which design pattern do Force.com platform uses? Explain Pattern.
Model
View
Controller

If they answer MVC pattern ask what they (each term Model, View Controller) co-relate to in Force.com platform; if they have not explained it in above question?
 Model:-What schema and data does salesforce uses to represent the system completely.In salesforce ,we can say that Sobjects are the models as every entity in salesforce is mapped to some sObject.
 View:-Visual force.
 Controller:-How to interface actions.Controllers are used to perform the actions ehanever users interact with visual force.
What is View State?
Creation: In a visualforce page, whenever we use form tag then view state will be created for the page.
Purpose: Assume that, we need to display the user input form in 3different visualforce pages. In first and second pages, user has to fill the information and click on Next button. On the final page, after filling the form if he/she will click on Save button, which ever the information we filled in the first and second pages should be also saved. View state will store the information which is filled in first and second page . To maintain the state of the page, we need view state.
Size: All the variables which we use in controller/extensions classes and expressions which are declared on the page will occupy the space in view state.
Governor Limits: Maximum size of the View State is: 135 KB.
Page Performance:
Whatever the variables information we don't required to maintain the state while navigating to other pages those variables we can decorate with transient keyword which won't occupy space in the view state.
Static variables also won't occupy space in the view state.
It is recommended to use only one form tag. If there are multiple form tags hierarchy of the folder structure increases which will occupy more space.


Q)Trigger for update account email from contact email update?

Q)Batch class have 670 records have defualt size is 200,then divided into 4 batchs
B1--1-200---pass
B2--2-5 failed recods
B3--3-9-failed recods
B4--4-200-- pass
How to get the failed records?
A)First use the database.stateful
list<string> lsts;
Database.saveresult sr = database.insert(ltsacc,false);
Q)Waht is the use of @future in salesforce?
A)Mathoed can run synchronous to asynchronous
2)call webservice call outside.
Q) ----c02
    ----co1 ----co2
       ----co2
----co2
Case----co1 ---co2
---co2
----c02
----co1 ----co2
----co2
A)Map<id,list<co2>> mapco2 = new map<id,list<co2>>();
map<id,list<co1>> mapco1 = new map<id,list<co1>>();
Q)How to call vf components in standard page layout with out using vf page?
A)Using the iframes.
Q)What is apex sharing and how to call?
Q)What is apex approval process and how to call?
Q)d/w work flow and process builder?
Q)If we using email to case there email address is from production mail id or any other mail id is there?
Q)webservice test class?how
Q)What is the agile methodology ,how to implement in ur project?
Q)how to get the requirements from client and how to impliment if you want develop trigger how to get approval from client?
Q)Test class best practice?
1)Test setup methods
2)test.startmethod and test.stoptest.
Q)how to remove the special charecters when we export the using dataloader?

These are the steps that you need to follow to load special charcters using dataloader.io:

1. Create the file as excel workbook - .xlsx
2. Make sure that the first entry in excel contains a special character
3. Save the file as Unicode Text
4. Open Notepad ++ (you can download this for free here - https://notepad-plus-plus.org/)
5. Open the file in Notepad ++
6. Replace the tabs with commas
7. Click on Encoding and change the Encoding to UTF-8
8. Save the file as type All Types and add .csv to the end of the name
9.  Do not open the file in Excel as you will lose the encoding
10.  Go to Dataloader.io and load your file
11. Check that the special character in the mapping example is correct and that all columns are created
12. Load data as normal

q)can we call webservice class from batch class ?
Yes...Must be used in batch Database.AllowsCallouts
global class linkltoMT4batch implements Database.Batchable<sObject>,Database.AllowsCallouts{

q)can we call @future metheod from batch class inside  ?
No.Both are asynchronous process.

q)can we call webservice class from @future method inside ?
Yes..Must be @future(callout=true)
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_invoking_future_methods.htm
https://developer.salesforce.com/forums/?id=906F0000000QtsRIAS

q)if we use @future methods that will excute when source will get mean while can set any specific time to excute?
No.
q)How to change the lookup field to master detail field if have more than 2 laks records?
A)using External id will update
Date dt = Date.today().addDays(7);
   Opportunity newOpportunity = new Opportunity(Name = 'shivasoft', StageName = 'Prospecting', CloseDate = dt);
Account accountReference = new Account(external__c = 'SHIVA123456711');
newOpportunity.Account = accountReference;
Account parentAccount = new Account(Name = 'Shiva', external__c = 'SHIVA123456711');
Database.SaveResult[]
    results = Database.insert(new SObject[] {  parentAccount, newOpportunity });

q)trigger for roll up summary ?

q)have you face any issues when you use the dataloader?

q)Best practices of test classes ?

Very important and first, “Test Coverage Target Should not be limited to 75%”. It is not about coverage, It is about testing complete functionality.
 It will be always better if your code fails during testing, It will be less devastating than failing functionality after product release.
If possible Don’t use seeAllData=true, Create your Own Test Data.
Create Different Class which will create Dummy Data for testing, and use it everywhere (You have to be very careful, as sometimes it may slow down test
class execution by creating unnecessary data which does not require by every test methods. So few developer prefer test data creation per Test class)
If your Object’s Schema is not changing frequently, you can create CSV file of records and load in static resource. This file will act as Test data for
your Test Classes.
Use As much as Assertions like System.AssertEquals or System.AssertNotEquals
Use Test.startTest() to reset Governor limits in Test methods
If you are doing any Asynchronous operation in code, then don’t forget to call Test.stopTest() to make sure that operation is completed.
Use System.runAs() method to enforce OWD and Profile related testings. This is very important from Security point of View.
As apex runs in system mode so the permission and record sharing are not taken into account . So we need to use system.runAs to enforce record sharing .
Always try to pass null values in every methods. This is the area where most of program fails, unknowingly.
Always test Batch Capabilities of your code by passing 20 to 100 records.
Use Test.isRunningTest() in your code to identify that context of class is Test or not. You can use this condition with OR (||) to allow test classes to
enter inside code bock. It is very handy while testing for webservices, we can generate fake response easily.
@TestVisible annotation can be used to access private members and methods inside Test Class. Now we don’t need to compromise with access specifiers for
sake of code coverage.
Maximum number of test classes run per 24 hour of period is  not grater of 500 or 10 multiplication of test classes of your organization.
Accessing static resource test records in test class e,g List<Account> accList=Test.loadData(Account,SobjectType,'ResourceName').
You can't  send email from test method.
System.debug statement are not counted as a part of apex code limit.
 Test method and test classes are not counted as a part of code limit
 We should not focus on the  percentage of code coverage ,we should make sure that every use case should covered including positive, negative,bulk and single
 record .Single Action -To verify that the the single record produces the correct an expected result .Bulk action -Any apex record trigger ,class or extension
 must be invoked for 1-200 records .Positive behavior : Test every expected behavior occurs through every expected permutation , i,e user filled out every
 correctly data and not go past the limit .Negative Testcase :-Not to add future date ,
 Not to specify negative amount.Restricted User :-Test whether a user with restricted access used in your code .

q)Best practices of trigger ?

1) One Trigger Per Object
A single Apex Trigger is all you need for one particular object. If you develop multiple Triggers for a single object, you have no way of controlling the order
of execution if those Triggers can run in the same contexts

2) Logic-less Triggers
If you write methods in your Triggers, those can’t be exposed for test purposes. You also can’t expose logic to be re-used anywhere else in your org.

3) Context-Specific Handler Methods
Create context-specific handler methods in Trigger handlers

4) Bulkify your Code
Bulkifying Apex code refers to the concept of making sure the code properly handles more than one record at a time.

5) Avoid SOQL Queries or DML statements inside FOR Loops
An individual Apex request gets a maximum of 100 SOQL queries before exceeding that governor limit. So if this trigger is invoked by a batch of more than
100 Account records, the governor limit will throw a runtime exception

6) Using Collections, Streamlining Queries, and Efficient For Loops
It is important to use Apex Collections to efficiently query data and store the data in memory. A combination of using collections and streamlining SOQL
queries can substantially help writing efficient Apex code and avoid governor limits

7) Querying Large Data Sets
The total number of records that can be returned by SOQL queries in a request is 50,000. If returning a large set of queries causes you to exceed your heap
limit, then a SOQL query for loop must be used instead.
It can process multiple batches of records through the use of internal calls to query and queryMore

8) Use @future Appropriately
It is critical to write your Apex code to efficiently handle bulk or many records at a time. This is also true for asynchronous Apex methods (those annotated
with the @future keyword). The differences between synchronous and asynchronous Apex can be found

9) Avoid Hardcoding IDs
When deploying Apex code between sandbox and production environments, or installing Force.com AppExchange packages, it is essential to avoid hardcoding IDs in
the Apex code. By doing so, if the record IDs change between environments, the logic can dynamically identify the proper data to operate against and not fail.

q)Best practices of visual force pages ?

q)Order of excutions?

1. System Validation Rules
2. All Apex “before” triggers
3. Custom Validation Rules
3. Executes all after triggers.
4. Executes assignment rules.
5. Executes auto-response rules.
6. Executes workflow rules.
7. If there are workflow field updates, updates the record again.
8. If the record was updated with workflow field updates, fires before and after triggers one more time. Custom validation rules are not run again.
9. Executes escalation rules.
10. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary field in
the parent record. Parent record goes through save procedure.
11. If the parent record is updated, and a grand-parent record contains a roll-up summary field or is part of a cross-object workflow, performs calculations
 and updates the roll-up summary field in the parent record. Grand-parent record goes through save procedure.
12. Executes Criteria Based Sharing evaluation.
13. Commits all DML operations to the database.
14. Executes post-commit logic. Ex: Sending email.

q)if have schenario for integration which go with you and how to convince the client for soap or rest?

SOAP Web Services

SOAP stands for Simple Object Access Protocol. It is a XML-based protocol for accessing web services. SOAP is a W3C recommendation for communication
between two applications.
SOAP is XML based protocol. It is platform independent and language independent. By using SOAP, you will be able to interact with other programming
language applications.
Advantages of Soap Web Services
WS Security: SOAP defines its own security known as WS Security.
Language and Platform independent: SOAP web services can be written in any programming language and executed in any platform.
Disadvantages of Soap Web Services
Slow: SOAP uses XML format that must be parsed to be read. It defines many standards that must be followed while developing the SOAP applications.
So it is slow and consumes more bandwidth and resource.
WSDL dependent: SOAP uses WSDL and doesn't have any other mechanism to discover the service.

RESTful Web Services
REST stands for Representational State Transfer. REST is an architectural style not a protocol.
Advantages of RESTful Web Services
Fast: RESTful Web Services are fast because there is no strict specification like SOAP. It consumes less bandwidth and resource.
Language and Platform independent: RESTful web services can be written in any programming language and executed in any platform.
Can use SOAP: RESTful web services can use SOAP web services as the implementation.
Permits different data format: RESTful web service permits different data format such as Plain Text, HTML, XML and JSON.

q)How to delete the trigger in production Chenge sets ?
Using the ANT Tool as Distructivechanges.xml files

q)Team1 and team2 have team2 can see the records of team1 and team1 can't see the records of team2 how it is?

Q)One 2 One relationship :
A)1)Creat M-D Relationship
    Rollup summary field >1---- error using trigger.
2)M-D relationship - child
roll up summary field - in parent
Validation in child object
retrive cross object formula list
child to parent field to count >1 then error.
3)lookup relationship
list of child size() >0 then error using trigger.

Q)i am intialized one object ,how to access that object data into 3 metehods,how it will get data in test class?
A)@testsetup methods
Q)In trigger how to run asyncronus mode?
A)@future methods
q)what is criteria of field update of work flow ,which relationship it will work field update?
A)M-D
q)data to run 10000 records insert to using trigger will run then how  many batches will excute trigger?
A)10000/200=50; Trigger.new for loop batch size is 200;
Q)Soap & Rest api ,what is get method return type?
Q)How to give access from salesforce to other application in rest api?
A)global class cAuthURIForApiReq {
    global string AuthenticationURI ='';
    public cAuthURIForApiReq(string Clientkey,string redirect_uri){
        string key = EncodingUtil.urlEncode(Clientkey, 'UTF-8');
        string uri = EncodingUtil.urlEncode(redirect_uri, 'UTF-8');
        string authuri = 'https://accounts.google.com/o/oauth2/auth?'+
                             'client_id='+key+
                             '&response_type=code'+
                 '&scope=https://www.googleapis.com/auth/drive'+
                 '&redirect_uri='+uri+
                 '&state=security_token%3D138r5719ru3e1%26url%3Dhttps://oa2cb.example.com/myHome&'+
                             '&login_hint=venkat81215@gmail.com&'+
                             'access_type=offline';
        AuthenticationURI = authuri;
    }
}
Q)how to give multiple objects return type in restapi ?

Q)what is http request?

           http response?
A)HttpRequest req = new HttpRequest();
        req.setMethod('POST');
        req.setEndpoint('https://accounts.google.com/o/oauth2/token');
        req.setHeader('Content-type','application/x-www-form-urlencoded');
        String messageBody = 'code='+codemeniaidentificationToken+'&client_id='+key+'&client_secret='+secret+'&redirect_uri='+redirect_uri+'&grant_type=authorization_code';
        req.setHeader('Content-lenth',String.valueOf(messageBody.length()));
        req.setBody(messageBody);
        req.setTimeout(60*1000);
       
        Http h = new Http();
        HttpResponse res = h.send(req);
        JSONParser parser = JSON.createParser(res.getBody());
        while(parser.nextToken()!=null)
        {
            if((parser.getCurrentToken() == JSONToken.FIELD_NAME)&&(parser.getText() == 'access_token'))
            {
                parser.nextToken();
                access_token = parser.getText();

Q)D/w with sharing and without sharing?

Q)Batch class inside @future method?
No.Both are same asynchronous process

Q)what is database.batchble context in batch class?-- AsyncApexJob
A)maintain the Status of the batch class can use this.

Q)How to write test class for batch class?
A)Inside test.starttest and test.stoptest ---reset the governer limits

Q)How to write test class for @future Method?
Asynchrinous, Inside test.starttest and test.stoptest ---reset the governer limits

q)what is system.schedule in batch class?
A)Shedule class excution.

Q)how to give the batch size?
database.excutebatch(b,50);

Q)trigger.newmap and trigger.oldmap ?
return the map of new versions of records,
Q)How to give validation error in trigger?
A)acc.name.adderror('select text');
Q)what is action function,support,region,poller,status ?or what are all ajax requests in vf page?

Q)d/w action function and java script remoting in salesforce?
Q)what is custom lable in salesforce,use?
Q)d/w soap and rest?
Q)1 2 1 without trigger?
Q)what are relationships in salesforce?
Q)d/w lookup and M-D relationships?
Q)how to call controller method in java script?
Q)Do you know about --communities ?
Q)Do you know about --lightning component ?
Q)Do you know about --process builder?
Q)d/w work flow and trigger?
Q)best practicess for trigger?
Q)d/w trigger.new and trigger.newmap ?
Q)what is the use of java script?
Q)10 users have same profile if 1 user don't have object permission how to give access?
Q)if i have 100 users 95 users have same access other 5 users 1 user can create the record other user can get read/write permission ,how?
Permission set.
Q)d/w outputlink and command link?
Q)d/w pageblocktable and data table?
Q)d/w pageblocktable and apex:repet?
Q)what is use of @istest(seealldata = true)?
Q)use of test.loaddata in test class?
A)Static resource.
Q)use of test.starttest and test.stoptest ?
Q)if i wand to validate create value in test class?how?May system.asstequals.
Q)Test class for webservice?

Q)test.is runningtest() ?

Q)D/w for loop and for each?

A)For each: loops lets you repeatedly excute code on every element of list:
ex:list<contact> allcon = [select id .lastname from contact];
for(contact con : allcon){
 con.lastname = 'venkat';
}
for loop: a traditional for loop lets you repeatedly excute code a spe number of times:
for(integer i=0;i<5;i++){
 contact con = new contact();
 con.lastname = venkat +i;
 insert con;
}

Q)what are the email services in salesforce?
inbound email services:-
global class ProcessContactApplicantEmail implements Messaging.InboundEmailHandler {

    global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, Messaging.InboundEnvelope envelope) {
        Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
     
        Contact contact = new Contact();
        contact.FirstName = email.fromname.substring(0,email.fromname.indexOf(' '));
        contact.LastName = email.fromname.substring(email.fromname.indexOf(' '));
        contact.Email = envelope.fromAddress;
        insert contact;
     
        System.debug('====> Created contact==> '+contact.Id);
     
        if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
          for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
            Attachment attachment = new Attachment();
            // attach to the newly created contact record
            attachment.ParentId = contact.Id;
            attachment.Name = email.binaryAttachments[i].filename;
            attachment.Body = email.binaryAttachments[i].body;
            insert attachment;
          }
    }
        return result;
    }
}
Out bound email services:-
1)Messaging.singleemailmessage.
2)Messaging.massemailmessage.
Q)how to bypass validation rules from apex?
Q)how to disable /enable all validaton rules for data loading?
A)Not($setup.customsettingName.checkboxfielddisable);
Q)Presales and postsales?
Q)Salescloud and service cloud?
Q)d/w force.com and salesforce.com?
Q)how to get the data ---2 users have same profile but 1 user left from company & there is no admin ,how to get the user a data to users?
Q)Rest API - stateless or stateful?
Q)how to write the test class for Rest API?
Q)is it both are same as normal test class?how?
Q)If the validation in custom object - that is status is completed then hit the validation.
But in report having data as that field value is showing completed? how?
a> Work flow field update?
Q)what is action function & action support?
Q)d/w work flow and process builder?
Q)what error you have faced in test class?
Q)how to retrive the error ,what is mixed dml statements?
Q)which one you have used for deployment?
Q)how to give grant using hierachy for standard objects?
A)No
Q)what is markup view in vf page salesforce?
Q)what is the use of output panel?
Q)in visual force page ,what are the partial represhment events in vf page?
Q)Ajax request in vf page?
Q)Batch class ,how to retrive error records?
Q)Quick action in pagelayouts?
Q)how to track field history  in custom  chatter objects  ,For this how to use chatters for field vale tracking in pagelayout?
Q)profiles and permissions?
Q)For Rest API how to autenticate the client ,how to get the from client.?
Client ID,Client Key.
Q)for deployment which you can work on?
Q)Changesets,Eclipse,AnTool.
Q)IF you have to deployee profile how to do it?
Q)If you want add like dependent components ?
A)No
Q)d/w type of triggers ?

q)which objects we can migrates using apex import wizard?
Data loader and import wizard in salesforce:
Import Wizard:
For simple imports of up to 50000 records.
It supports all custom objects and only few standard objects like Account, Contact, Leads, Solution.
It supports schedule export.
Delete operation is not available.
We cannot export data.
It doesn’t require installation.
While importing, duplicates can be ignored.
Data Loader:

For complex imports of any size more than 50000 records.
It supports all standard and custom objects.
It doesn’t support schedule export.
Delete operation is available.
We can export data of all custom & standard objects, and can import all custom & standard objects except User standard object.
It requires installation.
While importing, duplicates cannot be ignored.
Data Loader  is a tool or Application used in salesforce to import and export bulk data. ThroughApex Data Loader we are
able to Update, Insert, Delete, Upsert, Export and Export All. Each operation will be different from each other.

Q)what is the use of dataloader ?
Q)d/w soql and sosl in salesforce?
Q)d/w insert and database.insert in salesforce?
q)d/w quiry and database.quiry in salesforce?
Q)in Dml statement can use whether soql or sosl?
Q)d/w profile and permission sets?
Q)for permissionsets which kind of permissions can we give?
A)1)Object settings:-
   Permissions to perform objects & fields and settings such as tab available.
   2)apex class access:
   permissions to excute apex class.
   3)visaula force page access.
   4)system permissions :
   permissions to perform actions that apply across apps,such as "modify all data".
Q)what is test class and unit test?
Q)how many controller we can use?
Q)how many ways we can impliments class and vf page and trigger and test class?how?
Q)do you know static resource? what is the use of statatic resouce and limitation?
Q)what is the use of force.com flatform?
Q)tell us ur self?
Q)how to pass variable to all methods in batch class?how?
A)database.stateful.
Q)How to pass the parameter in batch class?how?
A)string str = 'select id,name from account';
batchclass b = new batchclass(str);
database.excutebatch(b,20);
Q)Write trigger for count no of childs have in parent object?
Q)how to get the URL parameter in vf page?
q)what is the corrent project process?
Q)how to get the requirements daily?
Q)Main limitations of workflow and process builder?
Q)what is the main advantage of vf page components?
Q)what is mixed dml operation ,how to resolve?
Q)whare u have used rest api -expalain?
Q)In custom object have custom fields - it will display in vf page .
when i create the another field with out modify any code it will display that fields in vf page?
Q)how to migrate chatter?
A)chatter data is store in the following objects:
1)<object> feed.
2)feed comment.
3)feed post.
4)feedtrackedchange.

1.What is Profile?
ANS: Profile contains set of permissions and access settings that controls what user can do with in the organization.

2. What are permission sets?
ANS: A set of permissions is given to the users without changing the profile.

3.What is OWD?
ANS: OWD'S are base line record level security for objects in the organization.
It is used to restrict access to data.

4.What is Roles?
ANS: A role controls the level of visibility that users have to an organization's data.

5.What is User?
ANS:The people who have authenticated username and password to login to the salesforce successfully.

6.What is Sharing Rules?
ANS:These are used to override the OWD permissions.
Sharing rules are two types
1.Based on record owner
2.Based on createria.

7.What is the role hierarchy?
ANS:Role Hierarchy states that higher hierarchy person can see lower hierarchy person records.

8.Can you override profile permissions with permission sets(i have defined some permissions in profile,i am trying to
use permission sets for the same object,can i override permissions for a particular object in the permission sets over to the profile?
ANS:No. Permission Sets are used only to extend the Profile permissions. It never overrides.

9. I want to have read/write permission for User 1 and read only for User 2, how can you acheive?
ANS:Create a Permission Set with read/write and assign it to User 1.

10. I have an OWD which is read only, how all can access my data and I want to give read write access for a particular record to them, how can i do that?
ANS:All users can just Read the record.
Create a Sharing Rule to give Read/Write access with "Based on criteria" Sharing Rules.

11.What is the difference between role hierarchy and sharing rules?will both do the same permissions?
ANS:Role Hierarchy states that higher hierarchy person can see lower hierarchy person records.
Sharing Rule is used to extend Role Hierarchy.

12. Is it possible to delete the user in salesforce?
ANS:No, once we create an user in salesforce we cannot delete the user record. We can only deactivate the user record.

13.How to provide security for Meta-Data files (Schema)?
ANS:Using Profiles and Permission Sets.

13. How to give permissions to two fields for different users who belongs to different profiles?
ANS:Permission set

14. How many users are there in your project salesforce instance?
ANS:1000 (It will depends upon the number of licenses taken by the client, it will be like upto 4000 like that based on the client)

15.What is Grant Access Using Hierarchies?
ANS:In OWD we have Private but your higher position persons should see that time we go for Grant Access Using Hierarchies.

16. How we can change the Grant access using role hierarchy for standard objects?
ANS:Not possible.

17.What is manual sharing?
ANS:Manual sharing is to share a record to a particular user manually.
Go to detail page of record and click on manual sharing button and assign that record to other user with Read or Read/Write access.
Manual Sharing button enables only when OWD is private to that object.

18.Can you tell the difference between Profile and Roles?
ANS:Profiles are used for Object level access settings.
Roles are used for Record level access settings.
   
1.What is trigger ?
Ans: Trigger is piece of code that is executes before and after a record is Inserted/Updated/Deleted from the force.com database.

2.What are different types of triggers in sfdc?
Ans: 1.Before Triggers-These triggers are fired before the data is saved into the database.
2.After Triggers-These triggers are fired after the data is saved into the database.

3.What are trigger context variables?
Ans:
Trigger.isInsert: Returns true if the trigger was fired due to insert operation.
Trigger.isUpdate: Returns true if the trigger was fired due to update operation.
Trigger.isDelete: Returns true if the trigger was fired due to delete operation.
Trigger.isBefore: Returns true if the trigger was fired before record is saved.
Trigger.isAfter: Returns true if the trigger was fired after record is saved.
Trigger.New: Returns a list of new version of sObject records.
Trigger.Old: Returns a list of old version of sObject records.
Trigger.NewMap: Returns a map of new version of sObject records. (map is stored in the form of map)
Trigger.OldMap: Returns a map of old version of sObject records. (map is stored in the form of map)
Trigger.Size: Returns a integer (total number of records invoked due to trigger invocation for the both old and new)
Trigger.isExecuting: Returns true if the current apex code is a trigger.
What are the difference between trigger.new and trigger.old?
Ans:
Trigger.new
 1. Returns the new version of sObject records
 2. Available only in insert and update events
 3. Records can be modified only in before events

Trigger.old
 1. Returns the old version of sObject records
 2. Available only in update and delete events

6.What is the difference between Trigger.New and Trigger.Old in update triggers?
Ans:

7.Can we call batch apex from the Trigger?
Ans: A batch apex can be called from a class as well as from trigger code.
In your Trigger code something like below :-
// BatchClass is the name of batchclass
BatchClass bh = new BatchClass();
Database.executeBacth(bh);

8.What are the problems you have encountered when calling batch apex from the trigger?
Ans:

9.Can we call the callouts from trigger?
Ans: yes we can. It is same as usual class method calling from trigger. The only difference being the method should always be asynchronous with @future

10.What are the problems you have encountered when calling apex the callouts in trigger?
Ans:

11.What is the recursive trigger?
Ans: Recursion occurs in trigger if your trigger has a same DML statement and the same dml condition is used in trigger
firing condition on the same object(on which trigger has been written)

How to restrict a trigger to run only once? (How to avoid recursive trigger execution?)

Ans: Triggers can fire twice, once before workflow rules and once after workflow rules. The before and after trigger fire one more time only if something needs to be updated.

To avoid recursive execution of triggers, we need to have the code write something like below.

 public class HelperClass{
     public static boolena firstRun = true;
 }

 trigger Xtrigger on Account(before delete, after delete){
      if(Trigger.isBefore){
          if(Trigger.isDelete){
              if(HelperClass.firstRun){
                  Trigger.old[0].addError('Before Delete Error');
                  HelperClass.firstRun = false;
              }  
          }
      }
 }

12.What is the bulkifying triggers?
Ans: By default every trigger is a bulk trigger which is used to process the multiple records at a time as a batch. For each batch of 200 records.

13.What is the use of future methods in triggers?
Ans: Using @Future annotation we can convert the Trigger into a Asynchrinous Class and we can use a Callout method.

14.What is the order of executing the trigger apex?
Ans:
1. System Validation Rules
2. All Apex “before” triggers
3. Custom Validation Rules
3. Executes all after triggers.
4. Executes assignment rules.
5. Executes auto-response rules.
6. Executes workflow rules.
7. If there are workflow field updates, updates the record again.
8. If the record was updated with workflow field updates, fires before and after triggers one more time. Custom validation rules are not run again.
9. Executes escalation rules.
10. If the record contains a roll-up summary field or is part of a cross-object workflow, performs calculations and updates the roll-up summary
field in the parent record. Parent record goes through save procedure.
11. If the parent record is updated, and a grand-parent record contains a roll-up summary field or is part of a cross-object workflow, performs
calculations and updates the roll-up summary field in the parent record. Grand-parent record goes through save procedure.
12. Executes Criteria Based Sharing evaluation.
13. Commits all DML operations to the database.
14. Executes post-commit logic. Ex: Sending email.

15.What is the trigger handler?
Ans:

16.How do we avoid recursive triggers?
Ans: Use a static variable in an Apex class to avoid an infinite loop. Static variables are local to the context of a Web request.

17.How many triggers we can define on a object?
Ans: We can write more than one trigger But it is not recommended .Best practice is One trigger On One object.

18.Can we define triggers with same event on single object?
Ans:

19.Tell me more scenarios where you have written triggers?
Ans:

20.What is the best scenario that you have developed on triggers?
Ans:

21.How many time workflow filed update will be called in triggers?
Ans:


Why 1% coverage is mandatory for triggers in salesforce?

Ans: This is to make sure that the triggers written will be executed in the production environment and will not become unreachable code and
trigger actions are called when appropriate actions are done.

1.What are the soql limitations in apex?
Ans: Total number of records retrieved by SOQL queries-50,000

2.What are the transaction limitations in apex?
Ans: Each execution of a batch Apex job is considered a discrete transaction.
For example, a batch Apex job that contains 1,000 records and is executed without the optional scope parameter from Database.executeBatch is considered five transactions of 200 records each.
The Apex governor limits are reset for each transaction.
If the first transaction succeeds but the second fails, the database updates made in the first transaction are not rolled back.

3.What is the need of batch apex?
Ans: By using Batch apex classes we can process the records in batches in asynchronously.

4.What is Database.Batchable interface?
Ans: The class that implements this interface can be executed as a batch Apex job.

5.Define the methods in batchable interface?
Ans:
Start:
global Database.Querylocator start (Database.BatchableContext bc){}
Execute:
global void execute(Database.BatchableContext bc,List <p>){}
Finish:
global void finish(Database.BatchableContext bc) {}

6.What is purpose of start method in batch apex?
Ans: It collect the records or objects to be passed to the interface method execute.

7.What is the Database.QueryLocator?
Ans: If we use a Database.QueryLocator,
the governor limit for the total number of records retrieved by SOQL queries is bypassed. (Default 50,000 It allow up to 50 million records).

8.What is the iterable<Sobject>?
Ans: If you use an iterable,
the governor limit for the total number of records retrieved by SOQL queries is still enforced.

9.What is the use of execute method?
Ans: Contains or calls the main execution logic for the batch job.

10.How many times execute method is called?
Ans: Execute method is called for  each batch of records.

11.What is the scope of execute method?
Ans: The maximum value for the optional scope parameter is 2,000

12.Can we call callouts from batch apex?
Ans: Yes we can call.

13.Can we call another batch apex from batch apex?
Ans: Yes you can call a batch apex from another batch apex .Either in start method or in finish method you can call other batch

14.How many callouts we can call in batch apex?
Ans: Batch executions are limited to one callout per execution.

15.Batch is synchronous or Asynchronous operations?
Ans: Asynchronous operations.

16.What is the maximum size of the batch and minimum size of the batch ?
Ans: The default batch size is 200 records. min?
max?

17.What is the Database.BatchableContext?
Ans: BatchableContext Interface is Represents the parameter type of a batch job method and
contains the batch job ID. This interface is implemented internally by Apex.

18.How to track the details of the current running Batch using BatchableContext?
Ans: You can check the AsyncApexJob.Status using the JobId from the Database.BatchableContext.

19.How many batch jobs can be added to queue?
Ans: Queued counts toward the limit of 5.

20.What is Database.State full interface?
Ans:To maintain variable value inside the Batch class, Database.Stateful is used.

21.What is Database.AllowCallouts?
Ans:
To use a callout in batch Apex, you must specify Database.AllowsCallouts in the class definition. For example:
global class SearchAndReplace implements Database.Batchable<sObject>,
   Database.AllowsCallouts{
              //Business logic you want by implementing Batchable interface methods
}
Callouts include HTTP requests as well as methods defined with the webService keyword.

22.What is AsyncApexJob object?
Ans: AsyncApexJob is Represents an individual Apex sharing recalculation job.
Use this object to query Apex batch jobs in your organization.

23.When a BatchApexworker record is created?
Ans: For each 10,000 AsyncApexJob records, Apex creates one additional AsyncApexJob record of type BatchApexWorker for internal use.

24)Every 3 months?
 global static string scheduleMe(){
        BatchClassforUser SC = new BatchClassforUser();
        string sched = '0 0 0 1 1/3 ? *';
        return System.schedule('Customer_Existing', sched,new BatchClassforUser());
    }
25)How to Execute the Batch Apex Class for Every 30 minutes?
We can achieve using System.schedule method.
batchApexMethod exeClass = new batchApexMethod();
String cronStr = '0 0,30 * * * *';
System.schedule('Process Accs Job', cronStr, exeClass);

26)Is it possible to call future method from apex scheduler or not?
         Yes
Below is sample code which I tested for this scenario. After scheduling the scheduler, I checked the debug logs and it was displaying logs for future handler
 and debug statement present in future method was present in logs.

//Scheduled Apex
public class DemoScheduler1 implements Schedulable{
    public void execute(SchedulableContext sc){
        system.debug('*******Going to call future method ');
        DemoAsynchronousTest.futureMethodCallFromScheduler();
    }
}
//apex class containing future method
public class DemoAsynchronousTest{
    @future
    public static void futureMethodCallFromScheduler(){
        system.debug('******futureMethodCallFromScheduler get called');
    }
 
}

27)Is it possible to do Synchronous Web service callouts from scheduled apex?
          No.
Synchronous Web service callouts are not supported from scheduled Apex. To be able to make callouts, make an asynchronous callout by placing the callout
in a method annotated with @future(callout=true) and call this method from scheduled Apex. However, if your scheduled Apex executes a batch job, callouts are
supported from the batch class.

28)Can we call scheduler from future method?
Yes

29)Can we call future method from batch apex (from execute method)?
No

30)Is there is any way through which we can call future method from batch apex?
As we know that a webservice can be called from batch class and webservice can call @future method. So in your batch class call webservice and which can
call your @future method.        
Also you can call future method from finish method in batch class.

31)What all different things which we need to consider while using future methods?
Methods with the future annotation cannot be used in Visualforce controllers in either getMethodName or setMethodName methods, nor in the constructor.
You cannot call a method annotated with future from a method that also has the future annotation. Nor can you call a trigger from an annotated method
that calls another annotated method.
Future methods cannot be called from batch class.

32)Can we modify the scheduler class or classes referenced by this scheduler class if any scheduled job is pending?
          No
If there are one or more active scheduled jobs for an Apex class, you cannot update the class or any classes referenced by this class through the Salesforce
 user interface. However, you can enable deployments to update the class with active scheduled jobs by using the Metadata API.

33)What we can do if we have to deploy the scheduler class or classes referenced by this scheduler class if any scheduled job is pending for that
 scheduler class in target org?
By default, changes to Apex code that have Apex jobs pending or in progress can’t be deployed. To deploy these changes, do one of the following.
Cancel Apex jobs before deploying changes to Apex code. Reschedule the jobs after the              deployment.
Enable deployments with Apex jobs in the Salesforce user interface in the Deployment Settings page.

Workflows and approval process and process builder:

1. What is workflow rule and Workflow actions?
Many of the tasks you normally assign, the emails you regularly send, and other record updates are part of your organization's standard processes.
Instead of doing this work manually, you can configure workflow to do it automatically.
Workflow automates the following types of actions based on your organization's processes:
Tasks—Assign a new task to a user, role, or record owner.
Email Alerts—Send an email to one or more recipients you specify.
Field Updates—Update the value of a field on a record.
Outbound Messages—Send a secure, configurable API message (in XML format) to a designated listener.
Before adding new action you need to deactivate workflow rule and do the changes and then again activate it.

2. A workflow already exists on object. Now user want to add time dependent workflow action to it but not able to get an option to select time dependent action.
 What might be issue?
Evualation criteria is set to “created, and every time it’s edited”
3. What is queue?
A queue can hold a predefined set of objects and consists of a set of users. Any of the queue members can pick up tasks assigned to the queue. Users or
Queues can be owners of records.
While adding queue members to queue, you can add users, public group, partner users, specify role of users etc.

4. What are approval process?
Salesforce supports wizard based easy to configure approval process. After an object is selected, the wizard guides the user through a step-by-step setup.
 Approval process is triggered when a user clicks on the "Submit for approval" button.
The approval process consists of the following steps -
Process definition
Initial submission actions
Step definitions
Final Rejection actions
Final Approval actions
Final Recall actionsIn workflow rule,action is triggered when a record meets an evaluation criteria. Workflow rules definition does not impact existing records.
 Workflow rule gets applied to new record creation or edits.

5. Is it possible to create parallel approval process (ability for multiple user to approve or reject a record)?
Yes. Parallel approval process allows specifying (upto 25) multiple approvers. The approver setting could be set to unanimous, or first action.
In unanimous parallel approval process, all approvers must approve a request, before it is considered as approved.
6. Difference between workflow rule and approval process?
Workflow Approval
They are activated when a record is saved. Approval process are triggered by explicitly clicking the "Submit for Approval" button.
Workflow consists of single step and different action Approval process consists of multiple steps. Also different action is taken based upon whether
 the record is approved or rejected.

7. Is it possible to start approval process after records is created in salesforce without clicking on submit for approval button?
Yes. Process builder or apex trigger can be used to initiate approval process when record is created.

8. How we can achieve dynamic approval process like approve of position record should be user defined in hiring manager field of position?
It is possible through apex triggers because in standard approval process, you need to define approver while creating approval process.

9. Is it possible to skip steps in approval process?
Yes.
In processes that have steps that are optional depending on criteria, use the skip step feature.
To skip steps, use filter criteria or formula, then choose what should happen to records that do not meet the criteria. The options are:
- Approve Record (approves the request and performs all final approval actions).
- Go to Next Step (skips this step and goes to the next step).

10. Can we implement multilevel approval process in salesforce?
Yes. Define different steps in approval process.

11. Can we update parent record with workflow field update?
Yes, only if relationship is master detail. If it is look-up relationship, then it is not possible.

1. What is process builder?
The Process Builder is a workflow tool that helps you easily automate your business processes by providing a powerful and user-friendly graphical representation
of your process as you build it. The Process Builder’s simple and powerful design allows you to:
Create your processes using a convenient layout with point-and-click efficiency.
Create your whole process in one place rather than using multiple workflow rules.
Create processes by collaborating with different teams in your business.
Stop using Apex code to automate simple tasks.
Automated processes in the Process Builder are based on records and consist of:
Criteria that determine when to execute action groups.
Immediate and scheduled actions to execute when those criteria are met.
Any change that causes a record to match the criteria can automatically trigger the action group.
You can use the more powerful and flexible Process Builder to perform the same actions as workflow. The process builder doesn’t support outbound messages,
but you can easily create one yourself with Apex. With the Process Builder, you can:
Create a record
Update any related record—not just the record or its parent
Use a quick action to create a record, update a record, or log a call
Launch a flow—you can’t schedule this action with workflow
Send an email
Post to Chatter
Submit for approval
Call apex metheod -@invocable method

2. What should be the condition we need to specify in process builder to specify schedule actions?
Below are 2 conditions:
Only when record is created
When record is created or edited and while define criteria select the checkbox for below setting
Do you want to execute the actions only when specified changes are made to the record?
3. Is it possible to edit the process once it is activated?
No, You need to clone and while cloning you can create new process or create new version.

4. How to troubleshoot the errors if any issue comes in process builder?
Use the error messages that appear in the Process Builder and the emails you receive when a process fails to help solve problems that arise when you’re
working with processes. When all else fails, look at the Apex debug logs for your processes.
Identifying Errors in the Process Builder
The API names for criteria nodes and actions are created in the background. When you create or update processes, you might see error messages that reference
those names to help you identify specifically where the problem occurred.
Errors Received after a Process Starts Evaluating a Record
When a user performs an action that triggers a process (such as creating a record) and that process fails, the user sees a page with this error:
“Workflow Action Failed to Trigger Flow.” In addition, the administrator who created the process receives an email with more details.
Using Debug Logs to Troubleshoot Processes
Use debug logs to find detailed information about your running processes after they finish running. For example, if a process doesn’t seem to trigger when
a record meets the process’s criteria, or if you want to understand the sequence of processes being executed.

5. What user permission is required to create edit and view process?
“Manage Force.com Flow” AND “View All Data” in profile.

Interview Questions on Workflows and Approval Process In salesforce
1. What is work flow ?
Ans: Work flow works based on certain criteria,By using workflow we can automate the business process like Email alerts,tasks,filed updates

2. What are the different kinds of evaluation criteria’s (events)?
Ans: 1.created
2.created, and every time it’s edited
3.created, and any time it’s edited to subsequently meet criteria

3. In which object workflows are stored?
Ans: Workflow

4. What is the difference between Created and everytime edited to meet the criteria and Created and edited to subsequently meet the criteria?
Ans: If we select 'Created and everytime edited to meet the criteria' whenever we create a record or edit a record if the criteria of the workflow rule meets
then it will trigger every time. If we select 'Created and edited to subsequently meet the criteria' -

While creating the record criteria meets so that workflow will fire and while editing the record again criteria meets workflow won't fire (meeting the criteria
to meeting the criteria)
While creating the record criteria doesn't meet so workflow won't fire and while editing the record workflow criteria meets then workflow will fire (not meeting
 the criteria to meeting the criteria)
Conclusion: Previous state of record should be not meeting criteria and current state of record should be meeting the criteria then only in current state
workflow will fire.

5.What are the types of rule criteria’s?
Ans: 1.Criteria meet (field - operator - value, if there are multiple criteria’s then in filter criteria we can give conditions like ( 1 or 2) and 3, field to
 field comparison is not possible, we can't fetch the previous state information of the field )
2.Formula evaluated (we can write formulas with this we can do field to field comparison and we can fetch previous state value of the record)

6. What is immediate workflow action?
Ans: The action which will be performed immediately after the record criteria meets.

7. What is time dependent workflow action?
Ans: The action which will be performed in future based on the any of the date field. To create time dependent workflow action we should create one time trigger. in time trigger
we can give either days or hours with the maximum of 999 value and we can select either before or after.

8. For which event we can't create time dependent workflow action?
Ans: Created and everytime edited to meet the criteria.

9. What are the different kinds of workflow actions?
Ans: New field update (we can update a field of the same object or the fields of the parent objects which are at master side in master-detail relationship,
only for master-detail parent objects we can update the field and for lookup we can't update)
New email alert (we can send emails if the criteria meets)
New task (we can create new task)
New outbound Message (we can make a callout)

10. What are the types of email templates?
Ans:1.Text
2.HTML (with letter head)
3.Custom HTML (without letter head)
4.Visual Force

12. How can you monitor future actions of time based workflow?
Ans: setup --> administration set up --> monitoring --> time based workflow

13. There is a timebased workflow which will update one of the fields if the criteria meet. User submits the record with valid criteria, workflow triggered so
that the field update is queued in the 'time based flow' queue which will fire after one day. If the user modifies the record which is submitted before the
scheduled date, after modification, a record criterion is not meeting. Whether the field will be updated or not in schedule date?
Ans: It won't trigger in the schedule date because if we modify the record to not meeting criteria that queued field update will be removed from the
 'time based flow' queue.

14. For the same scenario explained in the above question what happens when we deactivate or modify the criteria of the workflow to different criteria?
Whether the field will be updated or not in schedule date?
Ans: Yes, It will trigger in scheduled date.

15. Scenario: There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object,
 if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
Ans: It won't fire. To fire wf2 we should enable 'Re-evaluate Workflow Rules' checkbox of the field update which is there in wf1.

16. What is recursive workflow rule? How to avoid recursive workflow rules?
Ans:Whenever we enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule, due to this field update other workflow
rules on the same object will be fired if the entery criteria of those workflow rules satisfied.

Incase, in other workflow rules also if we enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update recursive workflow rules will
 come in some scenarios.

We can take two steps to avoid recursive workflow rules -

For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option, we can avoid recursive
 workflow rules.
If you don't enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update of a workflow rule we can avoid.

17. What is Approval Process?
Ans: If the criteria of the record meets then by clicking on submit for Approval button user can submit the record for approval
(Note: Approval history related list should be displayed on the record detail page)

18. Scenario: After activating the approval process, I want to add one more step. Is it possible?
Ans: It’s not possible, to add one more step deactivate the approval process and clone the deactivated approval process and add the new steps.

19.In which object all Approval process are stored?
Ans: Approval.

Limitations of the workflow
The workflow feature is only available in Enterprise, Unlimited, Performance, and Developer editions. For the Professional Edition, you can enable this
feature after paying an extra amount. As Salesforce is based on a multitenant architecture, it imposes a few limitations on the workflow:

• For each workflow rule, you can have the following:
10 time triggers
40 immediate actions
40 time-dependent actions per time trigger


• For both immediate and time-dependent actions in one workflow rule,
there can be no more than:

10 email alerts
10 tasks
10 field updates
10 outbound messages

• The workflow time trigger per hour limit for different editions are as follows:
Professional Edition: 250
Enterprise Edition: 500
Developer Edition: 50
Unlimited and Professional Edition: 1,000

• The workflow e-mail limit per day is as follows:

1,000 per Salesforce standard license
200,000 per organization


Note: Once an organization's daily e-mail limit of 200,000 exceeds, Salesforce will send a warning e-mail to
 the default workflow user and discard all the e-mails.
 Salesforce does not try to resend them later.

 Reports and dashboards in salesforce:

1. What are different types of reports?
Tabular report. This is the most basic report. It displays just the row of records in a table like format with grand total. Tabular reports cannot be used for generating dashboards.
Summary report. This is the most commonly type of report. It allows grouping of rows of data. It supports sorting and displaying subtotals. For example in a recruiting app,
a summary report could be used to display open positions classified by department name.
Matrix report. This is the most complex report format. Matrix report summarize information in a grid format. Matrix reports allows records to be grouped by both columns and rows.
Joined Reports: 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.
2. What all reports can be used to generate dashboards?
Summary and Matrix reports

3. What all things are not supported in joined reports?
The following items aren’t supported in joined reports, and aren’t converted:
Bucket fields
Cross filters
The Rows to Display filter
4. What are bucket fields?
Bucketing lets you quickly categorize report records without creating a formula or a custom field. For example, create a bucket field named Size based on
the # Employees field. Then, create buckets that group records into “Large,” “Medium,” or “Small” ranges that you define. Bucket fields can be used like
any other field to sort, filter, and group your report.
You can add up to five bucket fields per report, each with up to 20 buckets. Only numeric, picklist and text field can be used for bucketing.
Other data types are not supported.

5. Can we create a formula type in reports?
Yes.
Formula are not available in tabular reports but available for other report types.
Formula can be only in number, currency and percent format.

6. What is a Custom Report Type?
Custom report types allow you to build a framework in the report wizard, from which users can create and customize reports.
You build custom report types off of the relationships (master-detail and lookup) between objects so that you can:
Choose which standard and custom objects to display to users creating and customizing reports
Define the relationships between objects displayed to users creating and customizing reports
Select which objects' fields can be used as columns in reports
Note that the visibility of custom report types in the report wizard is controlled by users' access to the objects in the report type.
You may define which related records from other objects are returned in report results by choosing a relationship to another object.
You can associate up to four objects to a custom report type.

7. What is difference between custom report types and standard report types?
Standard report types are report types which salesforce create itself when we create objects and relationship between them.
Custom report types allow admin to specify what all fields will be available to user while creating a report. Also its provide functionality to
associate up to 4 objects.

8. How access to reports and dashboard is controlled in Salesforce?
Access to reports and dashboards are controlled by folder in which they are stored. If user has access to folder then they can run reports present
in that folder.
In reports data displayed is as per running user's security access. Reports can be run on both standard and custom objects.
Reports data is always generated in real time. When a report is saved, reports configuration parameters are stored but the generated data is not stored.

9. What is analytical snapshot?
Analytical snapshot allows reports run at scheduled time to be stored as objects. Analytical snapshots are used to perform trend analysis. As an example
 if we want to view how monthly sales are growing, fields in a report with sales figure can be stored in a custom object every month using Analytical snapshot.
 Data in this custom object can then be used to perform trend analysis.
Analytical snapshot are available from the Data Management menu option. Source report in Analytical snapshot can be of the type Tabular or Summary.
Setup Analytical reports require a four step process
Select source report
Select custom object
Map source report fields to custom object fields
Schedule the frequency for taking the snapshots
10. What is dashboard?
Dashboards are graphical representation of reports. Dashboards can be generated for summary or matrix reports (and not for tabular reports). Dashboards display
 data as per last time report was run.
A dashboard can have upto 20 components.

11. Is it possible that data you see on dashboard and data you see on report after drilling down the report on dashboard are different?
Yes.
When a user views the drill-down report for a dashboard component, running user's access permissions determine what data is displayed on the drilldown report.
Hence it is possible that data in the drill down report does not match the cumulative dashboard data.
Remember report runs based on current or logged in user and display real time data but dashboard store the information from reports when you refresh dashboard.
In order to see real time data on dashboard, refresh the dashboard.
Also dashboard can run based on logged in user or specified user but reports always runs based on logged in user.

12. What are different chart types available for dashboards?
Vertical column
Horizontal bar
Line
Donut
Funnel
Pie
Funnel is used to show proportion of values against each other.
Pie is used to demonstrate proportion of single value against total.
Donut is used to demonstrate proportion of single value against total and also show the total value.

13. What are limitations of salesforce reports?
Support for trend analysis in Salesforce is fairly limited.
User Interface of Salesforce reports and dashboards is fixed. Salesforce does not support pixel perfect report.
Salesforce reports do not support importing data from other sources
When displaying objects and their children, Salesforce does not support reporting on objects that do not have any children.
If an object has two different related lists, then Salesforce reporting does not support displaying both these related lists together.

Interview questions on Reports and Dashboard in salesforce
1. What is Report?
To summarize the information of an object we use reports.

2. What are the types of Reports?
Tabular (Displays records just like a table)
Summary (we can summarize the information based on certain fields)
Matrix (we can summarize the information in two dimensional manner, both rows and columns)
Join (we can summarize information in different blocks on the same object and the related objects)

3. How many blocks we can create for join reports?
5 blocks.

4. How many maximum groupings we can do for summary, matrix and join reports?
3 groupings

5. What is bucketing in reports?
Bucket field in Reports in Salesforce is used to group values to the name we specify.
A bucket field lets you group related records together by ranges and segments, without the use of complex formulas and custom fields. Bucketing can thus be
used to group, filter, or arrange report data. When you create a bucket field, you need to define multiple categories (buckets) that are used to group report
values.


The advantage is that earlier, we had to create custom fields to group or segment certain data.
It can group only the below data types fields
1. Picklist
2. Number
3. Text

6. How many records we can display on page for a report?
We can display up to 2000 records on a page. If more records are there to display we cannot see those through user interface. If you export the records
 to a excel sheet then you can export all records.

7.Can we mass delete reports using Apex (Anonymous Apex)?
Salesforce has not exposed any API for Reports. So best way is :
Move all reports needs to delete in new folder.
Inform everyone that reports will be deleted after some time may be 30 days.
Import your reports folder in Eclipse including all reports to be deleted and then delete the the reports folder in eclipse. It will delete all the reports
at once.

8.Explain what is dashboard?
Dashboard is the pictorial representation of the report, and we can add up to 20 reports in a single dashboard.

9.What are the different Dashboard Components?
Salesforce dashboard components are used to represent data. Salesforce dashboards have some visual representation components like graphs, charts, gauges,
tables, metrics and visualforce pages. We can use up to 20 components in single dashboard.

10.Is it possible to schedule a dynamic dashboard in Salesforce?
No, it is not possible to schedule a dynamic dashboard in Salesforce.

11.Which type of report can be used for dashboard components?
Summary and matric report.

12.Explain dynamic Dashboard?
Dynamic dashboards in Salesforce displays set of metrics that we want across all levels of your organization.
Dynamic Dashboards in salesforce are Created to provide security settings for the dashboards in salesforce.com.
We may have a requirement in an organization to “view all data” by every user in an organization according to their access we have to select
Run as Logged-in User. There are two setting option in Dashboards.
They are
1.Run as specified User.
2.Run as Logged-in User.

REST API and SOAP API in salesforce
1.What is SOAP and What is REST?

REST API

Representational State Transfer.
It is based URI:Uniform-Resource-Identifier
It works with GET:HTTP GET request is sent, and returns the specified resource.
,POST:HTTP POST request is sent, and creates a new resource.
,PUT:HTTP PUT request is sent, and creates or updates the specified resource.
,DELETE:HTTP DELETE request is sent, and deletes the specified resource.
,PATCH:HTTP PATCH request is sent, and updates the specified resource.
@RestResource(urlmapping ='/yoururl')
Works Over with HTTP and HTTPS


SOAP API

Simple Object Access Protocol.
It is based on Standard XML format
It is works with WSDL
Works Over with HTTP,HTTPS,SMPT,XMPP


2.Difference between REST API and SOAP API?
Ans :Varies on records that can be handled. Generally if we want to access less number of records we go for REST API.

3.What is WSDL?
A WSDL is an XML Document which contains a standardized description of how to communicate using webservice.

4.What are the different type of WSDL'S?
Ans:
Enterprise WSDL
Partner WSDL
Apex WSDL
Metadata WSDL
Tooling WSDL
Delegated Atuntection WSDL

5.Difference between Enterprise WSDL and Partner WSDL?
Ans:
Enterprise WSDL:
It is used for building client applications for a single salesforce organization.
Customers who use enterprise WSDL document must download and re-consume it when ever their organization makes a change to its custom objects or fields or
when ever they want to use a different version of the API.
Partner WSDL:
It is used for building client applications for multiple organizations.
The partner WSDL documention only needs to be downloaded consumed once per version of the API.

6.How can you expose an apex class as a REST web service in salesforce?
Ans - An apex class can be exposed as REST web service by using keyword '@RestResource'

7.How to fetch data from another Salesforce instance using API?
Ans :Use the Force.com Web Services API or Bulk API to transfer data We this this is a great job for the Bulk API.

8.How to call Apex method from a Custom Button?
Ans :An Apex callout enables you to tightly integrate your Apex with an external service by making a call to an external Web service or sending a HTTP request
 from Apex code and then receiving the response.
Apex provides integration with Web services that utilize SOAP and WSDL, or HTTP services (RESTful services).

9.What is the use of Chatter REST API?
The Chatter API (also called Chatter REST API) lets you access Chatter information via an optimized REST-based API accessible from any platform. Developers can
now build social applications for mobile devices, or highly interactive websites, quickly and efficiently.

10.How to fetch data from another Salesforce instance using API?
Answer: Use the FORCE.COM WEB SERVICES API or BULK API to transfer data We this this is a great job for the Bulk API.

11.What are callouts and call ins?
Making a request to an external system from salsforce is callout.

Getting requests from an external system is a call in.

12.How many callouts to external service can be made in a single apex transaction?
Ans - A total of 10 callouts are allowed in a single apex transaction.

13.What is the maximum allowed time limit while making a callout to external service in apex?
Ans - maximum of 120 second time limit is enforced while making callout to external service

14.What is the default timeout period while calling webservice from Apex.
Ans : 10 sec.

15.can we define custom time out for each call out?
Ans :
A custom time time can be defined for each callout.
the minimum time is 1 millisecond and maximum is 120,000 milli seconds.

16.How to increase timeout while calling web service from Apex ?
Ans :
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

17.What is the use of JSON?
Roundtrip Serialization and Deserialization
Use the JSON class methods to perform roundtrip serialization and deserialization of your JSON content.
These methods enable you to serialize objects into JSON-formatted strings and to deserialize JSON strings back into objects.
JSON Generator
Using the JSONGenerator class methods, you can generate standard JSON-encoded content.
JSON Parsing
Use the JSONParser class methods to parse JSON-encoded content. These methods enable you to parse a JSON-formatted response that's returned
from a call to an external service, such as a web service callout.

1. For which criteria in workflow "time dependent workflow action" cannot be created?
Ans: created, and every time it’s edited

2. What is the advantage of using custom settings?
Ans : You dont have to query in apex (fire select query) to retrieve the data stored in custom
settings.

3. What are the different workflow actions available in workflows?
Ans: 1. Field update 2. Email alert 3. send Outbound messages 4. Create new task

4. What is whoid and whatid in activities?
Ans: Whoid is the id of either contact or Lead. Whatid is the id of the related to record in
activity record(standard or custom object)

5. What is the difference between a standard controller and custom controller
Ans: standard controller inherits all the standard object properties, standard button
functionalities can be directly used. Custom controller defines custom functionalities,
a standard controller can be extended to develop custom functionalities using keyword "extenssions"

6. Can you have more than one extenssions associated with a single page?
Ans : Yes we can have more than extenssions.

7. If page is having multiple extenssions and if two extenssions have methods of same name.Then which method out of these two will be called upon calling from
vf page ?
Ans: The one which is present in the controller defined on the left side will be called.

8. What are governor limits ?
Ans: Governor limits are the limits imposed by salesforce so as to avoid monopoly by orgs in using salesforce shared resources.

9. How can we implement pagination in visualforce ?
Ans: use standardset controllers for implementing pagination.

10. What is the difference between force.com and salesforce.com?
Ans: force.com is paas(platform as a service) and salesforce.com is Saas(software as a service)

11. What is a externalid in salesforce?
Ans: It is a field which can be used to store a value that is used as a refernce for that record in other system.
For example if you have a record in system 'xyz' where it is referenced by some value then that value can be used as external id in salesforce for that record.
External id can be used for upsert operation in data loader.

12. What happens upon lead conversion ?
Ans: When lead is converted a contact, account and optionally an opportunity is created.

13. What are different ways of deployment in salesforce ?
Ans: Change sets, eclipse and ANT

14. How can you override a list button with a visuaflorce page?
Ans: Visualforce page should be a list controller that is it should have "recordsetVar" attribute defined in page tag.

15. Is it possible to bypass Grant Access Using Hierarchies in case of standard objects ?
Ans : No. This is default and cannot be changed.

16. How can you call a controller method from java script ?
Ans: Use action function component to call controller method from java script.

17. How can you call a visualforce page from a controller method?
Ans: Use pagereference object for calling a visualforce page from controller method.

18. How can you sort a select SOQl query ?
Ans: use order by clause in select query for sorting a list of records.

19. How much code coverage is needed for deployment?
Ans : Each trigger should have minimum of 1%. Class can have 0%. But, the total code coverage of 75%.

20. Can 'set' store duplicate values in it?
Ans : No. Set only stores unique values. List can have duplicate values in it.

21. Can two users have same profiles?
Ans: Yes

22. How can you refresh a particular section of a visualforce page?
Ans: This can be done using reRender attribute

23. How can you create a many to many relationship in salesforce?
Ans: This can be done by creating junction object between the two objects.

24. What happens to detail record when a master record is deleted?
Ans: detail record gets deleted.

25. What happens to child record when a parent record is deleted(look up relationship)?
Ans. Child record remains undeleted

26. How to get current logged in users id in apex ?
Ans: Use Userinfo.getuserid() to get the current logged in user's id in apex.

27. How to convert a csv file browsed in visualforce page into a string?
Ans: use csvfilecontents.tostring(). method to convert blob to string

28.How many records can a select query return ?
Ans : As of now it can return upto 50000 records.

29. How many records can a sosl query return ?
Ans: as of now it can return upto 2000 records

30. How to fire dynamic query in soql?
Ans: Using database.query
Example: List accList = Database.query('select name from account');

31.What is a bucket field in reports?
Ans: This field is used for custom grouping of values in a field. This can be used in summarizing the report.

32. What are dynamic dashboards ?
Ans: Dashboards which run for logged in user are dynamic dashboards

33. Can the dynamic dashboards be scheduled?
Ans: No they cannot be scheduled.

34.How can you use custom label; in visualforc page?
Ans: Use this syntax for accessing custom label in visualforce page - {!$Label.Samplelabel}

35.What are the types of custom settings in salesforce?
Ans: List type and Hierarchy type

36.What are the different types of collections in apex?
Ans: There are three types of collections in apex language
1. Set
2. List
3. Map

37. What are maps in apex?
Ans: Map has keys and values. A key points to a single value. Map can be used to store relationship between two entities. Keys in map are unique. Values can
be duplicated.

38. What are the different types of object relations in salesforce ?
Ans: 1. One to many
2. Many to many
3. Master detail

39.Can you have roll up summary fields in case of parent child relationship?
Ans: No. These are present only in case of master details relationship.

40. Can you see a lead which is converted in saleforce UI?
Ans: The detail record is not seen. But a page, wherein it shows the links for formed account, contact and opportunity.

41. What is the difference between action function and action support ?
Ans: Action functions can call controller method from java script, action support adds support to other components.

42. What is action poller in visualforce ?
Ans: Action poller sends AJAX request with a specified time interval.

43. What are the different types of reports available in salesforce?
Ans: 1. tabular report
2. Summary Report
3. Matrix Report
4. Joined Report

44. How many active assignments rule can you have in lead/Case?
Ans: You can have only one active assignment rule at a time.

45. How do we access static resource in visualforce?
Ans: Use this syntax for accessing static resource {!$Resource.Testresourcename}

46. How to embed a visaulflow in a visualforce page ?
Ans: Use this syntex to embed flow in vf page :

47. How to enable inline editing in visauflorce page ?
Ans You can enable inline editing in visualforce page by using component.

48. What is trigger.new in trigger ?
Ans: trigger.new is a list of records that are in the context of trigger or becuase of these records(modification,Creation, deletion) the trigger has been
called

49. How do we bulkify the trigger ?
Ans: Bulkfification requires iterating over all the records in trigger context
for example : for(account ac: trigger.new){
// your logic here
}

50.How can we get the old value in trigger ?
Ans: use trigger.old map for getting previous values of fields.

51. Can we modify records directly in trigger.new ?
Ans: trigger.new is a read only list, but field values can be changed in case of before trigger.

52. What does the error "list has no rows for assignment" mean?
Ans: it means the list you are trying to access has no values in it.

53. Why should we not write select query within for loop?
Ans: Writing select query within for loop may hit the governor limit of 100 select queries.

54. What should we do to avoid view state error in visualforce page?
Ans: Clear unused collections, define variable as transient.

55. What is a sandbox org?
Ans: It is the exact copy of your production org.

56.What is sosl?
Ans: select query that can return records of multiple objects as list of lists.

57. How many records a select query soql can return?
Ans: as of now the limit is 50000

58. What is the full form of AJAX?
Ans: it stands for asynchronous java and XML

59. Why do we need to write test classes?
Ans: Salesforce does not allow deployment in production if the test coverage is less than 75%

60.How can you show a custom error message in trigger?
Ans: This can be done using addError() method in trigger

61. What is the use of future annotation?
Ans: Future method starts execution when Salesforce has resources available.That is for asynchronous execution.

62. How to identify if a class is a test class?
Ans: test class always begins with @isTest

63. How to convert a blob variable into a string?
Ans:Use toString to convert blob into string

64. what are the different methods of batch apex class?
Ans: start method, execute method and finish method

65.What is' with sharing' in apex class code?
Ans: When you use 'with sharing', user's permissions and field-level security are respected. In case of 'without sharing' code runs in system mode.

66. How many records can a sosl return ?
Ans: It can return 2000 records as of now as per governers limit

67.Can you use dml statement in visualforce compoenent controller ?
Ans: To use dml in visualforce component you have to declare allowdml=true in visualforce component otherwise you will get an exception
"DML is currently not allowed"

68. Can you write sosl in trigger>?
Ans: Earlier this was not allowed but now sosl are allowed in triggers.

69. Which are the different access modifiers in apex?
Ans: 1. Private 2. Public 3. Protected 4.Global are the four access modifiers allowed in apex.

70. Can you change the master of a detail record in salesforce ?
Ans. Yes provided you have ticked marked "Allow reparenting" in field setting otherwise the field is read only and master cannot be changed.

71. How can you lock records in apex?
Ans: use For update in query to lock the record. For example: [select id,name from contact limit 10 For update];

72. Is there any limit on the number of items that can be stored in apex collections?
Ans: There is ni such limit but we need to consider heap size limit 6mb (6 MB as of now)

73. How can you monitor future actions of time based workflow?
Ans: setup --> administration set up --> monitoring --> time based workflow

74. What is visaulforce component ?
Ans: It is a piece of code that can be reused. It can be encapsulated in other visualforce pages.

75. Ho can you display the status of an AJAX update request in a visualforce page ?
Ans: To display AJAX request status we can use component.

76. How can you access custom label in apex:
Ans: Example --> string custLabelstr = System.Label.LabelNamehere

77.How can you get all the keys of a map variable ?
Ans: USe method keyset() for this
Example = Set idSet = mapname.keyset();

78. How can you compare values of a picklist field in validation rule?
Ans : for comparing picklist value use ispickval
ISPICKVAL(picklist_field, text_to_compare)

79.What are the different types of sandboxes in salesforce ?
Ans: Developer, Developer Pro, Partial Data and Full are the 4 types of sandboxes in salesforce.

80. With what frequency can you refresh a full copy sandbox?
Ans: full copy sandbox can be refreshed every 29 days from production.

81. How can you make fields required on a visualforce page?
Ans: mark required = true as done in the example below:

82. What is minimum coverage for every trigger for deployment?
Ans: every trigger should have a minimum coverage of 1%. Total coverage should be 75%

83. What is minimum coverage for every class for deployment?
Ans: There is no such requirement. A class can have 0% but the total coverage should be >75%

84. How can you implement custom functionality for a standardcontroller visualforce page?
Ans: This can be done by associating a controller class with that standard controller using "Extenssions"

85. How can you get the current record id in a visualforce page ?
Ans use ApexPages.CurrentPage().getparameters().get('id') to get the current record id in visaulforce page.

86. Can a user change his own profile in salesforce ?
Ans: No, a user cannot change change his own profile !!

87. Can a user change his own role?
Ans: Yes this can be done !!

88. Reset security token option is unavailabel in set up. What could be the reason?
Ans: If in the profile setting "login ip ranges" have been set up then the option of "reset security token" is uanvailbale.

89. How can you skip record type selection page(and take up default record type) while creating new record of a aprticular object ?
Ans: just tickmark against the object by navigating to following :
set up --> my personal information -- > Record type selection --> check against the required object

90. What are the different data types that a standard field record name can have?
Ans: Record name field can have either of the two data types : Auto Number or Text data type

91.Can you edit a apex trigger/apex class in production environment ?
Ans: No apex trigger /class cannot be edited in production.

92. Can you edit a visuaforce page in production environment ?
Ans: Yes this can be done.

93.How can you deliver a visualforce page in excel form ?
Ans: use contentType="application/vnd.ms-excel#Contacts.xls" in page component of visualforce page

94. What is trigger.new?
Ans: It is a list of records in current context in a trigger.

95. What does it mean when you get the error "too many soql queries 101 salesforce"?
Ans: It means you are hitting the limit of 100 soql queries as per governers limit

96. How can you create a input field for date on a visualforce page ?
Ans: To create a input date field on vf page you will have to bind it with a existing date field on any object.

97. How can you convert a text to upper string ?
Ans: stringname.toUppercase();

98. How can you convert a integer into a string ?
Ans: string.valueof(integerName);

99. What are the different types of email templates that can be created in salesforce?
Ans: Test, HTML (using Letterhead), Custom (without using Letterhead) and Visualforce.

100. How can you display different picklist values for picklist fields in different page layouts?
Ans: This can be done using record types.

101.Can you do a dml in constructor?
Ans: No this cannot be done.

102. What are the data types that can be returned by a formula field?
Ans: 1.Checkbox 2. currency 3.Date 4.Date/Time 5.Number 6.Percent 7.Text

103. Can you create a new profile from scratch ?
Ans: No, you have to clone from a existing profile and modify the settings as required.

104. What are custom labels in saleforce?
Ans custom labels are custom text values that can be accessed from apex codes and visualforce pages.

105. What is the character limit of custom label ?
Ans: Custom labels can be only 1000 characters long, not more than that.

106. How long can a sandbox name be?
Ans: It can only be of upto 10 characters not more than that.

107. Can you use sharing rules to restrict data access?
Ans No, sharing rule can only give wider access to data it cannot restrict data access.

108. Can you edit a formula field values in a record?
And: formula fields are read only and cannot be edited.

109. Can you edit roll up summary field values in a record?
Ans: No, roll up summary fields are read only and cannot be edited.

110. Ho can you create relationship between two objects in salesforce?
Ans relationship can be set up by crating either look up relationship field or master detail relationship fields on objects.

111. Can you create a roll up summary field on parent object?
Ans: Roll up summary fields can only be created if the relationship between objects is master detail type.

112. Ho can you place an entire visualforce page in a different visualforce page?
Ans - This can be done using include attribute.

113. How can you hard delete records in apex?
Ans - use emptyrecyclebin method as below
ex- delete myAccList;
DataBase.emptyRecycleBin(myAccList);

114. What all data types can a set store?
Ans - A set can store all primitive data types and sObjects but not collections.

115. What is the use of offset keyword in a soql query?
Ans - Using offset keyword return the records starting from desired location in the list. For example if we specify offset 8 then all the records starting
from location 9 onwards would be returned.

116. How can you display an image as an field in a detail page of record?
Ans - This can be done using IMAGE function. A url of the image stored in document should be given in image function

117. When a lead is converted into account/contact will the trigger on account/contact fire?
Ans - In set up we can enable or disable whether triggers should run on conversion.

118. What happens to contacts when an account is deleted?
Ans - When an account is deleted all the contacts under it gets deleted.

119. What is an sObject type?
Ans - sObject refers to any object that can be stored i force.com platform database. ex. sObject s = new contact()

120. How many elements can be stored with in a collection(list,set,map)?
Ans - There is no limit on the number of elements that can be stored in a collection. However, we need to consider the heap size limit.

121.Expand SOQL and SOSL.
Ans - SOQL- salesforce object query language, SOSL - salesforce object search language.

122. What is the difference between soql and sosl?
Ans - SOQL can query records from a single object at a time, while sosl can query records from
multiple objects. SOQL returns a list while SOSL returns list of lists.

123. How can you query all records using an soql statement?
Ans - This can be done using ALL ROWS keyword. This queries all records including deleted records i recyclebin.

124. What is the use of @future annotation?
Ans - Using @future annotation with a method executes it whenever salesforce has resources available.

125. What are the different access modifiers that can be used with methods and variables?
Ans - Global, Public, private and protected

126. What is the significance of static keyword?
Ans - Methods, variables when defined as static are initialised only once when class is loaded.
Static variables are not transmitted as part of view state for a visualforce page.

127. Can custom setting be accessed in a test class?
Ans - Custom setting data is not available default in a test class. We have to set seeAllData parameter true while definig a test class as below.
@isTest(seeAlldata=true)

128. What is the difference between role and profile?
Ans - Role defines record level access while profile defines object level access.

129. On which objects can you create Queues?
Ans - Queues can be created on two standard objects (Lead and case) and also on all custom objects.

130. What are the different ways to invoke apex code?
Ans - Apex code can be invoked using DML operation(trigger), Apex class can be scheduled using schedulable interface(ex. batch apex), apex code
can be run through developer console, an apex class can be associated with a visualforce page.

We can call apex class in below mentioned ways
    From another class
    From Trigger
    From Visualforce page
    From Developer console
    Form JavaScript button, Links
    From Home page components
    From apex shecduler
131.Can you create sharing rules for detail objects?
Ans - No. Detail objects cannot have sharing rules as the detail objects do not have owner field with them.

132. How can view state error be avoided?
Ans - Use transient keyword with variables wherever possible, clear unused collections. Use 1 form tag in a visualforce page.

133.Consider that a record meets a workflow criteria for time based workflow action, the action goes in queue . Later, before the time based action is
triggered, the same record gets modified and the criteria previously met is changed and now it does not meet the workflow criteria, what happens to the
time based action placed in queue?
Ans - The time based workflow action is removed from the queue and will not get fired.

134. What is the use of writing sharing rules?
Ans - Sharing rules extend the record/data access level which is set using OWD, role hierarchy.
Sharing rule cannot restrict the data visibility but can only widen it.

135. Which all field data types can be used as external ids?
Ans - An external id can be of type text, number or email type

136. What is a mini page layout?
Ans - Mini page layout defines fields and related list to be displayed in hover detail and console tab.
Whenever you hover mouse over any recently viewed record the fields are displayed, related list is
not displayed(fields can be set in mini page layout).
Console tab fields and related list on the right hand side are also controlled by mini page layout.

137. What is the use of console view/console tab?
Ans - Console gives list views and related list records for multiple objects on a single
screen without any customization (visualforce page or controller)

138.What is @future annotation in apex?
Ans - It is used to indicate that code should be executed asynchronously when salesforce has available resources.

139. What are the different considerations that must be followed when using @future annotation in apex method?
Ans - 1. Method must be static 2. It must return void and 3. method can have argument of type primitives,collection of primitives or arrays of primitives

140. How can you execute batch apex programmatically?
Ans - Batch apex can be invokde using Database.executebatch(). Ex- Id batchprocessId = Database.executebatch(mybatchapexclass,200)

141. How can you set the batch size in batch apex ?
Ans - This can be set using optional scope parameter in database.
executebatch (batchapexname,batchsize) example - Id batchprocessId = Database.executebatch (mybatchapexclass,200) in this example batch size is set to 200

142. How can you monitor batch apex job?
Ans - Batch apex job can be monitored by navigating to your name
--> setup --> monitoring --> Apex jobs

143. What is the difference between List type custom setting and Hierarchy type custom setting?
Ans - List type stores static data that can be used in apex code as it is examples could be country
codes,currencies etc
Hierarchy type stores data that may change depending on user,profile or org wide default

144. Where can custom setting data be accessed?
Ans - Custom setting data can be accessed in formula fields,validation rules,workflow rules,apex,API

145. What different return types can be returned by SOQL?
Ans - A SOQL can return List of objects, a single object or an integer

146.What are the different exceptions in apex?
Ans - Apex exceptions can be built in or we can also create our own custom exceptions.
Exception class is the super class of all the built in exceptions.
So as to create a custom exception the class name should end with string 'exception' and it
should extend any of the built in exception class or other custom exception class.

147. What different access modifiers can be used for apex classes?
Ans - Apex classes can have either or these three access modifiers 1. Private 2. public 3. global

148. What different access modifiers can be used for class members?
Ans - Class members can have any of these four access modifiers 1. global 2. public 3. protected 4. private

149. What are governers limit in salesforce?
Ans - Governers limit are run time limits that are enforced by salesforce.
Governers limits are reset per transaction.

150. What is an apex transaction?
Ans - An apex transaction represents set of operations that are executed as a single synchronous unit.

151. What does heap in apex mean?
Ans - Every apex transaction has its heap. Heap is nothing but the garbage collected
at the end of every apex transaction.

152. How many callouts to external service can be made in a single apex transaction?
Ans - A total of 10 callouts are allowed in a single apex transaction

153.What is the maximum allowed time limit while making a callout to external service in apex?
Ans - maximum of 120 second time limit is enforced while making callout to external service

154. How can you expose an apex class as a REST web service in salesforce?
Ans - An apex class can be exposed as REST web service by using keyword '@RestResource'

155. What are custom controllers?
Ans - Custom controller is an apex class that implements all of the logic for a vf page without
leveraging standard controller

156. Can a custom controller class accept arguments?
Ans - No. A custom controller cannot accept any arguments and must use a no argument constructor for outer class.

157. What different type of method can be defined for VF controllers?
Ans - getter methods, setter methods and action methods

158. What are getter methods, setter methods?
Ans - Getter methods retrieve data from controller while setter methods pass data from page to
controller.

159.What is Organisation Wide Default in salesforce?
Ans - Organization wide default is used to set default access level for various standard objects
and all custom objects. Default access can be set as Public read only, Public read write,
Public read write and transfer for different objects.
For example if the record access level is set to private then the records will be
accessible only to owners, users above in role hierarchy and if it shared using manual sharing.

160.Can you set default access in Organization wide default for detail objects (detail object in case of master detail relationship)?
Ans - No, Detail object will always have default access as 'Controlled by Parent' and it cannot be changed.

161. Can you create sharing rules for detail objects?
Ans - No, this cannot be done.

162. Can standard object appear as detail object?
Ans - No, you cannot have standard object as detail object in case of master detail relationship.

163. What are the differences between list and set?
Ans- 1. Set stores only unique elements while list can store duplicates elements
2. elements stored in list are ordered while those stored in set are unordered.

164. What various default accesses are available in OWD?
Ans - Private, Public Read only, Public read write, Public read write transfer, controlled by parent, Public full access

165. What are the different types of reports in salesforce?
Ans - tabular,summary,matrix and joined

166. Can a user not have a role?
Ans - Yes, this is possible, Role is not mandatory for user.

167. Can a user not have a profile?
Ans - No, a user should always have a profile. Profile is mandatory unlike role.

168. How many custom fields can be created on a object?
Ans - Initial limit is of 500 fields and if needed this can be extended to 800 by raising a case with salesforce.

1. What are validation rules?
Validation rule contains an error condition and error message. If evaluation of error condition results in true value, record is not saved, and the error
message is generated. Validation rules can be attached to fields. They are executed when a record is created or updated.

2. Can we avoid deletion of records through validation rules?
No. Validation rules fire in insert and update operation.

3. Can we bypass validation Rules?
Validation rules can never be bypassed. If we have upload records and need to bypass validation, then deactivate validation rule and upload records.
After upload, again activate validation rule.

4. Is it possible to fire validation only for records which is being getting updated not to newly inserted records?
Yes, We can use ISNEW() function which will return true whenever new record is getting created in validation rule. We can use this function and check our
 criteria only if ISNEW() function is returning false(means record is being updated).

5. Is there is any way through which validation rule is bypassed while doing upload through data loader  but not when user is creating record from user
interface?
Yes. Create a checkbox field as API upload and make this field hidden in page layout. Create a validation rule and in evaluation criteria first check if
checkbox is false and then check other validation criteria.
Whenever user upload record through data loader, specify value for this checkbox as true in .csv file and then upload it to salesforce. While upload,
validation rule will fire and will find checkbox value as true so it will not check other criteria and system will allow to upload records.

6. What is the difference between ISBLANK() AND ISNULL()?
ISNULL() works only for number data type fieds, if we don't populate with value for number fields it will return true.
ISNULL() won't support TEXT data type fields because text fields never become null.
ISBLANK() supports both number as well as text data types.

7. What are cross object formula fields?
Cross-object formulae span two or more objects by referencing merge fields. By using this you can refer parent fields from child record.

8. What are different ways to make field required in salesforce?
While field creation, specify required field as true.
Through page layouts
Validation rule
Apex trigger
9. Admin wants to avoid the deletion of child records in master detail relationship. Is it possible to achieve this using point and click functionality?
Yes. First create a roll up summary field on parent which calculates the total count of child records. Now write a validation rule on parent object which
checks if previous value of total count is less than new value. If yes, then display error message.
Suppose field name is total_count__c in parent object then validation rule criteria will be:
Priorvalue(total_count__c) <total_count__c
When we delete the child record then roll up summary field value will get reduced by 1. System will update the parent record roll up summary field which will
fire the validation rule and avoid user from deleting child record.
Validation Rules In Salesforce:

10)Restrict specific profile when opportunity stage = closed they doesn't change or modify that
 record for specific  profile.

AND($Setup.jl_runvalidations__c.Run_Validations__c,AND(
ISPICKVAL(PRIORVALUE(StageName),"Closed Won"),
($Profile.Id = "00e28000001N8Zv")
))

Fields:

1. What is difference between standard objects and custom objects?
Standard are objects are predefined by Salesforce like Accounts, Case, Contact etc. Custom object are created by developers based upon application requirements.

2. What are system modifiable fields. Whether these fields can be modified?
Fields like createdby, createddate, modifiedby, modifieddate are system modifiable fields. These fields cann’t be modified. If you want to upload historical
data and want to specify values for these fields, then you need to contact salesforce and they will make these fields available for certain duration.
Remember you can specify these fields while doing insert only. You cannot update these fields after insertion. System modifiable fields are available
through API’s only not on UI. As a best practice always enable these fields only for initial data migration.

3. True or False: The Created Date can be updated for a record via the API as long as the Modifiable System Fields id turned on.
False. These fields are available for insert and cannot be updated once uploaded.

4. Does salesforce stores the deleted objects and fields?
Yes, salesforce stores the deleted objects and fields for 15 days in recycle bin. You can restore or undelete them from recycle bin.

5. What are external Ids? Does external ids are unique in salesforce?
A field of type external id is a unique id of records from another system. The performance of reports and SOQL is better for fields defined as external ids.
Fields of type number, text and email can be set as external id. Each object can have upto three external ids.
External ids are not unique in salesforce. You need select unique and external id checkboxes while creating fields to make external ids unique.
Advantages of External Id:
-Increase report and API SOQL performance
-Used with upsert to easily integrate apps with other systems


6. What all data type can be used as controlling fields?
Picklist and checkbox. Standard picklist cannot be dependent picklist. Custom fields can be controlling as well as dependent fields.

7. What are encrypted fields?
A field defined as encrypted is not visible to users. Typical usage of encrypted field is for password. Only users with "View Encrypted Data" can view the
encrypted fields. Encrypted fields are editable.

8. What is difference between 15 digit and 18 digit Record id?
In Salesforce, whenever user create any component (Object, field, tab etc...) or record then salesforce will generate an unique id with which user can
identify the record or component.
After creating the record, in the URL user can see the id of the record which is of 15 digits length.
15 digit id- It is case sensitive and can be seen in user interface in URLs and Reports
18 digit Id- It is case insensitive. APIs and Apex (SOQL) always return 18 digit Id. Even through apex dataloader, we get 18 digit Id.

First 3 digit of record Id specifies the object to which record belongs. For example account records starts with “001” & contact record start with “003”.

9. What are different types of relationship in salesforce?
Basically there are 2 types of relationship, lookup and master detail.
Other relationships are:
Self-relationship- When object is related to itself. For example a case can be related to parent case.
Hierarchical relationship- When user has relationship with user. For example we can have manager field in user object which is related to user object only.
Many to many relationship- When an object is having master detail relationship with 2 different objects.  The intermediate object is called as junction object.
 An object is called junction object only if it has master detail relationship with 2 different objects.
10. Can a standard object become child in master detail relationship?
No. Standard objects always remain master.

11. What is difference between lookup and master details?
Ans: Difference between Lookup and Master-Detail relationship are

Master Detail
 1. Cascade record deletion
 2. Child record must have a parent
 3. Cascade record level security
 4. Standard Object can not be on detail side of Master Detail
 5. Roll-up summary fields on parent object
 6. Master Detail relationship field is required on the page layout  of the detail record

Lookup
 1. This is optional, no parent requirement
 2. No impact on record security
 3. Roll-up summary fields cannot be established
 4. Lookup relationship is not automatically required

12. What are roll up summary fields?
Rollup-summary fields are supported in master detail relationship. The parent object can use roll-up summary field type to perform operations of
sum, maximum, minimum, count among its children records.

13. What is junction object?
Junction object is an object which has master detail relationship with 2 different objects. Many-to-Many relationships are implemented using two
master detail objects. One Junction object is used as the child of the objects between which many-to-many relationship needs to be established.

14. What is difference between self-relationship and hierarchical relationship?
Self-relationship is a lookup relationship to itself. For example a case record can be related to parent case record.
When there is self-relationship exist on user object, then it is called hierarchical relationship. For example, an employee's manager is also an employee.

15. Can we change already existing lookup relationship between 2 objects to master detail relationship?
System will allow changing relationship to master-detail only if all child records have value specified for parent as in master detail relationship,
master is required.
If any of the child value doesn’t have parent value (means look up field is blank), then system will give validation error while changing the data type.
So if it is required to change relationship, them populate all blank values with some parent value and then change it to master detail.

16. Is it possible to change master-detail relationship to lookup relationship?
If the parent object doesn’t have Roll up Summary fields for the child object then we can convert.

17. Is it possible to create the Master – Detail Relationship field for the child object which is having existing records?
No, we cannot create directly. To create first we should create Look up relationship then populate the field value for all the records and then convert
the look up relationship to master detail relationship.

18. What will happen if we undelete junction object and normal object from recycle bin?
Master – Detail Relationship data types will be converted to look up relationship data types.
If we undelete any object from recycle bin, then all master detail relationship will be changed to lookup relationship.

19. What will happen if we delete child record in case of look up relationship and master detail relationship?
In case of lookup relationship, we can delete parent object or child object. When parent object will be deleted, the value of lookup relationship field in all
child records will become blank.
In case of master-detail relationship, if parent object contain roll up summary, then system will not allow you to delete child object.Also you cannot delete
parent object in master detail relationship.

20. Is it possible to filter the records which are coming in look-up window when we click on lookup icon?
Yes, define filter criteria while defining the look up relationship.

21)one master object A is private and other master object B is public then what is OWD for child object c?
A)Private.
22)if we have two objects A and B .and we have trigger on A to insert record in b.But user doesn't have access to B object what happens then?
A)Yes insert record ,Because trigger can run in system mode.

23)
Q) We are not providing some of fields in .csv file which are required in page layout level .what happens if we try to insert records into sales force through
data loader ?
A) All records are inserting in sales force successfully.
Q) We are not providing some of fields in .csv file which are required in field level .what happens if we try to insert records into sales force through data
loader ?

A) Except those records remaining records will be inserted in to sales force.

1. Is it necessary to define an explicit primary key in custom objects?
No. Every object has a standard field called id. There is no need to define an explicit primary key in custom objects. The standard id field can be used as
primary key.

2. In which order, we upload data in salesforce for related objects?
When loading data into a salesforce application dependencies between objects determine the order in which objects are loaded. If there is a one-to-many
relationship between A and B, the data for A should be loaded before the data for B.

3. What is Upsert and how external id are beneficial?
Upsert is an API function that combines insert and updates into a single call. Upsert uses an indexed custom field or external ID to determine whether to
create a new object or update an existing object.
-If the external ID is not matched, then a new object is created
-If the external ID is matched once, then the existing object is updated
-If the external ID is matched multiple times, then an error is reported
Use Upsert when importing data to prevent the creation duplicates.

4. What is import wizard?
It is easy to use tool to load Accounts, Contacts, Leads, Solutions, or Custom Objects.
-Load 50,000 records or less.
-Prevent duplicates
-Doesn’t support all standard object but supports all custom object

5. Which is API based tool supported by Salesforce and what are its advantages?
Apex Data Loader

Advantages are:-
-Is a fully supported salesforce.com product.
-Supports import from CSV or export to CSV.
-Can be used to import or export more than 50,00 records.
-Supports loading from or exporting to a database via JDBC.
-Supports custom relationships for upsert.
-Can be run from command line.

6. Can we avoid duplicates using apex data loader which we can do through import wizard?
No.

7. What is Bulk API?
The Bulk API is used to upload high volume of data (millions of records).
The Data Loader uses the SOAP-based Web Services API by default. To use the Bulk API instead, check “Bulk API” checkbox in apex data loader settings page.
When you check Bulk API checkbox, increases the batch (upto 10000 records) which is usually 200 in normal upload.
Hard delete bypasses the Recycle Bin, so deleted records do not consume storage space and there is no way to retrieve them.

8. What is difference between “Export” and “Export All” in apex data loader?
Export: It will fetch only active records from salesforce.
Export All: It will fetch active as well as records from recycle bin.

9. True or False: Users can mass transfer records to which they do not have read access?
False

10. What is DateTime format supported in .csv file for upload in salesforce?
YYYY-MM-DDThh:mm:ss.00Z

11. Is there is any option to specify time zone for uploading records in apex data loader?
Yes. Present in settings page of apex data loader.

12. When “Hard Delete” button will be enabled in apex data loader?
When you enable Bulk API setting in apex data loader.

How to handle comma within a field while uploading using Data Loader?
In a Data Loader .CSV, if there is a comma in field content, you will have to enclose the contents within double quotation marks: ” “.


Most Frequently Asked interview questions of Apex, Visual force, SOQL in Salesforce.com SFDC
20. In Which sequence Trigger and automation rules run in Salesforce.com
Ans : The following is the order Salesforce logic is applied to a record.
Old record loaded from database (or initialized for new inserts)
New record values overwrite old values
System Validation Rules
All Apex “before” triggers
Custom Validation Rules
Record saved to database (but not committed)
Record reloaded from database
All Apex “after” triggers
Assignment rules
Auto-response rules
Workflow rules
Escalation rules
Parent Rollup Summary Formula value updated (if present)
Database commit
Post-commit logic (sending email)
Additional notes: There is no way to control the order of execution within each group above.
21. If one object in Salesforce have 2 triggers which runs “before insert”. Is there any way to control the sequence of execution of these triggers?
Ans : Salesforce.com has documented that trigger sequence cannot be predefined. As a best practice create one trigger per object and use comment blocks
to separate different logic blocks. By having all logic in one trigger you may also be able to optimize on your SOQL queries.
22. How to delete the User from Salesforce?
Ans : As per now, salesforce does not allow to delete any user, however you can deactivate the user.
Read further…
23. How to delete the users data from Salesforce?
Ans : 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.
24. How to restrict the user to see any record, lets say opportunity?
Ans : set up opportunity sharing to be private.  If both users are admins or have view all records on opportunity, then that overrides private sharing.
25. What is the difference between trigger.new and trigger.old in Apex – SFDC?
Ans :
Trigger.new :
Returns a list of the new versions of the sObject records.
Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
Trigger.old :
Returns a list of the old versions of the sObject records.
Note that this sObject list is only available in update and delete triggers.
26. How to restrict any Trigger to fire only once OR how we can avoid repeated or multiple execution of Trigger?
Ans:
Triggers can fire twice, once before workflows and once after workflows, this is documented at
http://www.salesforce.com/us/developer/docs/apexcode/ Content/ apex_triggers_order_of_execution.htm:
“The before and after triggers fire one more time only if something needs to be updated. If the fields have already been set to a value, the triggers are not
fired again.”
Workaround:
Add a static boolean variable to a class, and check its value within the affected triggers.

public class HelperClass {
   public static boolean firstRun = true;
}
trigger affectedTrigger on Account (before delete, after delete, after undelete) {
    if(Trigger.isBefore){
        if(Trigger.isDelete){
            if(HelperClass.firstRun){
                Trigger.old[0].addError('Before Account Delete Error');
                HelperClass.firstRun=false;
            }
        }
    }
}

27.  What is difference between WhoId and WhatId in the Data Model of Task ?
Ans :
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
Check Data Model of task here

28. Where is the option of the report for the “Custom Object with related object” and what are the condition to generate related reports?
Ans :
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 enable.
Both object must be related either using Lookup or Master Detail type of field.
Read this article, to get detailed idea on this topic.

29. How you can provide the User Login (Authentication) in Public sites created by Salesforce.
Answer : We can provide the authentication on public sites using “Customer Portal”.

30 : What is the dynamic Apex?
Ans :
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”.
31 : How to get the list of all available sobject in salesforce database using Apex (Dynamic Apex)?
Ans:
Map<String, Schema.SObjectType> m =  Schema.getGlobalDescribe();
32 : How to create instance of sobject dynamically? Normally the sobject is created like “Account a = new Account();”. But if you are in situation that you
don’t know which sobject is going to be instantiated ? Means it will be decided at runtime, how you will handle it? Hint : Use Dynamic Apex.
Ans:
public SObject getNewSobject(String t)
{
    // Call global describe to get the map of string to token.
    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    // Get the token for the sobject based on the type.
    Schema.SObjectType st = gd.get(t);
    // Instantiate the sobject from the token.
    Sobject s = st.newSobject();
    return s;
}
33 : How to get all the fields of sObject using dynamic Apex?
Ans:
Map<String, Schema.SObjectType> m  = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get('API_Name_Of_SObject') ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
34 : How to get all the required fields of sObject dynamically?
Ans:
There is no direct property available in Apex dynamic API to represent the required field. However there is another way to know about it.
If any field have below three properties then it is mandatory field.
If it is Creatable
If it is not nillable and
If it does not have any default value
Map<String, Schema.SObjectType> m  = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get(so.apiName) ;
Schema.DescribeSObjectResult r = s.getDescribe() ;
Map<String,Schema.SObjectField> fields = r.fields.getMap() ;
for(String f : fields.keyset())
{
    Schema.DescribeFieldResult desribeResult = fields.get(f).getDescribe();
    if( desribeResult.isCreateable()  && !desribeResult.isNillable() && !desribeResult.isDefaultedOnCreate() )
    {
//This is mandatory / required field
    }
}
35 : How to display error messages in the visualforce page ?
Ans:
In Apex use below code to create the error message for visualforce.
1
Apexpages.addMessage( new ApexPages.Message (ApexPages.Severity.ERROR, 'Required fields are missing. '));
in Visualforce page add below tag where you want to display the error message.
<apex:pageMessages ></apex:pageMessages>
36 : What is property in Apex? Explain with advantages.
Ans:
Apex mainly consist of the syntax from the well known programming language Java. As a practice of encapsulation in java we declare any variable as private
and then creates the setters and getters for that variable.
private String name;
public void setName(String n)
{
  name = n;
}
public String getName()
{
 return name;
}
However, the Apex introduced the new concept of property from language C# as shown below:
public String name {get; set;}
As we can see how simple the code is and instead of using nearly 8 to 11 lines all done in 1 line only. It will be very useful when lots of member is
declared in Apex class. It has another advantage in “number of lines of code” limit by salesforce which will drastically reduced.
37 : What is the controller extension ?
Ans:
Any apex class having a public constructor with Custom Controller or Standard Controller object as a single argument is known as controller extension.
38 : Explain the need or importance of the controller extension.
Ans:
Controller extension is very useful and important concept introduced by the salesforce recently. It gives the power to programmer to extend the functionality
of existing custom controller or standard controller.
A Visualforce can have a single Custom controller or standard controller but many controller extensions.
we can say that the custom extension is the supporter of custom or standard controller.
Consider one example : If there is one controller written and used by the multiple visualforce pages and one of them needs some extra logic. Then instead of
writing that logic to controller class (Which is used by many visualforce pages) we can create a controller extension and apply to that page only.
39 : How to read the parameter value from the URL in Apex?
Ans:
Consider that the parameter name is “RecordType”.
String recordType = Apexpages.currentPage().getParameters().get('RecordType');

Visualforce Interview Questions and Answers

Q). What are expressions used in pages  to bind in controllers?
      Using methods we can bind.
     Getter:Will return value from controller to vf page
     Setter:Will pass value from vf page to controller
     Action:Will redirect to another page.

Q). What is the purpose of controllers?
 Controllers provide the data and actions that are available to a Visualforce page.

Q). Which objects have associated standard controllers?
 All standard and custom objects that can be accessed via the API have associated controllers

Q). What is included with each standard controller?
  Data: the fields for the associated object record that are API accessible, including the related records (5 up/1 down).  Actions: save, delete, view, edit,
  cancel.

Q). When do you need to go beyond a standard controller and code custom Apex?
 If you need data beyond the limits of what is available in the standard controller or actions that go beyond the provided standard actions.

Q).Compare and contrast custom controllers and controller extensions.  How are they the same?  How are they different?

Both allow for custom code to be used, allowing for custom data sets and custom actions.  Extensions leverage the existing data and actions within a standard
or custom controller.  Custom controllers must contain all data and actions that need to be executed by the page.  Extensions that extend standard controller
allow for the pages which use those extensions to be used in custom buttons, standard button overrides, and over declarative features.

Q), What identifies a controller as being an extension?
The controller must declare a constructor which takes another controller explicitly.  For example: public myControllerExtension(ApexPages.StandardController
stdController) {this.acct = (Account)stdController.getRecord();  }

Q). Why are properties helpful in controllers
Properties can automatically create standard getters and setters while still allowing for their customizations.  They save you from both writing the tedious
code and reading the clutter when reviewing code.

Q).In what order do methods fire within a controller?
The only rule is that setters fire before action methods.  Aside from that, there is no guaranteed order.

Q).What are some Apex classes that are commonly used within controllers?
StandardController, SelectOption, PageReference, Message, etc.

Q).   How are wizard controllers different from other controllers?
The two main issues is that they must handle multiple pages and they must maintain the state across those pages.

Q). What are the effects of using the transient key word?
The transient key word prevents the data from being saved into the view state.  This should be used for very temporary variables.

Q). When is a component controller required for custom components?
A component controller is required when business logic is required to decide how to render the component.

Q), What kind of content can be included in a Visualforce page?
Any content that can be rendered in a browser (HTML, JavaScript, etc.).

Q). What do {!expressions} refer to when used in Visualforce components?
Expressions refer to either data or actions that are made available to the page from the controller

Q).What are the ways that Visualpages can be incorporated into the rest of your user interface?
Basically, via links, buttons, tabs, and inline frames.

Q), Is it always necessary to know Apex to create Visualforce pages?  When does it become necessary?
No, it is not always necessary.  You can use standard controllers and VF component tags to accomplish quite a bit.  Apex becomes necessary when you need either
a custom set of data or custom actions to be available from the page.


Q).  What are attributes?  What is the syntax for including them?
Attributes are modifiers to the main tag that belong after the tag name in the start tag.  The syntax is attributeName=“attributeValue”

Q). What are three types of bindings used in Visualforce?  What does each refer to?
Data bindings refer to the data set in the controller.
Action bindings refer to action methods in the controller.
Component bindings refer to other Visualforce components

Q).What is the main difference between using dataTable vs. pageBlockTable tags?
 PageBlock: For default salesforce standard format.
dataTable:To design customformats

Q).Which tag is used with both radio buttons and picklists to create the selectable values?
 <Apex:selectoption> tag

Q).How many controllers can a page have?  Where is the controller for a page assigned?
One main controller (of course, it could have extensions or custom components could have controllers, etc.).  The controller is assigned in the <apex:page> tag.

Q).There are a series of layout components that all help recreate the traditional Salesforce page layout style very easily.  What name do they share?
   pageBlock.

Q), Which tags should be used to automatically bring in the Salesforce label and default widget for a field?
Pageblock

Q). What are static resources?
Static resources are a new type of storage in Salesforce specifically designed for use in Visualforce pages.  They are ways to store images, flash files,
stylesheets, and other web resources on the Salesforce servers that can be cached for better page performance.

Q). What are some examples of JavaScript Events?
 Onmouseover, onclieck etc.

Q). What is AJAX typically used for in Visualforce
AJAX is primarily used for partial page updates in Visualforce.  In s-controls, the AJAX toolkit was the soap (XML over HTTP) client that gave you access to
the force.com Web Services API.

Q). What is the purpose of <script> tags?
Script tags allow you to create JavaScript (or other types) functions that can be used within your pages

Q), What are the different AJAX action tags?  What does each do?
·         actionStatus: used to display start and stop statuses of AJAX requests.
·         actionSupport: used to call a second component when an event happens to the first component.
·         actionPoller: similar to actionSupport, but the event is based on a timer instead of a user action.
·         actionFunction: provides support for invoking a controller action from JavaScript code using an AJAX request by defining a new JavaScript function.
·         actionRegion: used to demarcate which parts of the page the server should reprocess.

Q), How can you create partial page refreshes?
 Basically, you need to define the section of the page that is going to refresh (typically with a panel of sorts), and then define the event that will cause
 the refresh.  The method changes depending on if the area being refreshed is the same as the one handling the event.  It also depends on if you are
 just processing something on the server, or if you need the UI to change.

Q). Which tag is used with both radio buttons and picklists to create the selectable values?<apex:selectOption>

Q). What is the purpose of creating attributes on components?
 By allowing the component to take parameters via an attribute, you can make the component more flexible and reusable

Q). How can you access visualforce components values into a JavaScript?
Using Component global variable, we can access visualforce components in javascript. Let us suppose, we want to use id of an apex field with id=”afield”.
So, we can use the {!$Component.afield} syntax to use properties of the field in javascript.
Let us suppose, we want to store the field’s value in java script, then we can use like below:
<script>
Var a =’ document.getElementById('{!$component.afield}').value’;
</script>

Q), What are the Gov Limits in Salesforce.com?
Because Apex runs in a multitenant environment, the Apex runtime engine strictly enforces a     number of limits to ensure that runaway scripts do not
monopolize shared resources. These limits, or governors, track and enforce the statistics outlined in the following table. If a script ever exceeds a limit,
the associated governor issues a runtime exception that cannot be handled.

Q).What are the Global Key words?
We have global keywords like component,User,url,current page etc., to access various values from      components on page, from user object or from url or
from current page fields. To access value from each source, we have different global keywords. One such keyword is explained in above question(!$component)
Various global keywords are:
i. URL
ii.USER
iii. PROFILE
iv. Resource
v. Component
vi.Current page
vii.Page reference etc.

Basic concepts and Interview Questions of salesforce, Visualforce, Apex and SOQL
40. What is Master Detail relationship and look up relationship in Salesforce?
Ans:
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, AVG, MIN 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.
41. Can we convert the lookup relationship to Master Detail relationship?
Ans:
We can convert the lookup relationship to master detail relationship if and only if all the existing record has valid lookup field.
42. In How many way we can invoke the Apex class?
Ans:
Visualforce page
Trigger
Web Services
Email Services
More
43. Can we create Master Detail relationship on existing records?
Ans:
No. As discussed above, first we have to create the lookup relationship then populate the value on all existing record and then convert it.
44. How validation rules executed? is it page layout / Visualforce dependent?
Ans :
The validation rules run at the data model level, so they are not affected by the UI. Any record that is saved in Salesforce will run through the validation
rules.
45. What is the difference between database.insert and insert ?
Ans:
insert is the DML statement which is same as databse.insert. However, database.insert gives more flexibility like rollback, default assignment rules etc.
 we can achieve the database.insert behavior in insert by using the method setOptions(Database.DMLOptions)
Important Difference:
If we use the DML statement (insert), then in bulk operation if error occurs, the execution will stop and Apex code throws an error which can be handled in
 try catch block.
If DML database methods (Database.insert) used, then if error occurs the remaining records will be inserted / updated means partial DML operation will be done.
46. What is the scope of static variable ?
Ans:
When you declare a method or variable as static, it’s initialized only once when a class is loaded. Static variables aren’t transmitted as part of the view
state for a Visualforce page.
Static variables are only static within the scope of the request. They are not static across the server, or across the entire organization.
47. Other than SOQL and SOSL what is other way to get custom settings?
Ans:
Other than SOQL or SOSL, Custom seting have there own set of methods to access the record.
For example : if there is custom setting of name ISO_Country,
1
SO_Country__c code = ISO_Country__c.getInstance("˜INDIA');
2
//To return a map of data sets defined for the custom object (all records in the custom object), //you would use:
3
Map<String,ISO_Country__c> mapCodes = ISO_Country__c.getAll();
4
// display the ISO code for India
5
System.debug("˜ISO Code: "˜+mapCodes.get("˜INDIA').ISO_Code__c);
6
//Alternatively you can return the map as a list:
7
List<String> listCodes = ISO_Country__c.getAll().values();
48. What happen if child have two master records and one is deleted?
Ans :
Child record will be deleted.
read more in this article.
49. What is Difference in render, rerender and renderas attributes of visualforce?
Ans:
render – It works like “display” property of CSS. Used to show or hide element.
rerender – After Ajax which component should be refreshed – available on commandlink, commandbutton, actionsupport etc.
renderas – render page as pdf, doc and excel.
50. What is Scheduler class in Apex and explain how to use Crone statement to Schedule Apex class?
Ans:
The Apex class which is programed to run at pre defined interval.
Class must implement schedulable interface and it contains method named execute().
There are two ways to invoke schedular :
Using UI
Using System.schedule
The class 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);
To see how to make crone job string – Refer this Online Crone Expression Generator tool .
Note : Salesforce only accepts integer in Seconds and Minutes. So, lets say if you want to run Apex job on every 10 minutes, crone statement
 will be ‘0 0/10 * 1/1 * ? *’ and salesforce will throw an error saying “System.StringException: Seconds and minutes must be specified as integers“.
That mean like Time based Workflow, minimum interval to schedule job is 1 hour.

51. Explain Permission sets released in Winter 12.
Ans :
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.
52. What is the difference between External ID and Unique ID?
Ans:
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 reccomended, 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 absenor 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” i 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.
Salesforce - External Id option while creating field
Salesforce – External Id option while creating field
53. How to get the picklist value in Apex class?
Ans :
Using Dynamic apex, we can achieve this.on object of type pickilist, call getDescribe(). then call the getPicklistValues() method. iterate over result
and create a list. bind it to <apex:selectOptions>.
54. What are the types of controller in visual force?
Ans :
There are basically two types of Controller in Visual force page.
Standard Controller and
Custom Controller
55. How many Controllers can be used on single VF page?
Ans :
Only one controller can be used salesforce. Other than them, Controller extension can be used. There may be more than one Controller extention.
Example :
1
<apex:page standardController="Account"
2
extensions="ExtOne,ExtTwo" showHeader="false">
3
<apex:outputText value="{!foo}" />
4
</apex:page>
if ExtOne and ExtTwo, both have the method getFoo() then the method of ExtOne will be executed.
A controller extension is any Apex class that contains a constructor that takes a single argument of type ApexPages.StandardController or CustomControllerName,
where CustomControllerName is the name of a custom controller that you want to extend.
56. Explain System.runAs()
Ans :
Generally, all Apex code runs in system mode, and the permissions and record sharing of the current user are not taken into account. The system method,
 System.runAs(), lets you write test methods that change user contexts to either an existing user or a new user. All of that user’s record sharing is then
 enforced. You can only use runAs in a test method. The original system context is started again after all runAs() test methods complete.
Example :
1
System.runAs(u) {
2
// The following code runs as user 'u'
3
System.debug('Current User: ' + UserInfo.getUserName());
4
System.debug('Current Profile: ' + UserInfo.getProfileId()); }
5
// Run some code that checks record sharing
6
}
57. Explain Test.setPage().
Ans:
It is used to set the context to current page, normally used for testing the visual force controller.
58. What is the custom settings ?
Ans :
Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data
for an organization, profile, or specific user. All custom settings data is exposed in the application cache, which enables efficient access without
the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, Apex, and the Web services API.
59. Types of the custom settings?
Ans :
List Custom Settings
A type of custom setting that provides a reusable set of static data that can be accessed across your organization. If you use a particular set of data
frequently within your application, putting that data in a list custom setting streamlines access to it. Data in list settings does not vary with profile or
 user, but is available organization-wide. Examples of list data include two-letter state abbreviations, international dialing prefixes, and catalog numbers
 for products. Because the data is cached, access is low-cost and efficient: you don’t have to use SOQL queries that count against your governor limits.
Hierarchy Custom Settings
A type of custom setting that uses a built-in hierarchical logic that lets you “personalize” settings for specific profiles or users. The hierarchy logic
checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,” value. In the hierarchy, settings
for an organization are overridden by profile settings, which, in turn, are overridden by user settings.
60. Difference between SOSL and SOQL in Salesforce ?
Ans :
SOSL
SOQL
stands for "Salesforce object search language". stands for "Salesforce object query language".
Works on multiple object at a same time. Need to write different SOQL for different object.
All fields are already text indexed. SOQL against same field will be slow.
Cannot used in Triggers. Can only be used in Apex class and anonymous block. Can be used in Apex class and Triggers.

61. How to round the double to two decimal places in Apex?
Ans:
1
Decimal d = 100/3;
2
Double ans = d.setScale(2) ;
62.In Profile settings, what is difference between “Modify All Data” and “Modify All” ?
Ans:
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.
63. If i want record level access then what should i use from Salesforce security model?
Ans: Manual Sharing
63. If i want Object level access then what should i use from Salesforce security model?
Ans: Profile
64. In OWD (Organization wide sharing), can i change the setting “Grant Access Using Hierarchies” for Standard Objects ?
Ans: You cannot change it for Standard Objects However for Custom Objects its possible.
65. What is Mandatory while creating User, Role or Profile?
Ans : Its Profile.
66. In case of Master-Detail relationship, on Update of master record can we update the field of child record using workflow rule?
Ans: No
67. In case of Master-Detail relationship, on Update of child record can we update the field of Parent record using workflow rule?
Ans: Yes, the Master fields are also available for “Criteria evaluation”.
68. While setting OWD (Organization wide sharing), can we change/modify the setting of child record in case of Master-Detail relationship?
Ans: No, Child record is controlled by the Parents setting.
69. What is the need of “Custom Controller” in Visualforce as everything can be done by the combination of Standard Controller + Extension class.
Ans :
Sharing setting is applied on standard object/extension by default; In case we don’t want to apply sharing setting in our code then Custom controller is
only option.
It is possible that the functionality of page does not required any Standard object or may require more than one standard object, then in that case Custom
controller is required.
70. In class declaration if we don’t write keyword “with sharing” then it runs in system mode then why keyword “without sharing” is introduced in apex?
Ans:
Lets take example, there is classA declared using “with sharing” and it calls classB method. classB is not declared with any keyword then by default
 “with sharing” will be applied to that class because originating call is done through classA. To avoid this we have to explicitly define classB with
 keyword “without sharing”.

 71. If user doesn’t have any right on particular record and have only read level access at object level. Can he change the record owner?
Ans : Yes. In profile, there is setting for “Transfer Record”.
72. In Which Scenario share object “MyCustomObject__share” is not available/created for custom object “MyCustomObject” ?
Ans: The object’s organization-wide default access level must not be set to the most permissive access level. For custom objects, this is Public Read/Write.
 For more information, see Access Levels. This object is used for creating Apex based sharing.
73. How to hide the “App Setup” Menu from user’s setup page?
Ans : In Profile, remove access “View Setup and Configuration”.
74. While creating new profile for user, which existing profile should be copied?
Ans: If the new user is not System administrator then copy from “Standard User” profile.
75. Who can run reports?
Ans : Users with permission “Run Report” and access to report folder can only run the report.
76. What is Difference between “printable View” and “Export Details” button on report?
Ans:
Printable View: formatting, grouping and subtotals are persisted.
Export Details: formatting, grouping and subtotals are lost.
Salesforce Report - Printable view and Export Details
Salesforce Report – Printable view and Export Details
77. What is the use of “floating report header”?
Ans: If you have long tabular report, you can make the column header visible on each pages as you scroll, by enabling floating report headers.
78. How to enable “floating report header”?
Ans :
Go to “Setup | App Setup | Customize | Report and Dashboard | User Interface Settings “.
Click on checkbox “Enable Floating Report Headers”.
Salesforce Enable Floating Reports Headers
Salesforce Enable Floating Reports Headers
79. Which permission is required to set the running user other than you in dashboard?
Ans: “View All Data” in profile.
80. Who can access “drag and drop dashboard”?
Ans : User with permission “manage dashboard”.

81. Which type of report can be used for dashboard components?
Ans : Summary and matric report.
82. How many types of dashboard components are available?
Ans : Chart, Table, Metric and Gauge.
83. Explain dynamic Dashboard.
Ans : Dashboard which is running under current logged in user permission are known as “dynamic Dasboard”. At the most 3 dynamic dashboards can be built.
Available in Unlimited, Enterprise and developer edition. This type of dashboard cannot be scheduled for refresh. IT must be scheduled manually.
84. What is the default timeout period while calling webservice from Apex.
Ans : 10 sec.
Read more at  –
http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_callouts_timeouts.htm
85. A single Apex transaction can make how many callouts to an HTTP request or an API call ?
Ans : Maximum 100 callouts
86. How to increase timeout while calling web service from Apex ?
Ans :
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds
87. How to show loading image while Ajax call in Visualforce? OR how to show image in <apex:actionStatus> tag in Visualforce?
Ans:
<div style="position:absolute;top:20px;left: 50%;">
            <apex:actionStatus id="refreshContent" >
               <apex:facet name="start" >
                <apex:image url="{!$Resource.LoadingImage}" />
               </apex:facet>
             </apex:actionStatus>
         </div>
88. What is analytic Snapshot in salesforce?
Ans : 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 a source report.
It does not support matrix report. The field type in target object must be same as source report object field.

111 : How to get the Recordtype Id using Dynamic Apex?
Ans:
Normally to get the RecordtypeId for any sObject we use SOQL and it will count against your limit. So below method will bypass the need of SOQL Query.
Map<String, Schema.SObjectType> m  = Schema.getGlobalDescribe() ;
Schema.SObjectType s = m.get('API_Name_Of_SObject') ;
Schema.DescribeSObjectResult cfrSchema = s.getDescribe() ;
Map<String,Schema.RecordTypeInfo> RecordTypeInfo = cfrSchema.getRecordTypeInfosByName();
Id rtId = RecordTypeInfo.get('Record Type Name').getRecordTypeId();
or
Schema.SObjectType.Object_API_Name__c.getRecordTypeInfosByName().get('recordtype name').getRecordTypeId()
112 : Write Apex code which will take the RecordID as input and on the basis of that it will print the Object name and field names of sObject.
Ans:
List<Schema.SObjectType> gd = Schema.getGlobalDescribe().Values();
Map<String,String> objectMap = new Map<String,String>();
for(Schema.SObjectType f : gd)
{
     objectMap.put(f.getDescribe().getKeyPrefix(), f.getDescribe().getName());
}
String sampleId ='00390000003LIVw';
String prefix =  sampleId.substring(0,3);
String objectName = objectMap.get(prefix);
System.debug('** SObject Name ** '+objectName);
Map<String, Schema.SObjectField> desResult = Schema.getGlobalDescribe().get(objectName).getDescribe().Fields.getMap();
List<String> fieldList = new List<String>();
fieldList.addAll(desResult.keySet());
for(integer i =0;i<fieldList.size();i++)
{
    System.debug('** Field Name ** '+fieldList[i]);
}
113. 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 acheive this?
Ans:
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 a
actual user.
114. How to get “https” link instead of “http” for Visualforce page using URLFOR() in Email Template ?
Ans: When you create the Link using URLFOR() in Email Template, it creates link in “http” format instead of “https” and thus causes end user to logged into

salesforce again.
So instead of
<a href='{!URLFOR('/apex/SomePage', null, [id=Some_Object__c.Id,retURL="/apex/SomeOtherPage"])}'>Go to SomePage here!</a>
We can use something like :
<a href='{!SUBSTITUTE(URLFOR('/apex/SomePage', null, [id=Some_Object__c.Id,retURL="/apex/SomeOtherPage"]),'http:','https:')}'>Go to SomePage here!</a>

121 : Consider we have overall 90% code coverage however there is one class which have 0% code coverage. Can we still able to deploy that class on production?
Ans : Yes. Minimum 1% required for every trigger and there is no such restriction for Apex class.
122 : How to get selected records ID from List View using Javascript / Ajax Toolkit, when custom button is added on List View page?
Ans : Create a new Button on Lead of type List Button. Add the button on Lead List View Layout and write below Javascript code:
{!RequireScript("/js/functions.js")}
var recordsSelected = {!GetRecordIds($ObjectType.Lead)}
for(var i=0; i < recordsSelected .length ; i++) {
     alert('Selected ID '+recordsSelected[i]);
}
123 : In Ajax toolkit for custom Javascript button, you have to explicitly login to API because global Session variable is not available. In that case
it is security vulnerable because anybody logged in can see the javascript code and your username and password. So is there any way to avoid this?
Ans: We can create a visualforce page with output type as JavaScript. Global session variable is available in VF page. Initialize the global javascript
variable in that VF page. include VF page as a javascript file and we are done!
124 : In Custom Component How we can return value to Custom Controller or Controller Extension?
Ans: In Apex, Objects are passed by reference (read this article to understand Pass by Value and Pass by reference in Salesforce and also read this Salesforce
 blog article). So supply an argument of wrapper class (object) type to custom component. If its value is changed in Custom component we will get updated value
 in controller also.
125 : Lets consider you had created outbound changeset previously. After that, some class is modified which is part of that old changeset. Can you reuse same
changeset to deployed changed component ?
Ans : Once changeset is created it cannot be modified. After creation of changset, if we modify any component it will not reflected and we need to clone the
changeset to reflect changes. More information available here.
126 : 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?
Ans : Even after deactivation of workflow, its action will be active in queue.
127 : We have “Time Based Workflow” and there is action scheduled to be executed. Can we delete that workflow?
Ans : If a workflow have any pending time dependent action, then we cannot delete the workflow.
128 : How to clear the Time based workflow action queue ?
Ans : 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.
129 : In trigger, lets say we have system.debug() statement after adderror() method. Will system.debug() be statement executed in Trigger after adderror()
method?
Ans: adderror() method is not error statement rather its normal execution flow and all the statements written after adderror() will be executed normally.


131. What will happen if you try to update record in After Trigger Context?
Ans : You will get an error saying “record is Read only”.
132. Let’s say we have to update the same record in After Trigger context. Is there any way or workaround?
Ans : If we create a new instance of an SObject in the Apex Trigger in memory using the Id of the newly created record as provided in the After Trigger context,
 we can perform an Update DML statement and not get a read only error. This is because in Apex, the SObject is seen as a
 new reference (even though the records have the same SFDC ID) and therefore is eligible for DML operations. The below snippet of code
 illustrated this working and not working.

List<Contact> originals = new List<Contact>();
if(mirrorResultMap.values().size() > 0)
{
    for(Contact origContact : contactRecs.values())
    {
        Contact mirrorContact = mirrorResultMap.get(origContact.Id);
        //origContact.Linked_Contact__c = mirrorContact.Id; //Link the Original Record tot he Mirror Record WILL FAIL
        Contact origContactUpdate = new Contact(Id=origContact.Id, Linked_Contact__c = mirrorContact.Id); //This will WORK
        originals.add(origContactUpdate);
    }
    //update contactRecs.values(); //Update the Records -> THIS WILL FAIL AS ITS ORIGINAL RECORDS IN MEMORY
    update originals;

}
Credit goes to Cory Cowgill for this Blog Entry.
133 . 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 ?
Ans :
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.
134 : System.debug() statements are included against script count?
Ans : Any statement ending with semi-colon will be included against script count. There is very good article by Abhinav explaining this here.
135 : While trying to access javascript code from some CDN like Google, we get error something like “attempt to run uG request”. How to resolve it ?
Ans : While providing URL, do not specify the protocol. Use like this:
1
<script type='text/javascript' src= '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'></script>
136 : Explain ActionFunction, ActionSupport and ActionPoller in Visualforce.
Ans:
apex:ActionFunction : This component helps to envoke AJAX request (Call Controllers method) directly from Javascript method. It must be child of apex:form.
Read here – www.salesforce.com/us/developer/docs/pages/Content/pages_compref_actionFunction.htm
apex:ActionSupport : This component adds Ajax request to any other Visualforce component. Example : Commandlink button has inbuilt AJAX functionality however
few components like OutputPanel does not have inbuilt AJAX capabilities. So with the help of this component, we can enable AJAX. Read more here.
apex:ActionPoller : This is timer component which can send AJAX request on pre-defined interval. Minimum interval is 5 sec and default is 60 sec.
137 : In how many ways you can invoke Controllers / Controller Extensions method from VF?
Ans : Javascript Remoting, ActionFunction, ActionSupport, ActionPoller.
138 : What is the use of apex:detail component ?
Ans : With the help of this Visualforce component, we can diretly get complete behavior of page layout defined for logged in users profile. There is no need
to
 add fields, related lists explicitly. Read more here.
139 : What is the difference between “apex:dataTable” and “apex:pageBlockTable” components in Visualforce?
Ans : Both component is used to render data in tabular format. dataTable will render records in simple HTML table format whereas the “pageBlockTable” possess
default look and feel of salesforce standard CSS and must be written inside “apex:pageBlock” componet.
You can read more here.
140 : User have all the permissions to see the Dashboard and Source Folder still when he wants to see dashboard, its not visible. What might be the cause?
Ans : It is possible that Salesforce User license for Dashbaord running user is different than User wants to access Dashboard. Example – Running User license
is “Salesforce” and user trying to access Dashboard is “Salesforce Plateform”.

141 : User Wants to set the starting day in Calendar as “Monday” instead of “Sunday”. How to get it done?
Ans : Change the user locale to “English ( United Kingdom ) ” in Personal information or User record.
142 : Why CSS is not working in PDF created by Visualforce ?
Ans : In Many cases, i have observed problems faced by my colleagues and complaining that CSS is not working when they try to render any Visualforce page as
“PDF”. Same Question is asked many times in Interviews also. Basically there are two ways:
Use “apex:stylesheet” tag to import external CSS file
Wrap “Style” tag inside “Head” tag in Visualforce
143 : How to get Ip Address of User in Apex?
Ans :
String ipAddress = ApexPages.currentPage().getHeaders().get('X-Salesforce-SIP');
True-Client-IP has the value when the request is coming via the caching integration.
X-Salesforce-SIP has the value if there is no caching integration (sandbox, developer edition orgs) or via the secure url.
Thanks to TechNrd for this tips.
144 : How to get total number of Child records in Lookup relationship?
Ans: As Rollup Summary field is only supported in Master detail, we cannot use it for Lookup. There are following two ways (If anyone has any other idea
please comment).
Inline Visualforce page
Trigger on Child Object, which will update field in Parent record if child record is inserted, deleted or undeleted.
145 : System admin has created a Visualforce for Account. In future he created few more new Fields. How could System admin can code Visualforce so that in
future if any new field is added or existing field deleted. It should reflect in Visualforce without changing anycode?
Ans : It can be done with help of Field Sets. Please read this article.
146 : Once you convert lead, Few fields on lead should be reset so that sensitive information should not be queried using SOQL. How to get this done?
Ans : Once lead is converted, its READ ONLY. we cannot update it using Apex or Trigger. However we can use “Before Update” trigger on lead and check for
 fiels “IsConverted“. If its true means lead is going to be converted so reset all fields in that case.
147 : How to convert carriage returns in Textarea to Line Breaks in Visualforce?
Ans : We can use “<apex:outputField>” instead of “<apex:outputText>”. It will maintain formatting automatically.
148 : How to handle comma within field while uploading using DataLoader ?
Ans : Data Loader cannot handle this implicitly because there is no logical path to follow. In case your Data Loader CSV file for import will contain commas
for any of the field content, you will have to enclose the contents within double quotation marks ” “. Data Loader will be able to handle this.
For example :
1
Column_1__c,Column_2__c,Column_3__c
2
Shiva,"Jitendra, Minal",Soft
If you are creating the import CSV in Excel, the quotation marks will be inserted automatically by Excel whenever a comma is detected in any cell – Saving the
CSV in Excel and opening the same in Notepad reveals the enclosing quotation marks for cells containing commas.
149 : In Master Detail Relationship :
OWD for Parent is public Read Only.
If User has – Create, Edit Permission on Master as well as Detail Object.
While creating record for detail object he selects parent record which is not created by him. What will happen in this case ?
Ans : He will get an error, because in order to add child record user must have edit permission in parent master record.
150 : Difference in “Export” and “Export All” in Data Loader in Salesforce?
Ans :
Export : It is used to export the Salesforce Data(excluding recycle bin’s data) into your local system.
Export All :  It is used to export the Salesforce Data(including recycle bin’s data) into your local system.

151. Give Sample Code Snippet of Apex that that will show that how Parent and Child record can be inserted in Single Statement ?
Ans : It can be done with help of External Id.
Date dt = Date.today().addDays(7);
Opportunity newOpportunity = new Opportunity(Name = 'shivasoft', StageName = 'Prospecting', CloseDate = dt);
/*
Create the parent reference.
Used only for foreign key reference  and doesn't contain any other fields. If we provide any other value it will give following error
System.DmlException: Insert failed. First exception on row 1; first error: INVALID_FIELD,
More than 1 field provided in an external foreign key reference in entity: Account: []
*/
Account accountReference = new Account(MyExtID__c = 'SHIVA1234567');
newOpportunity.Account = accountReference;
//  Create the Account object to insert.  Same as above but has Name field.  Used for the insert.
Account parentAccount = new Account(Name = 'Shiva', MyExtID__c = 'SHIVA1234567');
Database.SaveResult[]
    results = Database.insert(new SObject[] {  parentAccount, newOpportunity });
152 . Which SOQL statement can be used to get all records even from recycle bin or Achieved Activities?
Ans : We will need “ALL Rows” clause of SOQL.
Sample :
1
SELECT COUNT() FROM Contact WHERE AccountId = a.Id ALL ROWS
153. How can you lock record using SOQL so that it cannot be modified by other user.
Ans : we will need “FOR UPDATE” clause of SOQL.
Sample :
1
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
154. If you set more than one savepoint, then roll back to a savepoint that is not the last savepoint you generated,
What will happen to later savepoint variables ?
Ans : if you generated savepoint SP1 first, savepoint SP2 after that, and then you rolled back to SP1, the variable
SP2 would no longer be valid. You will receive a runtime error if you try to use it.
155. What are few limitations (points to remember) of Savepoint or Transaction Control in Apex ?
Ans :
Each savepoint you set counts against the governor limit for DML statements.
Static variables are not reverted during a rollback. If you try to run the trigger again, the static variables retain the values from the first run.
Each rollback counts against the governor limit for DML statements. You will receive a Runtime error if you try to rollback the database additional times.
The ID on an sObject inserted after setting a savepoint is not cleared after a rollback.
156. What are few Considerations about Trigger ?
Ans :
upsert triggers fire both before and after insert or before and after update triggers as appropriate.
merge triggers fire both before and after delete triggers for the losing records and before update triggers for the winning record only.
Triggers that execute after a record has been undeleted only work with specific objects.
Field history is not recorded until the end of a trigger. If you query field history in a trigger, you will not see any history for the current transaction.
You can only use the webService keyword in a trigger when it is in a method defined as asynchronous; that is, when the method is defined with the
@future keyword.
A trigger invoked by an insert, delete, or update of a recurring event or recurring task results in a runtime error when the trigger is called in bulk
from the Force.com API.
Merge trigger doesn’t fire there own trigger instead they fire delete and update of loosing and winning records respectively.
157. How to execute Apex from Custom button or Javascript ? Give Example.
Ans :
It is possible using Ajax toolkiit.

global class myClass {
    webService static Id makeContact (String lastName, Account a) {
        Contact c = new Contact(LastName = lastName, AccountId = a.Id);
        return c.id;
    }
}
we can execute above method from javascript like :
{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/33.0/apex.js")}
var account = sforce.sObject("Account");
var id = sforce.apex.execute("myClass" , "makeContact",
{lastName:"Smith", a:account});
To call a webService method with no parameters, use {} as the third parameter for sforce.apex.execute .
Also, you can use the following line to display a popup window with debugging information:
sforce.debug.trace=true;
158.  What is difference between public and global class in Apex ?
Ans :
Public class can be accessed within application or namespace. This is not exactly like public modifier in Java.
Global class visible everywhere , any application or namespace. WebService must be declared as Global and which can be accessed inside Javascript also.
It is like public modifier in Java.
159. Explain Considerations for Static keyword in Apex.
Ans :
Apex classes cannot be static.
Static allowed only in outer class.
Static variables not transferred as a part of View State.
Static variables and static block runs in order in which they are written in class.
Static variables are static only in scope of request.
160. Explain few considerations for @Future annotation in Apex.
Ans :
Method must be static
Cannot return anything ( Only Void )
To test @future methods, you should use startTest and stopTest to make it synchromouse inside Test class.
Parameter to @future method can only be primitive or collection of primitive data type.
Cannot be used inside VF in Constructor, Set or Get methods.
@future method cannot call other @future method.

201. Common Apex page attributes.
1
<apex:page sidebar="false" standardStylesheets="false" showHeader="false">
202. Declare Visualforce page as HTML5.
1
<apex:page docType="html-5.0" />
203. Visualforce page output as JSON.
1
<apex:page controller="ControllerName"  contentType="application/x-JavaScript; charset=utf-8"showHeader="false" standardStylesheets="false" sidebar="false">
2
{!jsonString}
3
</apex:page>
204. How to refer static resources in Visualforce.
CSS File :
1
<apex:stylesheet value="{!URLFOR($Resource.style_resources, 'styles.css')}"/>
Relative path in CSS from static resource, You can use relative paths in files in static resource archives to refer to other content within the archive.
1
table { background-image: img/testimage.gif }
Image tag:
1
<apex:image url="{!$Resource.TestImage}" width="50" height="50"/>
or
1
<apex:image url="{!URLFOR($Resource.TestZip, 'images/Bluehills.jpg')}" width="50" height="50"/>
Include Javascript in Visualforce from Static resource
1
<apex:image url="{!$Resource.TestImage}" width="50" height="50"/>
Refer static resource path from Aprx Controller
1
global class MyController {
2
    public String getImageName() {
3
        return 'Picture.gif';//this is the name of the image
4
    }
5
}
1
<apex:page renderAs="pdf" controller="MyController">
2
    <apex:variable var="imageVar" value="{!imageName}"/>
3
    <apex:image url="{!URLFOR($Resource.myZipFile, imageVar)}"/>
4
</apex:page>
205. How to get element id of Visualforce components to be used in Javascript ?
1
{!$Component.Parent1.Parent2.fieldId}
read more in this post.
206. Autogenerated Salesforce Id consist of colon, how to handle it in JQuery ?

var ele = $('[id="abc:xyz"]');
read more about problem here.
207. How to return Map result from SOQL query in Apex.
Map<ID, Contact> m = new Map<ID, Contact>([SELECT Id, LastName FROM Contact]);
208. How to query and abort scheduled job using Apex.
While updating class on Sandboxes, chances are high that it is being used in any scheduler, so below code will abort all scheduled job.
If there are 150+ scheduled job,
 then you might want to use below code again and again in developer console until all jobs are removed from system.
//Limit is 150 because System.abortJob counted against DML
List<CronTrigger> abort_job = [SELECT Id FROM CronTrigger WHERE State != 'Deleted' limit 150];
    for (CronTrigger t : abort_job) { //for each record
     //try catch - to make sure one fail should not impact other jobs which needs to be cancelled
     try{
        System.abortJob(t.Id); //abort the job
     }catch(Exception e){}
    }
209. How to use standard Salesforce REST API from Visualforce page ?
Befor any Ajax call, make sure to add ‘Bearer’ token in header. If using JQuery use below code snippet. For more information read this post.
$.ajax({
          type: reqType,
          beforeSend: function (xhr)
                {
                    xhr.setRequestHeader("Authorization",  'Bearer {!$API.Session_ID}');
                },
          headers : {'Content-Type' : 'application/json; charset=utf-8'},
          url: postUrl,
          data: postData,
          dataType: 'text'
        })
         .done(function( data ) {
                //Code if success
          })
          .fail(function(xhr,textstatus,error){
             //Code if fail
          });

217 : How to capture errors after using Database DML methods in Salesforce?
Ans :
List<Contact> lstContact = new List<Contact>();
Contact con = new Contact (lastName = 'Zaa', SQL_Server_Id__c='3',firstName='Jitendra');
lstContact.add(con);
//.. Other Contact records added in List
Database.UpsertResult[] results = Database.upsert( lstSGAccOppInsert, Contact.SQL_Server_Id__c.getDescribe().getSObjectField() ,false ) ;
for(Integer i=0;i<results.size();i++){
    if (!results.get(i).isSuccess()){
        Database.Error err = results.get(i).getErrors().get(0);
        System.debug('Error - '+err.getMessage() + '\nStatus Code : '+err.getStatusCode()+'\n Fields : '+err.getFields());
    }
}

Sales force interview questions: Configuration

Production and Sandbox Environments
We should not modify the live application directly so we work in different environment for the changes of the existing application.
Salesforce Production related interview questions | Salesforce Sandbox related interview questions | Salesforce CRM related to Cloud Computing | Salesforce
Sandbox Types

1. What is Cloud Computing ?
Pictorial representation of internet is Cloud.
Cloud Computing is nothing but internet computing.
With this approach everything can be done in internet (Using Application, Developing Application and distributing the hardware), no need of any minimum
hardware requirementsand no need to install any software in local system.
Cloud Computing is an approach to provide the following services -
SAAS (Software As A Service)
PAAS (Platform As A Service)
IAAS (Infrastructure As A Service)
2. What is Salesforce?
Salesforce is a company which provides a web based tool called Salesforce
Salesforce by following the Cloud Computing approach, providing SAASand PAAS
SAAS: Providing Sales, Marketing and Call Center applications as a service
PAAS: Providing Force.com platform in which we can develop Apex (Programming language similar to Core Java) and Visualforce (Mark up language similar to HTML)
logic.
3. What is Production?
              We should not make coding changes in production since end-users are using the           application from production environment.
4. What is production url?
           login.salesforce.com
5. What is sandbox?
To make any changes for the exiting application we should copy all contents of the production into sandbox and make all changes after that test thoroughly
and move those changes into production.
To create the sandbox, in production we can find one link called sandboxes. by clicking on that link we can create the sandbox by choosing type of the sandbox.
6. What is sandbox url?
   test.salesforce.com
7. What are the types of Sandboxes?
Developer Sandbox
Developer pro sandbox
Partial data sandbox
Full copy sandbox
8. What is Developer sandbox?
It copy only configuration changes from the production
It won’t copy real time data
We can test the configuration changes with sample data
Sample data limit is 200mb
Refresh time interval is one day
If we refresh all the sandbox contents will be replaced with production contents
9. What is developer pro sandbox?
Copy configuration changes
No real time data
Sample data limit is 1GB
Refresh time interval one day
10. What is partial data sandbox?
Copy configuration changes
Copy certain amount of real time data
Real time data limit is 5GB
For each table it can copy maximum of 10k records
Refresh interval 5 days
11. What is Full copy sandbox?
It is exact replica of the production
Copy both configuration and entire real time data from the production
Refresh time interval 29 days
Configuration
Using point and click approach, we can configure the functionalities.
Salesforce Configuration Interview Questions | Salesforce Admin Interview Questions | Salesforce Administration Interview Questions | Salesforce point and
click Interview Questions
1. What is Track Field History?
While creating the object, we can enable 'Track Field History'.
If, we enable 'Track Field History' user can see 'Set History Tracking' button under 'Custom Fields & Relationships' section which is available on the object
detail page.
By clicking on 'Set History Tracking' button, we can enable tracking for the fields which ever we want.
To see the object history, go to object's record layout and add Object Name History related list to the layout.
Whenever, user changes field value from one value to another value, it will show the history of the field in 'Object History' related list.
2. What are the Activities in Salesforce?
To create the Activities, while creating the object, we should check for 'Allow Activities' check box then user can add open Activities and Activity History
related lists on the Object layout.
There are two types of activities -
Task: Task is nothing but work assigned to a particular person, it doesn't have certain time limit.
Event: It has certain time limit in that time only all persons should assemble after the time limit over, event will get complete.
- Once event or task status changed to 'Completed' then we can see those records under Activity History Related List.
3. How to Rename the tab?
Tab name will be decided based on the Plural Label of the custom object, to rename go to corresponding object detail page and rename the plural label.
4. How to display multiple columns after clicking on the tab?
Click on the tab(Which should be realted to any of the custom/standard object) > Expand Force.com Quick Access Menu > Edit Columns > Move the needed fields
from Available Fields to Selected Fields. > Click on Save > User should be able to see multiple columns.
(OR)
Click on Setup > Create > Objects > Select the corresponding object link > Under Search Layouts section > Click Edit which should be left to Object Tab >
Move the needed fields from Available Fields to Selected Fields. > Click on Save > User should be able to see multiple columns.
5. What is the difference between ISBLANK() AND ISNULL()?
ISNULL() works only for number data type fieds, if we don't populate with value for number fields it will return true.
ISNULL() won't support TEXT data type fields because text fields never become null.
ISBLANK() supports both number as well as text data types.
6. What is dependent picklist?
In some scenario's, we should be able to control one of the field(Dependent field) from another field(Controlling field), example If we select
Country(Controlling field) as US then City(Dependent Field) should display only US cities.
We can use checkbox data type fields also while creating dependent picklist (Note: Checkbox should be always controlling field)
We can use multi-select data type fields also while creating dependent picklist (Note: multi-select data type field should be always dependent field)
7. What is the architecture of the salesforce
MVC Architecutre - Model, View , Controller
View - It is the user interface (Apps, Tabs, Page Layouts, Fields and Record Types)
Controller - Business Logic (Save, Edit, New, Cancel and Delete - upon click on these button salesforce execute some logic from controller)
Model - It is the Database, which stores Schema (Meta-Data(Data about Data) --> Apps, Tabs, sObjects, fields, Apex Classes, Visualforce pages, etc...)
and Instance (Records)
8. What is the difference between 15 digit and 18 digit id in Salesforce?
In Salesforce, whenever user create any component (Object, field, tab etc...) or record then salesforce will generate an unique id with which user can
identify the record or component.
After creating the record, in the URL user can see the id of the record which is of 15 digits length.
Through user interface user always see 15 digit id which is Cases-Sensitive
.
If the user query the existing records from the database through API (Either from Query Tool or from a program), it will always return 18 digit id which is
Case-Insensitive.
Last 3 digits of the 18 digit represents checksum of the capitalization of 15 digit id.
Based on the first 3 digits user can identify the object of the record.
All the records belongs to same object will contain same firt 3 digits.
9. What is Record Type?
For an object based on the Record Type, we can show different fields and different picklist values by assigning different page layouts for the record types
and profiles.
After creating the record type, on the record type detail page user can see all the picklist data type fields, user can edit the picklist and decide which
values should display for this particular record type.
10. What is the difference between detail page and edit page?
Whenever user try to create a new record or edit an existing record user can input the values for the fields, this page is nothing but edit page.
After creating a new record or editing an existing record, user can see the information of the record, this page is nothing but detail page.
11. What is out of box functionality?
Within the sfdc standered functionality (no need to code).
12. What are the type of tabs?
Custom tabs (create for objects)
Web tabs (create to display a website)
Visual force tabs (create to display the visual force page)
13. What is validation rule?
While creating or modifying the record based on the certain conditions we can display error messages on top of the page or below to the filed.
14. There are two fields, if the user populate two field values if we combine those values uniqueness should be maintained, how to achieve this without coding?
Create a unique text field and update the field from workflow rule (use formula to update by combining two field values), after the update again all the system
 validations will be performed so error will be displayed.
15. What are Governor Limits?
Since we are working in multitenant environment Salesforce is enforcing the limits for all the functionalities.
Max. number of Master Detail relationships per an object: 2
Max. number of Relationship Fields per an object: 40 (Increased from 25 to 40 in Summer'14)
Max number of Roll-up Summary fields per an object: 25 (Click here for the Reference)
How many external ids we can enable for an object: 7 (increased from 3 to 7 in Winter'15)
16. For which data type we can enable external id?
            text, number, auto number, email.
17. What is list view?
After clicking on the tab on the top of the page we can see views, by default we can see the value called ‘all’. If we click on ‘Go’ beside that all we can see
 all the records of that object. If we want we can create new views. While creating the view we can give the filter conditions so that based on the filter
 condition only we can see the records.
18. What is Inline editing?
On the detail page without clicking on edit button we can edit particular field if it is not read-only.
19. How to disable Inline editing?
To enable or disable Inline editing follow the below navigation - Setup--> Customise--> User Interface--> Enable Inline Editing
20. What is Enhanced list view?
In list views we can modify multiple records at a time using Enhanced list views Note: To modify multiple records, all the records should belong to same
record type in the list view otherwise we cannot modify.
21. What is search layout?
Whenever we click on a tab or we click on a lookup icon or search for a record we see only one standard field by default, to enable remaining fields -
To show multiple fields for the records which display under a tab, on object detail page > under Search layouts edit tab and add required fields.
To show multiple fields for the records which display when we click on lookup of a field, on object detail page > under Search layouts edit Lookup Dialogs
and add required fields.
To show multiple fields for the records which display when we search for the records, on object detail page > under Search layouts edit Search Results and
add required fields.
22. What is mini page layout and how to enable?
For lookup fields on record detail page we see a link, whenever we put cursor on that link we see a popup window which displays few fields. To control the
fields visibility, on that look up field parent object page layout we see a mini page layout in that we can control.
23. What is lead process?
To control the picklist values of the status field on the lead object we should create lead process.
Without selecting the lead process we can't create the record type for lead object
24. What is sales process?
To control the picklist values of the stage field on the opportunity object we should create sales process.
Without selecting the sales process we can't create the record type for opportunity object
25. What is Support process?
To control the picklist values of the status field on the case object we should create support process.
Without selecting the support process we can't create the record type for case object
26. What is web-to-lead?
On lead object we can generate the HTML code by selecting lead fields and by mentioning return URL from web-to-lead option. The generated HTML code can be
hosted in any of the website. Upon entering the information in those fields and clicking on submit button that information will be saved into lead object of
the Salesforce.
27. What is Queue?
In queue we can add group of users and we can assign the objects to the Queue. After creating the queue one of the list view automatically created on the
objects which are selected for the queue. We can assign this queue as the owner of the records (objects which are selected for this queue). Later users who
are part of that queue can claim the ownership by navigating to list view corresponding to the queue. In that list view users who are part of the queue can
select the record and click on accept button so that record ownership will be transferred from queue to accepted person.
28. What is public group?
We can add set of random users in the public group. We can't assign public group as an owner of the record. In manual sharing, sharing rules and in list views
we can use public group.
29. What are the Assignment rules?
On lead and case objects we can create the Assignment rules. Whenever any record is submitted for lead/case if specified condition in the Assignment rule
satisfied based on that we can decide the owner of the case/lead. Note:While submitting case/lead we should check for 'Assign using active assignment rule'
 checkbox which will display under Optional section.
30. What are Auto-Response Rules?
On lead and case objects we can create the Auto-Response Rules. Whenever any record is submitted for lead/case if specified condition in the Auto-Response
Rules satisfied based on that we can decide the email format which should send as auto response.
31. What are the Escalation rules?
On case object we can create Escalation rule. Based on the priority we can send escalation mails.
32. What is the Architecture of the Salesforce?
Salesforce Architecture is MVC. MVC stands for -
M - Model (Database - Physical Existance of the Data)
V - View (Userineterface which can be seen by the user)
C - Controller (Business Logic)
33. Relate TV, Remote and Setup Box with MVC?

M - Model --> Setup Box
V - View --> TV
C - Controller --> Remote

Questions on Relationships
To avoid Data Redundancy and To achieve Integrity we should go for Relationships.
Salesforce Interview Questions related to Relationships topic
| Salesforce Interview Questions related to Lookup Relationship
| Salesforce Interview Questions related to Master-Detail Relationship
| Salesforce Interview Questions related to External Lookup Relationship
| Salesforce Interview Questions related to Self Relationship
| Salesforce Interview Questions related to Manay-to-Many Relationship
| Salesforce Interview Quesitons related to Internal Lookup
| Salesforce Interview Questions related to Internal-lookup relationship
1. Is it possible to create the Master – Detail Relationship field for the child object
which is having existing records?
No, we cannot create directly. To create first we should create Look up relationship then populate the field value for all the records and then convert the
 look up relationship to master detail relationship.
2. Is it possible to convert Mater – Detail Relationship to Look Up Relationship?
If the parent object doesn’t have Roll up Summary fields for the child object then we can convert.
3. Is it possible to delete junction – Object in case of Mater – Detail Relationship?
If the parent objects don’t have Roll up Summary fields for the child object then we can delete.
To delete a child object it should not be referred in Apex Classes and Apex Triggers.
Later if we undelete the object, Master detail fields on the junction objects will be converted to look up Fields.
Note:
If we delete only Master – Detail Relationship field from the child object and undelete it from the Recycle Bin then it will be converted to look up
relationship.
Parent Object we cannot delete because it will be referred in the child object.
4. What will happen if we undelete the deleted Junction Object?
Master – Detail Relationship data types will be converted to look up relationship data types.
5. What will happen to child records if we delete a parent record in case of Lookup Relationship?
If we delete parent object record all the child object records relationship's field value will be get deleted. (Entire record won’t be get deleted)

Example:
Child Object: Employee (Employee object have Department field which is related to Department Object)
Parent Object: Department
Suppose N number of employee records related to IT department, if we delete IT department all the child(Employee) records Department field value related
 to IT department will be get deleted.
Note:
Salesforce store deleted records only for 15 day in Recycle bin later it will remove the records permanently.
If we undelete the IT department record from the Recycle bin then all the related child records department field value will be restored.
6. What will happen to child records if we delete a parent record in case of Master Detail Relationship?
If we delete the parent object record all the child object records will be get deleted.

Example:
Child Object: Employee (Employee object have Department field which is related to Department Object)
Master Object: Department
Suppose N number of employee records related to IT department, if we delete IT department all the child records will get deleted.
Note:
Salesforce store deleted records only for 15 day in Recycle bin later it will remove the records permanently.
If we undelete the IT department record from the Recycle bin then along with IT department record all the related child (Employee) records will be restored.
(We cannot see the child object records in the Recycle bin)
7. What is Junction Object?
A child object which is having master detail relationships with two different parent object is called junction object.

Example:
Object1: Department
Object2: Project
Child Object: Employee
Field1: Department (Master Detail with Department )
Field2: Project(Master Detail with Project)
Note: From the above example we can say Employee Object as Junction Object.
8. For a junction object if we delete one of the parent record what will happen to child records?
Child records will be get deleted which are related to Department as well as Project.

Note: If we undelete the IT department record from the Recycle bin then along with IT department record all the related child (Employee) records will be
restored those will be reflected for Project as well. (We cannot see the child object records in the Recycle bin)
Next Question to be added

Users, Profiles and Permission Sets
Profiles and Permission Sets provides security for meta-data (Structure) components.
Salesforce interview questions related to security in Salesforce
| permission sets
| Sharing Settings
| Sharing Rules
| Manual Sharing
| Apex managed sharing
| Grant Access using hierarchies
| OWD | Organization Wide Defaults
| Criteria based Sharing Rules
| Roles | Roles and Subordinates
| Queues
| Public Groups
1. Is it possible to delete the user in salesforce?
No, once we create an user in salesforce we cannot delete the user record. We can only deactivate the user record.
2. What is 'Grant Account Login Access'? How to enable 'Grant Account Login Access'
If we enable 'Grant Account Login Access' for a user then we can see 'Log in' button on the detail page of that user. By clicking on that 'Log in'
button without giving that user's username and password we can log in.
To enable the 'Grant Account Login Access' follow the below steps -
Log in as a user to whom you want to enable Log in access.
At top right corner click on name (Which should be left to Setup) > My Settings
User should be able to see user's personal set up page.
Left side, click on Personal Information > Grant Account Login Access
User should be able to see Grant Account Login Access page
In Access Duration column select '1 Year' for all the records and click on 'Save' button.
Log out and Log in as any other user in the organization then click on Manage Users > Users.
User should be able to see list of records and verify the user to whom we enabled the Grant Account Login Access
User should be able to see the Login link beside Edit link.
Click on Login then user should be able to login as that user mode
Observe at top right corner, user should be able to see Logged in as 'Name of the user' which should be highlighte in black color.
Click on Logout
User should be come back to original user's mode, Observe at top right corner, user should not be able to see Logged in as 'Name of the user'
3. How to provide security for Meta-Data files (Schema)?
Using Profiles and Permission Sets.
4. What is Profile?
Profile deals with CRED (Create, Read, Edit and Delete) permissions over Apps, Tabs, sObjects, Fields, Record Types, etc...
We can map only one profile for one user and without mapping the profile we cannot create the user.
5. What is Permission Set?
To improve the permissions for the users over profiles we should go for Permission Sets.
Example- To give additional permissions to few users who belongs to different profiles over Apps, Tabs, sObjects and fields.

6. How to give permissions to two fields for different users who belongs to different profiles?
Permission sets.
7. How many users are there in your project salesforce instance?
1000 (It will depends upon the number of licenses taken by the client, it will be like upto 4000 like that based on the client)
8. How to provide security for the Records(Instance)?
Roles
OWD(Organigation Wide Defaults)
Sharing Rules.
Manual Sharing
Apex Managed sharing
View all.
Modify all.
View all data.
Modify all data.
9. What is role?
Role deals with authorization to access data.
10. What is OWD?
OWD is the default access level on records for any object in sales force.
For custom objects we can see below access levels -
Private
Public Read only
Public Read/Write
Public Read/Write transfer -Lead and Case
Public full access -Campaign
controlled by parent:M-D
By default after creating custom object OWD access level is Public Read/Write.

Private: only owner and above hierarchy users can have Read/Write access and below hierarchy users don't have any access.
Public Read only: only owner and above hierarchy users can have Read/Write access and below hierarchy users can have only Read Only.
Public Read/Write: Irrespective of role hierarchy every one can have Read/Write permissions on the records.
11. What is Grant Access Using Hierarchies?
Say there are three roles
Role A
Role B
Role C
Role A is higher in hierarchy, Role B is in middle and Role C is lower in hierarchy
If the Role A user through Manual Sharing or Sharing Rules, shares the record to Role C user who is in lower hierarchy, then the Role B user who is
above in hierarchy to Role C user can see the records, if we enable Grant Access Using Hierarchies at sharing settings else Role B user cannot see the record.
12. One of the Sales Rep is going on leave and want to assign the access to the opportunity to his collogue, How can he provide the access to the
opportunity record?
Through 'Manual Sharing' a specific record can be shared.
Import Wizard and Data Loader

1. What is Import wizard?
Import wizard is a web based tool to process bulk records.
With import wizard we can process maximum of 50,000 records.
In import wizard we can't see few objects (ex: if there is masterdetail relationship between two objects then child object we can't see).
Account,contact,lead,solution and custom objects
Can't allow the Duplicates
Can't export and delete
2. What is Data Loader?
Data Loader is a stand-alone tool to process bulk records. With Dataloader we can process maximum of 5 million records. Most of the time we use only Dataloader. Default batch size of the Dataloader is 200.
3. Which operations we can perform on dataloader?
Insert (Inserting brand new records, no need of ID)
Update (Updating the existing records based on the record ID)
Upsert (To Upsert we should have one external ID field on the object, based on the external id field if the value already exists it will update,
if doesn't exist then it will insert)
Delete (Delete the records based on the id provided, to delete we need only id, deleted records can be found in recycle bin)
Hard delete (Delete the records based on the id provided, to delete we need only id, deleted records can't be found in recycle bin,
 Note: If we enable bulk API in data loader settings then only we can perform Hard delete.)
Export (From any object we can export records based on the SOQL query, Note: We can't export deleted records which are there in the recycle bin)
Export all (From any object we can export records based on the SOQL query, Note: Using Export all we can export deleted records which are there in
the recycle bin also.
        IsDeleted = true.
4. Data loader or Import wizard supports which file format?
.CSV (Comma Separated Values)
5. What is the filed mapping file format of the data loader?
.SDL
6. How to insert null values into dataloader?
In dataloader settings we should enable 'insert null values' checkbox otherwise we can't insert null values.
7. What is external ID?
Suppose we have account table in Salesforce and account table outside of the Salesforce (ex: .csv file, sql database). In Salesforce all the records can be
 identified with record id and outside of the Salesforce we can't recognize records with Salesforce id that is the reason to compare outside table and
 salesforce table in Salesforce for one of the field we have to enable external ID (we can enable external id for text, number, auto number and email).
 If we enable external id we can compare that particular column with the column which is available in external table. While comparing if the both column
 values are same then it will update otherwise it will insert.
8. Maximum batch size of data loader?
10,000 records and minimum 1 record.
9. What is default batch size if we enable bulk API?
2,000 records.
Workflows and Approvals

1. What are the different kinds of evaluation criteria’s (events)?
Created
Created and everytime edited to meet the criteria
Created and edited to subsequently meet the criteria
2. What is the difference between Created and everytime edited to meet the criteria and Created and edited to subsequently meet the criteria?
If we select 'Created and everytime edited to meet the criteria' whenever we create a record or edit a record if the criteria of the workflow rule meets then
it will trigger every time. If we select 'Created and edited to subsequently meet the criteria' -
While creating the record criteria meets so that workflow will fire and while editing the record again criteria meets workflow won't fire (meeting the criteria
 to meeting the criteria)
While creating the record criteria doesn't meet so workflow won't fire and while editing the record workflow criteria meets then workflow will fire (not
meeting the criteria to meeting the criteria)
Conclusion: Previous state of record should be not meeting criteria and current state of record should be meeting the criteria then only in current state
workflow will fire.
3. What are the types of rule criteria’s?
Criteria meet (field - operator - value, if there are multiple criteria’s then in filter criteria we can give conditions like ( 1 or 2) and 3,
field to field comparison is not possible, we can't fetch the previous state information of the field )
Formula evaluated (we can write formulas with this we can do field to field comparison and we can fetch previous state value of the record)
4. What is immediate workflow action?
The action which will be performed immediately after the record criteria meets.
5. What is time dependent workflow action?
The action which will be performed in future based on the any of the date field. To create time dependent workflow action we should create one time trigger.
 in time trigger we can give either days or hours with the maximum of 999 value and we can select either before or after.
6. For which event we can't create time dependent workflow action?
Created and everytime edited to meet the criteria.
7. What are the different kinds of workflow actions?
New field update (we can update a field of the same object or the fields of the parent objects which are at master side in master-detail relationship,
 only for master-detail parent objects we can update the field and for lookup we can't update)
New email alert (we can send emails if the criteria meets)
New task (we can create new task)
New outbound Message (we can make a callout)
8. What are the types of email templates?
Text
HTML (with letter head)
Custom HTML (without letter head)
Visual Force
9. There is a timebased workflow which will update one of the fields if the criteria meet. User submits the record with valid criteria,
workflow triggered so that the field update is queued in the 'time based flow' queue which will fire after one day.
 If the user modifies the record which is submitted before the scheduled date, after modification, a record criterion is not meeting.
 Whether the field will be updated or not in schedule date?
It won't trigger in the schedule date because if we modify the record to not meeting criteria that queued field update will be removed
from the 'time based flow' queue.
10. For the same scenario explained in the above question what happens when we deactivate or modify the criteria of the workflow to
different criteria? Whether the field will be updated or not in schedule date?
Yes, It will trigger in scheduled date.
11. Scenario: There are two workflow rules on the same object say namely wf1 and wf2. If wf1 fires then a field will be updated on the same object,
if the field updated and due to this wf2 criteria meets then what will happen, wf2 will fire or not?
It won't fire. To fire wf2 we should enable 'Re-evaluate Workflow Rules' checkbox of the field update which is there in wf1.
12. What is recursive workflow rule? How to avoid recursive workflow rules?
Whenever we enable Re-evaluate Workflow Rules after Field Changecheckbox in the Field Update of a workflow rule, due to this
field update other workflow rules on the same object will be fired if the entery criteria of those workflow rules satisfied.
Incase, in other workflow rules also if we enable Re-evaluate Workflow Rules after Field Change checkbox in the Field Update
recursive workflow rules will come in some scenarios.
We can take two steps to avoid recursive workflow rules -
For the workflow Evaluation Criteria if you choose created, and any time it’s edited to subsequently meet criteria option,
 we can avoid recursive workflow rules.
If you don't enable Re-evaluate Workflow Rules after Field Changecheckbox in the Field Update of a workflow rule we can avoid.
13. What is Approval Process?
If the criteria of the record meets then by clicking on submit for Approval button user can submit the record for approval
(Note: Approval history related list should be displayed on the record detail page)
14. How to configure Approval Process?
Before creating the Approval Process we should select the object after that we should follow below steps -
Give the Approval Process name
Give the criteria of the Approval Process
Select the email template (If we don't select any email template salesforce by default send an email notification to the target
approver else with our selected email template target approver will be notified)
Select the users who can submit for the approval (If we do not select any user by default all the users who can access to that record can submit)
Select the user to whom record should be submitted
Initial submission actions ( after submitting the record for approval immediately whatever the actions included in the initial
submission actions section will be triggered)
Approval Steps (we can add multiple steps)
For each and every step we can see 'Approval actions' and 'rejection actions' sections where we can add actions to be performed
If the Approver approves the record then actions which are under 'approval actions' section will be triggered
Final approval actions section (If all the steps approved then actions which are under 'final approval actions' section will be triggered)
Final rejection actions section (If any one of the step rejected then actions which are under 'final rejection actions' section will be triggered)
Recall approval actions ( After submitting record for approval if you want to revoke we click on recall approval action on the detail page,
after clicking on that button actions which are under recall approval actions section will be triggered )
15. Scenario: After activating the approval process, I want to add one more step. Is it possible?
It’s not possible, to add one more step deactivate the approval process and clone the deactivated approval process and add the new steps.
Reports and Dashboards
To summarize the information.
1. What is Report?
To summarize the information of an object we use reports.
2. What are the types of Reports?
Tabular (Displays records just like a table)
Summary (we can summarize the information based on certain fields)
Matrix (we can summarize the information in two dimensional manner, both rows and columns)
Join (we can summarize information in different blocks on the same object and the related objects)
3. How many blocks we can create for join reports?
5 blocks.
4. How many maximum groupings we can do for summary, matrix and join reports?
3 groupings
5. What is bucketing in reports?
Bucket field in Reports is used to group values to the name we specify.
See in detail here
6. How many records we can display on page for a report?
We can display up to 2000 records on a page. If more records are there to display we cannot see those through user interface.
If you export the records to a excel sheet then you can export up to to 50000 records. (Click here for the Reference Link)