Wednesday, 26 August 2015

Difference between Clone and DeepClone in Apex in Salesforce

If a list is cloned, it duplicates it and has reference.
If a list is DeepCloned, it duplicates and doesn’t have any reference.
Primitive data types are supported.
Primitive data types are not supported.
Not applicable
Boolean opt_preserve_id – Whether cloned sObjects records ids are maintained.

Boolean opt_preserve_readonly_timestamps– Whether cloned sObjects records read only system fields like createdDate, LastModifiedDtate, etc are   maintained.

Boolean opt_preserve_autonumbe– Whether cloned sObjects records auto number fields are maintained.
If an user is freezed,
1. He will not be able to login.
2. User license of that user will not be released.
This is mainly used if you want to restrict an user to login during any activity.
Check the below link for Freezing and Unfreezing.
If an user is inactivated,
1. He will not be able to login.
2. Report will not run, if he/she is set as running user.
3. Web to lead and web to case will not work, if he is set as the default creator.
4. User license of the inactivates user will be free for other user.
This is mainly done, when the user leaves the organization.
Freeze Button in Salesforce User detail Page
Freeze button prevent users from logging into your organization.

Note: Freezing user accounts doesn't frees the user licenses available for use in your organization
PageBlockTable: PageBlockTable should be define inside pageblock or pageblocksection. PageBlockTable uses standard styles sheets to design a visualpage. It has the  required attribute "value". Column headers  will be displayed automatically. DataTable: No need to write inside pageblock or pageblocksection. There is no required value. The  data can be displayed using  custom style sheets. we need to specify column headers explicitly. Repeater: There is no proper alignment of data in repeater compared with..
Regular Expressions
One of the most powerful aspects of formula fields is the REGEX function. A full discussion of regular expression syntax is beyond the scope of this article but if you are interested in more details check out thisgreat tutorial.
The REGEX function is not available in Custom Formula Fields or Visualforce.
Ensures that a custom field, Driver's License, is from California
 MailingState = "CA",

 NOT(REGEX(Drivers_License__c, "([A-Z]\\d{7})?"))
Check for a valid credit card
NOT( REGEX( Credit_Card_Number__c ,"(((\\d{4}-){3}\\d{4})|\\d{16})?"))
Validate Social Security Number format

   LEN (Social_Security_Number__c) = 0,
   REGEX( Social_Security_Number__c , "[0-9]{3}-[0-9]{2}-[0-9]{4}")

8. List examples of custom field types?
Text, Pick list, Pick list (multi select), Date, Email, Date/Time, Date, Currency, Checkbox, Number, Percent, Phone, URL, Text Area, Geolocation, lookup relationship, master detail relationship etc…..

9. What is TAB in Salesforce?
   Tab is a user interface component to user creates to display custom object data.
   There are three type of tabs.
        Custom Tabs
        Visual force Tabs
         Web Tabs
10. Does user can create insert their own custom logo, while creating their own custom applications?
Yes user can upload their custom logo in documents and then they choose that logo for organization.
11. List things that can be customized on page layouts?
  We can customize different things on page layout like, Fields, Buttons, Custom Links and Related Lists. We can also create sections.
14. What is difference between trigger and workflow?
Workflow is automated process that fired an action based on Evaluation criteria and rule criteria.
We can access a workflow across the object.
We cannot perform DML operation on workflow
We cannot query from database
Trigger is a piece of code that executes before or after a record is inserted or updated.
We can access the trigger across the object and related to that objects
We can use 20 DML operations in one trigger.
We can use 20 SOQL’s from data base in one trigger.
15. What is Wrapper class?  
A Wrapper class is a class whose instances are collection of other objects.
It is used to display different objects on a Visual Force page in same table.
16. What is Difference between SOQL and SOSL?
SOQL(Salesforce Object Query Language)
Using SOQL we can Search only on one object at a time.
We can query on all fields of any datatype
We can use SOQL in Triggers and classes.
We can perform DML operation on query results.
SOSL(Salesforce object Search Language)
Using SOSL we can search on many objects at a time.
We can query only on fields whose data type is text,phone and Email.
We can use in calsses but not in Triggers.
We cannot perform DML operation on search result

17. What is difference insert() and database .insert() ?
Using insert method we can insert the records but if any error occurs in any record system will throw an error insertion fail and none of the records are inserted.
If we want to execute partially success of bulk insert operation we will use database .insert.
18. What is Static Resources?
Using Static Resources we can upload images, zip files, jar files, java script and CSS files that can be referred in a visual force page.
The maximum size of Static Resources for an organization is 250mB.
19. How to call java script using Static Resource in Visual Force page?
Add java script file in Static Resource setup -> develop -> Static Resources -> click on ‘New’ -> Name: filename and add file from local desktop and save.
We can use that file as follows in Visual Force page
<apex: includescript values=” {! $Resource.fileName}”/>
20. What is sharing rule?
If we want to give the access to other users we use sharing rules.
21. How many ways we can share a record?
Role Hierarchy:
If we add a user to a role, the user is above in the role hierarchy will have read access.
Setup -> manage users -> roles -> setup roles -> click on ‘add role’ -> provide name and save.
Defines the base line setting for the organization.
Defines the level of access to the user can see the other user’s record
OWD can be Private, Public Read Only, Public Read and Write.
Setup -> Security Controls -> sharing settings -> Click on ‘Edit’
Manual Sharing:
Manual Sharing is sharing a single record to single user or group of users.
We can see this button detail page of the record and this is visible only when OWD setting is private.
Criteria Based Sharing rules:
If we want to share records based on condition like share records to group of users
 Whose criteria are country is India.
 Setup -> security controls -> sharing settings -> select the object and provide name and
 Conditions and save
Apex sharing:
Share object is available for every object(For Account object share object is AccountShare ). If we want to share the records using apex we have to create a record to the share object.
29. How to create Master Details relationship between existing records?
Directly we can’t create Master Detail relationship between existing records, first we have to create Lookup relationship and provide valid lookup fields and it shouldn’t  null.
31. What is manual sharing?
                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
32. How we can change the Grant access using role hierarchy for standard objects?
                Not possible.
33. What is the use of “Transfer Record” in profile?
                If user have only Read access on particular record but he wants to change the owner name of that record, then in profile level Transfer Record enables he can able to change the owner.
34. What is Field dependency?
                According to the field selection on one field filter the pick list values on other field.
35. Is check box performs like controlling field?
                Yes possible. Controlling field should be Check box or pick list.
36. How many field dependencies we can use in Visual Force page?
                Maximum we can use 10 field dependencies in VF page.
37. What is Roll-up summary?
                Roll-up displays the count of child records and calculate the sum, min and max of fields of the child records.
38. How to create Roll-up summary field on lookup relation?
                Not possible. Roll-up summary is enabled for only Master –Detail relationship.
39. What are the Record Types?
                 Record Types are restrict the pick list values and assign to the different page layouts for different Record Types.
40. What is Audit Trail?
                Audit Trail provides the information or track all the recent setup changes that an administrator done to the organization.
               This can store the last 6 months data.

41.  What are the Report Types?
       4 Types of report in Salesforce
       Tabular Reports: We can only displays the grand total in the table form.
        Summary Reports: It is a detail form of report in which the grouping done based on Columns.
       Matrix Reports: It is a detail form of report in which the grouping done based on both Rows and Columns.
       Joined Reports: We can join the two or more reports in the single report displayed in the form of blocks.
42. What is Dashboard?
                Dashboard is a pictorial representation of report. We can add up to 20 reports in single dashboard.
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.
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 governer limits ?
     Ans: Governer 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 and
       Ans: is paas(platform as a service) and 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 covergae 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<account> 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 summarising 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 syntex for accessing custom albel in visualforce page - {!$Label.Samplelabel}
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 realationship between two entities. Keys in map are unique. Values can be duplicated.
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.
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 syntex for accessing static resource {!$Resource.Testresourcename}
2. Import wizard will support for which Objects?
Only Accounts, Contacts and custom object’s data can be imported.  If we want to import other objects like Opportunities and other object’s data, then we need to go for Apex Data Loader.
4. What is a VLOOKUP in S.F?
VLOOKUP is actually a function in sales force which is used to bring relevant value to that record from another record automatically.
5. When I want to export data into SF from Apex Data Loader, which Option should be enable in Profile?
Enable API
6. What is a web - lead?
Capturing a lead from a website and routing it into lead object in Sales Force is called wed-lead (web to lead).
7. What are the Types of Account and difference between them?
We have two types of accounts.
Personal accounts
Business accounts
In personal accounts, person’s name will be taken as primary considerations where as in business accounts, there will be no person name, but company name will be taken into consideration.

9. What are formula and Rollup Summary fields and Difference between them? When should Rollup- Summary field enable?
Formula: A read-only field that derives its value from a formula expression that we define. The formula field is updated when any of the source fields change.
Rollup Summary: A read-only field that displays the sum, minimum, or maximum value of a field in a related list or the record count of all records listed in a related list.
Define Account Hierarchy?
Account hierarchy defines the Hierarchy of accounts. It is displayed in tree structure.
Validation Rules, What are they use for in Salesforce?
Validation rules are used to maintain data format and consistency.

What is and Mention the differences. is a cloud computing platform where the developers build multitenant applications. is also a cloud computing platform, it contains only standard objects. is hoisted on

In Which edition the Apex Data Loader will support? What are those editions?  
Earlier Enterprise and Unlimited editions use to support Apex data loader. Now, Professional, Enterprise and Unlimited edition supports data loader.
Through Sales force Import wizard how many records we can import into S.F Objects and the wizard will support for which Objects?
Using Import wizard, we can upload up to 50000 records. And only Accounts, Contacts and custom object’s data can be imported.  If we want to import other objects like Opportunities and other object’s data, then we need to go for Apex Data Loader.
In which edition work flows are available in S.F?
In Enterprise edition and in unlimited edition, we have these work flows. We do not have these work flows in group and professional editions. We can get these workflows in professional edition also as an add-on.
What is the data and file storage capacity in Professional and Enterprise and Unlimited editions Org wide? What is the storage capacity for each user in above editions?
                            Data storage (Org)        File storage (Org)         Dstorage/Fstorage(User)
         1GB                                             1GB                              20MB/100MB
              1GB                                             1GB                              20MB/100MB
                1GB                                     1GB                         120MB/100MB
In Which Edition Outlook and Excel and Mobile Lite are available in S.F? 
Mobile Lite users can view, create, edit, and delete accounts, assets, contacts, leads, opportunities, events, tasks, cases, and solutions from mobile.
 Mobile lite is available in all editions i.e.; Group edition, Professional edition, Enterprise edition, Unlimited edition.
Outlook  connect to sales force is used to sync contacts, Events and mails to sales force. Like mobile lite feature this is also available in all above mentioned editions.
What are the types of bindings available in Visual force?
Using get; set in apex, we can bind variables in visual force.
ex:     public String textdemo{get;set;} // in apex
 <apex:input text value=”{!textdemo}”>  

Using methods in controller
Ex: <apex:selectlist value=”textdemo”>
            <apex:selectoptions value=”listt”/>
//In apex
Public List<Account> getlistt(){
  Return [select Id,Name from Account]; \\ returns list

What is junction Object and what does it mean?
Junction object is a custom object which is used to create many to many relationship between two objects.
It always contains two Master-Detail relationships.

Differences between Master-Detail and Lookup
Both are used to create one to many relationship between two objects.
In case of MD, if Parent is deleted, child is also deleted.
In case of Lookup, if Parent is deleted, child is not deleted.

In MD, Child is mandatory, but in Lookup, child is not mandatory.

When I want to export data into SF from Apex Data Loader, which Option should be enable in Profile? 
Enable API
What is an External Id?
External Id is an id that can be given to any field in an object. An external id will be generated on the field that we mention. This field will be used to detect duplicate values when we try to import data into sales force using an external system like apex data loader, informatica data loader etc.
What is a Field level Security?
Giving permissions to users based on Profiles.
Mentioning the availibity of a field to the users for viewing and editing purpose based on profile is called field level security.
While creating a field,we can mention the security level of that field fr every profile by deciding its level of accessibility to each profile.
Difference btw isNull and isBlank
IsNull – it supports for Number field.
IsBlank- it supports for Text field.
What is a workflow? Types of workflow and actions in workflow.
Workflow is a force platform business logic engine that allows us to automatically send email alerts, assign tasks, field updates based on rules that we define.
Immediate actions:  That executes when a record matches the criteria.
Time-dependent:  When a record matches the criteria, and executes according to time triggers.Task : Asign a new task to user.
Email-alerts : Send email to one or more recipients that are specified.
Field Updates : Update value of a field.
Outbound Messages: Send a configurable API message to designed listener.

Types of email templates
Html with letter head
Custom Template
Visual Force.
Types in roles:
Manual Sharing
OWD (organization wide default):  
Public read
Public read/write
Sharing rules
Role Hierarchy
What are collections and types of collections?
Collection is an object which groups multiple elements into a single unit.
List: Ordered collection of elements which allows duplicates.
Set: Unordered collection of elements which do not allow duplicates.
Map: Pair of two elements, in which the first element is always unique..
Difference between VF and S-Control

It is a markup language like XML, HTML
     It is a procedural language like Java, Ajax      
Automation of data is there- Binding
No automation of data- Manual Binding        
Style sheet(CSS) is included
  CSS is not included     
Accessibility of object

{! ($Objecttype.ObjectName.accessable)}----------- returns true if object is accessible.

What are Global keywords?
Used to access various values from components on a page or from user objects or from URL, for each object we have each key word.

                                                                Current Page
                                                             Page Reference
                                                                 Object Type

What is a Page Reference?
Page reference is a class in apex, which is used to redirect to another page.
By creating an object to this class, we can use this object to forward to another page as shown in example below:
Public Pagereference go()
           Pagereference p = new pageReference(‘’);
Return p;

What is MVC?
The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.
Model: The model object knows about all the data that need to be displayed.
View: The view represents the presentation of the application (User Interface).
Controller: Actual business logic of VF is present here.
What are the Controllers available in
3 types of controllers are available
Standard Controller: Used for both custom and standard objects.
Custom Controller: is an apex class that implements all the logic for a page without leveraging the functionality of a standard controller.
Extension Controller: is an apex class which adds functionality to existing standard and custom controllers.
What is a difference between render, rerender and renderAs? 
Render: is an attribute used in VF to hide or show certain components in visual force page.
        Rerender: Used to refresh a part of a page in visual force page when an action occurs.
        Render as: Used to convert entire visual force into PDF
        Render as = “pdf”.
How can you access URL Parameters in to a visual force page?
 Using $CurrentPage, you can access the query string parameters for the page by specifying the parameters attribute, after which you can access each individual parameter.
Ex: $CurrentPage.parameters.location

What are annotations ant their types?
Annotations are used to bypass the methods in the way they execute.
@Future: Used to execute the methods asynchronously.
@IsTest: Used to test the methods.
@Remote Action
What is a difference between <apex: dataTable />, <apex: pageBlockTable />?
Only standard style sheets used in page block table,
 If we want to add custom style sheets we have to data table.
What are triggers? Types of Triggers
Trigger is a piece of code that is executed before or after a particular field of certain type is inserted, updated or deleted.
Bulk Trigger:
  All triggers are bulk triggers by default, and can process multiple records at a time. You should always plan on processing more than one record at a time.
   Bulk triggers can handle both single record updates and bulk operations like:
Data import
Mass actions, such as record owner changes and deletes
Recursive Apex methods and triggers that invoke bulk DML statements.
Recursive trigger:
 A component that adds AJAX support to another component, allowing the component to be refreshed asynchronously by the server when a particular event occurs, such as a button click or mouseover.
 A component that provides support for invoking controller action methods directly from JavaScript code using an AJAX request. 
  A timer that sends an AJAX update request to the server according to a time interval that you specify.
What is Batch Apex? How can you implement Batch Apex?(Dynamic Apex)
Batch Apex gives you the ability to operate over large amounts of data by chunking the job into smaller parts, thereby keeping within the governor limits.
Using batch Apex, you can build complex, long-running processes on the platform. For example, you could build an archiving solution that runs on a nightly basis, looking for records past a certain date and adding them to an archive.

What is a Callout method? How does it invoke, how many methods available in Classes and Triggers?
It is used to invoke the External services HTTP or web services.
An Apex callout enables you to integrate your Apex with an external service by making a call to an external Web service or sending a HTTP request from an Apex script and then receiving the response. Apex provides integration with Web services that utilize SOAP and WSDL, or HTTP services (RESTful services).
What is a difference between System log and debug log?
System Log console is a separate window that displays debugging information, as well as its cumulative limits and source code. It can be considered a context-sensitive execution viewer showing the source of an operation, what triggered that operation, and what occurred afterward. Use the System Log console to view debug logs that include database events, Apex processing, workflow, and validation logic.
Debug log records database operations, system processes, and errors that occur when executing a transaction or while running unit tests. The system generates a debug log for a user every time that user executes a transaction that is included in the filter criteria.
SOQL: Object Query Language
SOSL: Object Search Language
What is a IDE?
Ans. IDE is a development environment which is available as a plug-in to be installed in Eclipse and used. This IDE can be used to work on and manipulate the salesforce structure like authoring Apex classes, Visual force pages, apex triggers etc.,
What is a Managed Package and Unmanaged package?
Unmanaged vs. Managed
Managed packages are AppExchange packages that can be upgraded in the installer's organization. They differ from unmanaged packages in that some components are locked, allowing the upgrade process. Unmanaged packages do not include locked components and can not be upgraded.

Customer portal
With Salesforce CRM’s customer portal, your customers can log cases and get updates 24x7. All via the intuitive user experience for which Salesforce CRM is famous. The result—higher customer satisfaction at a lower cost.

Partner portal
Outsource your service management by allowing third-party service reps to manage customer cases via the partner portal. Service partners can do everything they need to resolve customer support issues: search the solution database, log cases, make case comments, and run reports.
53.What are the rules Criteria to create a work flow?  How many ways to fire a work flows and when should those available? What are the actions in work flow?
Ans. Criteria that cause to apply the workflow rule.
    Immediate actions that execute when a record matches the criteria.
     Time-dependent actions that queues when a record matches the criteria, and executes according to time triggers.
In 2 ways,
1. Immediate action: when criteria matches record then workflow will be fired immediately.
2. Timedependent action: Fires according to time triggers.
           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.
55. What is test coverage code % for the classes and triggers and what is the test method syntax?
Ans.  75%
57.What are the types of bindings available in Visual force?
Ans . 1. Using GET-SET in apex, we can bind variables in visual force.
    2. Using methods in controller
Visual Force
1.       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.
2.       What is the purpose of controllers?
Controllers provide the data and actions that are available to a Visualforce page.

3.       Which objects have associated standard controllers?
All standard and custom objects that can be accessed via the API have associated controllers
4.       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.
5.       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.
6.       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.
7.       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();  }
8.       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.
9.       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.
10.   What are some Apex classes that are commonly used within controllers?
StandardController, SelectOption, PageReference, Message, etc.
11.   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.
12.   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.
13.   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.
14.   What kind of content can be included in a Visualforce page?
Any content that can be rendered in a browser (HTML, JavaScript, etc.).
15.   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
16.   What are the ways that Visualpages can be incorporated into the rest of your user interface?
Basically, via links, buttons, tabs, and inline frames.
17.   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.
18.   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”
19.   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
20.   What is the main difference between using dataTable vs. pageBlockTable tags?
PageBlock: For default salesforce standard format.
dataTable:To design customformats

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

22.   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.
23.   There are a series of layout components that all help recreate the traditional Salesforce page layout style very easily.  What name do they share?
24.   Which tags should be used to automatically bring in the Salesforce label and default widget for a field?
25.   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. 
26.   What are some examples of JavaScript Events?
Onmouseover, onclieck etc.
27.   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 Web Services API.
28.   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
29.   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 AJAXrequest by defining a new JavaScript function.
·                     actionRegion: used to demarcate which parts of the page the server should reprocess.

30.   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. 
31.   Which tag is used with both radio buttons and picklists to create the selectable values?
32.   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

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

34.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:
Var a =’ document.getElementById('{!$component.afield}').value’;

35.What are the Gov Limits in

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.
Governor limits can be extended from release to release.

Total number of SOQL’s
    Total number of                SOSL’s
Total number of records Retrieved by single SOQL Query
Total number of records Retrieved by single SOSL Query
Total Number Of  Call out Methods
Total number of send email methods allowed
Total Heap Size
300000 Bytes



1.       What is the biggest difference between Apex and most programming languages?
         Apex provides built-in Data Manipulation Calls(Like Insert,Update,Delete etc.,)without establishing any connections to database and closing the connections.
         It provides default exception handling which throws an exception message automatically onto the screen unlike in other programming languages which throws error on to error console and shows abnormality.
But, Apex handles the exception and shows us on the page.
         Embedded SOQL (Salesforce Object Query Language)and SOSL(Salesforce Object Search language) queries which returns the SObject results.
         Apex is interpreted(compiled), executed and Controller by platform.
2.       Where can Apex be authored?  Where can it be executed?
                          Apex can be authored on editor which is provided in Salesforce SETUP pane on left side.Apex classes are executed on platform. It cannot be executed on Local machines using tomcat  or any other servers.
3.       Why are governor limits important?  What are they based on?
A.      Governor limits are important because it controls the user to use the database interactions with limited control. Since, is a cloud platform , it offers multi-tenancy which provides unit platform for various tenants. If the governor limits are not set, and if most users start interacting with cloud database with no limit, then obvious burden will be imposed on Cloud.So, governor limits are important which determine the total pages visited by a client and total number of page navigations, a client can do in a day, total data base interactions that can be made in a single go.Governor limits are based on the type of the Org we use.Generally, testing org contains different governer limits(more), and production org contains different governor limits(less).
4.       List a few characteristics of Apex that is different than other programming languages.
A.      Apex is strongly typed language with direct references TO Sobject and fields names.
       Apex is interpreted, Executed, Controlled by platform.
       Apex scripts can be saved against different versions of the API.
5.       How would an external program access functionality on platform?          We have a concept called Web Services. Using this extended functionality, we can make external program access the functionality on platform.We will generate WSDL document(Web Services Description Language) which will be exposed to host environment which results in extending the capability of accessing platform from external program.
6.       What are governor limits?  Why are these important in a multi-tenant environment?
A.      Governor limits are the database limits that are applied to the users who use platform. Governor limits simply means the limited database calls that a developer/user do.
      These governor limits are important because unlimited and free access to database many number of times from each time will slow down the database effectiveness.So,to preserve the database effectiveness, governor limits are important in multi-tenant environment.
7.       What is Run time type information?  How do obtain it in Apex?
A.      Run time type information refers to a system that keeps the information about an object’s data type in memory at run time. This run time information deals to integers, strings and generic objects.
8.       How do you override a method in Apex?
A.      With the help of the OVERRIDE key word in method signature, we can override a method in Apex.
        For example, we have a method  public void abc(){
f we want to override the method, we can do like below:
Public override void abc(){
9.       What are the ways in which Apex can be invoked?
A.      We can invoke apex in 4 ways:
a.       Triggers: By writing the apex triggers,and calling them on the 7 pre defined events of creating/modifying a record, we can invoke apex.
b.      Apex Schedule: We can schedule Apex code to be run at a particular point/for a particular period of time. We need to write some Apex code and schedule them using Apex Scheduler.By this way, we can invoke apex.
c.       Anonymous Blocks: Anonymous Block refers to a block, from where we can invoke apex by writing the logic we need. Example is as below:
d.      Apex in Ajax: For Apex, we have ajax took kit, from where we can do Apex calls. This Ajax toolkit can be used on the visualforce page using javascript notations. Using this Apex in Ajax, we can invoke Apex.
10.   What are some of the limitations of code that you can call via the anonymous block?
A.      Anonymous Block’s code execute with current user’s permission. So, if the user does not have field-level permissions or does not have profile permissions, then the code in anonymous block fails.
11.   How do you expose functionality on to be consumed by external clients?
A.      We have a concept called Web Services. Using this extended functionality, we can make external program access the functionality on platform.
13.   What is the difference between the global and public access modifier keywords?
A.      We have different access modifiers like global, private, public.
       If we use the access modifier as Global, it can be used anywhere in the org. Generally, Global is used for   web-services since one class needs to handle some other parts of apex in the org. Whenever we use Public keyword, then the access is limited to the particular class and cannot be used outside the related class.
14.   Is casting between a String and Integer allowed? 
 15 .What are different data types for Apex variables?
        Premitive and non premitive data types
16.What keywords are used to declare a constant?
Final and static
17.What special characters are used to surround SOQL or SOSL queries?
[ and ]
  What is the maximum number of rows that can be brought back by a SOQL query?
o   50000
  What advantage does using a variable list in a for loop have over a single variable?
o   Using list ,we save retrived data in a single list variable
  What is different about a static method?
o   Static methods are not used in web services
  What are the two types of iterations that can be performed in a for loop with a SOQL query?
o   Variable and variable_list
  Does Apex use explicit transactional calls such as commit and rollback?
o   NO
  The assert family of methods belong to which class?
o   System
  What do the Limit class methods help you to manage?
  How do you access the records that cause the trigger to execute? 
  What are the seven different types of trigger events?
o   Before insert,before update,before delete
o   After insert,after update,after delete,after undelete
  How do you specify that a trigger is a “bulk trigger?”
o   By default all triggers are bulk triggers
  Under what identity do triggers execute?  What ramifications does that have?
  Is it necessary to import a WSDL to perform a callout?
o   NO
12. Is it possible to write the Apex code from user Interface?
You can add, edit, or delete Apex using the user interface only in a Developer Edition organization, a Enterprise Edition trial organization, or sandboxorganization. In a production organization, you can only make changes to Apex by using the Metadata API ,
deploycall, the IDE, or Migration Tool. The IDE and Migration Tool are free resources provided by to support its users and partners, but are not considered part of our Services for purposes of the Master Subscription Agreement.

13. When you can’t add Time dependent action in Workflow rule?
You can’t add time-dependent actions to a rule if you choose Every time a record is created or edited.
14. What are the types of email templates available in
1.                  Text
2.                  HTML with Letter Head
3.                  Custom HTML
4.                  Visual force
16. What is Roll up summary field in Salesforce?
Roll up summary field in salesforce calculates the Count, Sum, Min or Max of particular field of any child record. Thus, we can say that Roll up summary field can only be created on Master object. To read further, please check this URL
17. What will happen if the Account is deleted?
If the Account is deleted then Contact, Opportunity will also be deleted from Salesforce which are related to that Account.
From the database perspective, check below image of child relationships of Account Child relationship in salesforce
If we use schema builder, released in Winter 12 it would look like:
Account Contact and Opportunity of salesforce in schema builder
19. How to create many to many relationships between object?
Creating many to many relationship in salesforce is little tricky. You cannot create this type of relationship directly. Follow below steps to create this type of relationship.
Create both objects which should be interlinked.
Create one custom object (also called as junction object), which should have autonumber as unique identification and create two master relationships for both objects, no need create tab for this object.
Now on both object, add this field as related list.

20. In Which sequence Trigger and automation rules run in The following is the order salesforce logic is applied to a record.
1.                  Old record loaded from database (or initialized for new inserts)
2.                  New record values overwrite old values
3.                  System Validation Rules
4.                  All Apex “before” triggers (EE / UE only)
5.                  Custom Validation Rules
6.                  Record saved to database (but not committed)
7.                  Record reloaded from database
8.                  All Apex “after” triggers (EE / UE only)
9.                  Assignment rules
10.              Auto-response rules
11.              Workflow rules
12.              Escalation rules
13.              Parent Rollup Summary Formula value updated (if present)
14.              Database commit
15.              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 : 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.
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 and trigger.old in Apex – SFDC?
Ans : :
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
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
26. How to restrict any Trigger to fire only once ?
Triggers can fire twice, once before workflows and once after workflows, this is documented at
“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.”
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) {


                Trigger.old[0].addError('Before Account Delete Error');




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
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.
·                     The relationship between both of them must be “Master – detail relationship”.
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”.
Visualforce page:
<apex:page controller="MemberPaginationController">

    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection title="Interests Results -  Page #{!pageNumber}" columns="1">
                <apex:pageBlockTable value="{!listMember}" var="m">
                    <apex:column value="{!m.Name}"/>
                    <apex:column value="{!m.Age__c}"/>
                <apex:panelGrid columns="4">
                    <apex:commandLink action="{!first}">First</apex:commandlink>
                    <apex:commandLink action="{!previous}" rendered="{!hasPrevious}">Previous</apex:commandlink>
                    <apex:commandLink action="{!next}" rendered="{!hasNext}">Next</apex:commandlink>
                    <apex:commandLink action="{!last}">Last</apex:commandlink>

Apex Controller:

public class MemberPaginationController {
    public ApexPages.StandardSetController con {
        get {
                if(con == null) {
                    con = new ApexPages.StandardSetController(Database.getQueryLocator([Select Id, Name, Age__c FROM Member__c Order By Name limit 100])); 
                return con;
    public List<Member__c> getlistMember(){
        return (List<Member__c>)con.getRecords();
    public Boolean hasNext {
        get {
                return con.getHasNext();
       public Boolean hasPrevious {
        get {
            return con.getHasPrevious();
    public Integer pageNumber {
        get {
            return con.getPageNumber();
    public void first() {
    public void last() {
    public void previous() {

    public void next() {;
    public void cancel() {

Visualforce page:

<apex:page controller="AddingInterestsController">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!interestList}" var="int">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                <apex:column headerValue="Name">
                    <apex:inputField value="{!int.Name}"/>
                <apex:column headerValue="Description">
                    <apex:inputField value="{!int.Description__c}"/>
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertIntests}"/>

Apex Controller:

public class AddingInterestsController {
    Id empId;
    public List<Interest__c> interestList {get;set;}
    public Integer rowNum{get;set;}
    public AddingInterestsController(){
        empId = ApexPages.currentPage().getParameters().get('empId');
        interestList = new List<Interest__c>();  
        interestList.add(new Interest__c());      
    public void insertIntests(){
        insert interestList;
    public void insertRow(){
        interestList.add(new Interest__c()); 
    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));

How to auto populate lookup field values to other fields in Salesforce?
Visualforce page:
<apex:page sidebar="false" controller="SampleController" >
<apex:form >
    <apex:pageBlock id="pg">
        <apex:pageBlockSection columns="1">
            <apex:inputField value="{!interest.Name}"/>
            <apex:inputField value="{!interest.Member__c}">
                <apex:actionSupport event="onchange" action="{!fetchMemberDetails}" reRender="pg"/>
            <apex:inputField value="{!interest.Member_Name__c}"/>
        <apex:pageBlockButtons >
            <apex:commandButton value="Save"/>
Apex Controller:
public class SampleController {
    public Interest__c interest {get;set;}
    public Member__c member {get;set;}
    public SampleController(){
        interest = new Interest__c();
    public void fetchMemberDetails(){
        member = [SELECT Name FROM Member__c WHERE Id = : interest.Member__c];
        interest.Member_Name__c = member.Name;
How to show report chart in Visualforce page?
<apex:page sidebar="false" >
     <analytics:reportChart ReportId="00OU0000001pO02" showRefreshButton="true" size="huge" cacheResults="false" />
What is the use of Web Tab in Salesforce
Web tab is used to have generic link in our organization.For example, company's intranet.
How to compare old field value with the next field value in Salesforce?
trigger emailCheck on Employee__c (before update){
    Map<Id,Employee__c> o = new Map<Id,Employee__c>();
    o = trigger.oldMap;
    for(Employee__c n :    {
        Employee__c old = new Employee__c();        old = o.get(n.Id);
        if(n.Email__c != old.Email__c)        {
            n.Email__c.addError('Email cannot be changed');     }    }}
Generated PDF:
trigger sendEmail on Employee__c (after insert, after update)
    List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>();
    for(Employee__c e :
        Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
        String body;
        body = '<html><h1 style=\"text-align:center;\">Employee Information</h1><br/><br/><table align=\"center\"><tr><td>Employee Name</td><td>' + e.Name + '</td></tr><tr><td>Age</td><td>' + e.Age__c + '</td></tr><tr><td>State</td><td>' + e.State__c + '</td></tr><tr><td>City</td><td>' + e.City__c + '</td></tr></table></html>';
        System.debug('HTML is ' + body);
        attach.Body = Blob.toPDF(body);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(new String[] { e.Email__c });
        mail.setSubject('PDF Generation');
        mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
Before Trigger:
In case of validation check in the same object.
Insert or update the same object.

After Trigger: 
Insert/Update related object, not the same object.
Notification email.
We cannot use After trigger, if we want to update a record because it causes read only error. This is because after inserting or updating, we cannot update a record.
Trigger to sum all the child record field and storing it in another object field in Salesforce
Consider the below Scenario
Quote and Structure__c --> Master Detail relationship
Quote and Bigmachine__c --> Lookup relationship
Structure__c and Bigmachine__c --> Lookup relationship
We have to calculate total scope on Big Machine object, which should be the sum of all scope in Structure__c object.
Sample Trigger:

trigger Structure_AIUD on Structure__c (after insert, after update) {
    Set<Id> quoteIds = new Set<Id>();
    List<Structure__c> structList = new List<Structure__c>();
    Map<Id, List<Structure__c>> quoteIdStructListMap = new Map<Id, List<Structure__c>>();
    List<Big_Machine__c> bigMachineList = new List<Big_Machine__c>();
    Map<Id, Double> quoteIdTotalScopeMap = new Map<Id, Double>();
    for(Structure__c struct : trigger.New) {
    structList = [SELECT Id, Scope__c, Quote__c FROM Structure__c WHERE Quote__C IN : quoteIds];
    bigMachineList = [SELECT Id, Total_Scope__c, Quote__c FROM Big_Machine__c WHERE Quote__C IN : quoteIds];
    if(bigMachineList.size() > 0) {
        if(structList.size() > 0) {
            for(Structure__c struct : structList) {
                if(!quoteIdStructListMap.containsKey(struct.Quote__c)) {
                    quoteIdStructListMap.put(struct.Quote__c, new List<Structure__c>());
            for(Id quoteId : quoteIdStructListMap.keySet()) {
                List<Structure__c> tempStructList = new List<Structure__c>();
                tempStructList = quoteIdStructListMap.get(quoteId);
                Double tempTotalScope = 0;
                for(Structure__c struct : tempStructList) {
                    tempTotalScope = tempTotalScope + struct.Scope__c;
                quoteIdTotalScopeMap.put(quoteId, tempTotalScope);
        for(Big_Machine__c bigMachine : bigMachineList) {
            bigMachine.Total_Scope__c = quoteIdTotalScopeMap.get(bigMachine.Quote__c);
        update bigMachineList;
To update a field in Master record when child record is updated, we have to use Trigger.

Sample Trigger:

In the below trigger, if a Contact is created or updated, the Average_Rating__c field will be updated as average of all Contacts Rating__c under that Account.

trigger RatingAverage on Contact(after insert, after update) {

    Map<Id, List<Contact>> AcctCont = new Map<Id, List<Contact>>();
    Map<Id, Contact> NewMap = trigger.NewMap;
    List<Account> AcctList = new List<Account>();
    List<Contact> ContList = new List<Contact>();
    Set<ID> AcctIds = new Set<ID>();

    for(Contact Con : trigger.New) {
    System.debug('Account ids are ' + AcctIds);

    AcctList = [SELECT Average_Rating__c FROM Account WHERE Id IN : AcctIds];
    System.debug('Account List is ' + AcctList);

    ContList = [SELECT Rating__c, AccountId FROM Contact WHERE AccountID IN : AcctIds];
    System.debug('Contact List is ' + ContList);

    for(ID TempId : AcctIds) {
        List<Contact> TempContList = new List<Contact>();
        for(Contact Con : ContList) {
            if(Con.AccountId == TempId) {
            Contact TempCont = new Contact();
            System.debug('Contact Id is ' + con.Id);
        AcctCont.put(TempId, TempContList);
    System.debug('Account and contacts are ' + AcctCont);

    for(Account Acct : AcctList) {
        List<Contact> TempContList = new List<Contact>();
        Decimal Total = 0;
        System.debug('Account Id is ' + Acct.Id);
        TempContList = AcctCont.get(Acct.Id);
        for(Contact Con : TempContList) {
            Total = Total + Con.Rating__c;
        Acct.Average_Rating__c = Total/(TempContList.size());
    Update AcctList;

Post a Comment