Here are the most frequently asked Salesforce interview questions to help you ace your interview & bag a career as a Salesforce professional.

If there is any new salesforce  interview question that have been asked to you, kindly post it in the the comment section.


 

1. Can two users have the same profile? Can two profiles be assigned to the same user?

Ans:

Profiles determine the level of access a user can have in a Salesforce org.
As far as the first part of the question is concerned, Yes. One profile can be assigned to any number of users. Take the example of a Sales or Service team in a company. The entire team will be assigned the same profile. The admin can create one profile: Sales Profile, which will have access to the Leads, Opportunities, Campaigns, Contacts and other objects deemed necessary by the company.
In this way, many users can be assigned the same profile. In case the team lead or manager need access to additional records/ objects then it can be done by assigning permission sets only for those users.

2. What are Governor Limits in Salesforce?

Ans:

In Salesforce, it is the Governor Limits which controls how much data or how many records you can store in the shared databases. Why? Because Salesforce is based on the concept of multi-tenant architecture. In simpler words, Salesforce uses a single database to store the data of multiple clients/ customers. The below image will help you relate to this concept.

To make sure no single client monopolizes the shared resources, Salesforce introduced the concept ofGovernor Limits which is strictly enforced by the Apex run-time engine.
Governor Limits are a Salesforce developer’s biggest challenge. That is because if the Apex code ever exceeds the limit, the expected governor issues a run-time exception that cannot be handled. Hence as a Salesforce developer, you have to be very careful while developing your application.
Different Governor Limits in Salesforce are:

  • Per-Transaction Apex Limits
  • Force.com Platform Apex Limits
  • Static Apex Limits
  • Size-Specific Apex Limits
  • Miscellaneous Apex Limits
  • Email Limits
  • Push Notification Limits

3. What is a sandbox org? What are the different types of sandboxes in Salesforce?

Ans:

A sandbox is a copy of the production environment/ org, used for testing and development purposes. It’s useful because it allows development on Apex programming without disturbing the production environment.
When can you use it?
You can use it when you want to test a newly developed Force.com application or Visualforce page. You can develop and test it in the Sandbox org instead of doing it directly in production.
This way, you can develop the application without any hassle and then migrate the metadata and data (if applicable) to the production environment. Doing this in a non-production environment allows developers to freely test and experiment applications end to end.
Types of Sandboxes are:

  • Developer
  • Developer Pro
  • Partial Copy
  • Full

4. Can you edit an apex trigger/ apex class in production environment? Can you edit a Visualforce page in production environment?

Ans:

No, it is not possible to edit apex classes and triggers directly in production environment.
It needs to be done first in Developer edition or testing org or in Sandbox org. Then, to deploy it in production, a user with Author Apex permission must deploy the triggers and classes using deployment tools.
However, Visualforce pages can be created and edited in both sandbox and in production.
Only if the page has to do something unique (different values), it would have to be developed via Sandbox.

5. What are the different data types that a standard field record name can have?

Ans:

A standard field record name can have data type of either auto number or text field with a limit of 80 chars.
For generating auto numbers, the format needs to be specified while defining the field and after that for every record that is added, the number will get auto generated. For example:-
Sr No-{1}
Sr No-{2}
Sr No-{3}

6. What is WhoId and WhatId in activities?

Ans:

WhoID refers to people. Typically: contacts or leads. Example: LeadID, ContactID
WhatID refers to objects. Example: AccountID, OpportunityID

7. What is the use of writing sharing rules? Can you use sharing rules to restrict data access?

Ans:

Sharing rules are written to give edit access (public read and write) or public read only access to certain individuals in Salesforce org. A classic example is when:- only your managers or superiors need to be given extra credentials to your records in objects as compared to your peers.
By default, all users in your organization will have organization-wide-default sharing settings of eitherPublic Read Only or Private.
To give access to more records, which users do not own, we write sharing rules.
Example: Sharing rules are used to extend sharing access to users in public groups or roles. Hence, sharing rules are not as strict as organization-wide default settings. They allow greater access for those users.
As far as the second part of the question is concerned, the answer is no. We cannot use sharing rules to restrict data access. It is only used for allowing greater access to records.

8. What are the different types of email templates that can be created in Salesforce?

Ans:

The different types of Email templates are listed in the below table:-

Text

All users can create or change this template

HTML with letterhead

Only Administrators and users having “Edit HTML Templates” permissions can create this template based on a letterhead.

Custom HTML

Administrators and users having “Edit HTML Templates” permissions can create this template without the need of a letterhead

Visualforce

Only administrators and developers can create this template. Advanced functionalities like merging data from multiple records is available only in this template

9. What is a bucket field in reports?

Ans:

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.

10. What are dynamic dashboards? Can dynamic dashboards be scheduled?

Ans:

Before we understand dynamic dashboards, let us first understand static dashboards. Static dashboards are the basic dashboard types that will be visible to any user who has made a report out of his data. An example of this is what a Sales manager/ Marketing manager would be able to see on his Salesforce org. In other words, a normal dashboard shows data only from a single user’s perspective. Now comes the concept of dynamic dashboards.

Dynamic dashboards are used to display information which is tailored to a specific user. Let us consider the same example as above. In case the Sales manager wants to view the report generated specific to only one of his team members, then he can use dynamic dashboards.

You can use dynamic dashboards when you want to show user-specific data of a particular user, such as their personal quotas and sales, or number of case closures, or leads converted etc.

You can also use a normal/ static dashboard when you want to show regional or organization-wide data to a set of users, such as a particular region’s sales number, or a particular support team’s performance on case closures.

As far as the second part of the question is concerned, no we cannot schedule a dynamic dashboard. That is because whenever we open the dashboard, it will show the data generated in real-time.



 

11. What are the different types of reports available in Salesforce? Can we mass delete reports in Salesforce?

Ans:

Salesforce Report Types

1. Tabular reports

Simple Excel type tables which provide a list of items with the grand total

2. Summary reports

Similar to Tabular reports, but also have functionality of grouping rows, viewing subtotals & creating charts

3. Matrix reports

Two-dimensional reports which allow you to group records both by row and column

4. Joined reports

Multiple blocks showing data from different reports based on same or different report types

Another important point to note here is that, only Summary reports and Matrix reports can be fed as data source for dashboards. Tabular and Joined reports cannot be used as data source for dashboards.

Can we mass delete reports in Salesforce? Of Course we can mass delete reports in Salesforce. The option to mass delete reports can be found under Data Management in Setup.

12. What are the different types of object relations in salesforce? How can you create them?

Ans:

No list of Salesforce interview questions is complete without involving relationships between objects in Salesforce. Relationships in Salesforce can be used to establish links between two or more objects.
The different types of object relationships in Salesforce are:

Master-Detail Relationship (1:n):-
It is a parent-child relationship in which the master object controls the behavior of the dependent child object. It is a 1:n relationship, in which there can be only one parent, but many children.The main concept you need to be know is that, being the controlling object, the master field cannot be empty. If a record/ field in master object is deleted, the corresponding fields in the dependent object are also deleted. This is called a cascade delete. Dependent fields will inherit the owner, sharing and security settings from its master.
You can define master-detail relationships between two custom objects, or between a custom object and standard object as long as the standard object is the master in the relationship.

Lookup Relationship (1:n):-
Lookup relationships are used when you want to create a link between two objects, but without the dependency on the parent object. Similar to Master-Detail relationship, you can think of this as a form of parent-child relationship where there is only one parent, but many children i.e. 1:n relationship.The difference here is that despite being controlling field, deleting a record will not result in automatic deletion of the lookup field in the child object. Thus the records in the child object will not be affected and there is no cascade delete here. Neither will the child fields inherit the owner, sharing or security settings of its parent.

Junction Relationship (Many-To-Many):-
This kind of a relationship can exist when there is a need to create two master-detail relationships. Two master-detail relationships can be created by linking 3 custom objects. Here, two objects will be master objects and the third object will be dependent on both the objects. In simpler words, it will be a child object for both the master objects.

13. What happens to detail record when a master record is deleted? What happens to child record when a parent record is deleted?

Ans:

In a Master-Detail relationship, when a master record is deleted, the detail record is deleted automatically (Cascade delete).
In a Lookup relationship, even if the parent record is deleted, the child record will not be deleted.

14. Can you have a roll up summary field in case of Master-Detail relationship?

Ans:

Yes. You can have a roll-up summary in case of a master-detail relationship. But not in case of a lookup relationship.
A roll-up summary field is used to display a value in a master record based on the values of a set of fields in a detail record. The detail record must be related to the master through a master-detail relationship.
There are 4 calculations that you can do using roll-up summary field. You can count the number of detail records related to a master record. Or, you can calculate the sum, minimum value, or maximum value of a field in the detail records.

15. Explain the term “Data Skew” in Salesforce.

Ans:

“Data skew” is a condition which you will encounter when working for a big client where there are over 10,000 records. When one single user owns that many records we call that condition ‘ownership data skew’.
When such users perform updates, performance issues will be encountered because of “data skew”. This happens when a single user/ members of a single role own most of the records for a particular object.

16. Explain skinny table. What are the considerations for Skinny Table?

Ans:

In Salesforce, skinny tables are used to access frequently used fields and to avoid joins. This largely improves performance. Skinny tables are highly effective, so much so that even when the source tables are modified, skinny tables will be in sync with source tables.
Considerations for skinny tables:

  • Skinny tables can contain a maximum of 100 columns.
  • Skinny tables cannot contain fields from other objects.
  • For full sandboxes: Skinny tables are copied to your Full sandbox organizations, as of the Summer ’15 release.

17. Which fields are automatically Indexed in Salesforce?

Ans:

Only the following fields are automatically indexed in Salesforce:

  • Primary keys (Id, Name and Owner fields).
  • Foreign keys (lookup or master-detail relationship fields).
  • Audit dates (such as SystemModStamp).
  • Custom fields marked as an External ID or a unique field.

18. How to handle comma within a field while uploading using Data Loader?

Ans:

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

19. For which criteria in workflow “time dependent workflow action” cannot be created?

Ans:

Time dependent workflow action cannot be create for: “created, and every time it’s edited”.

20. What are the types of custom settings in Salesforce? What is the advantage of using custom settings?

Ans:

There are two types of custom settings in Salesforce: List Custom Settings and Hierarchy Custom Settings.
List Custom Settings are a type of custom settings that provides a reusable set of static data that can be accessed across your organization irrespective of user/ profile.
Hierarchy Custom Settings are another type of custom settings that uses built-in hierarchical logic for “personalizing” settings for specific profiles or users.
The advantage of using custom settings is that it allows developers to create a custom set of access rules for various users and profiles.




 

21. How many active assignment rules can you have in a lead/ case?

Ans:

Only one rule can be active at a time.

22. What are custom labels in Salesforce? What is the character limit of custom label?

Ans:

Custom labels are custom text values that can be accessed from Apex classes or Visualforce pages. The values here can be translated into any language supported by Salesforce.
Their benefit is that they enable developers to create multilingual applications which automatically presents information in a user’s native language.
You can create up to 5,000 custom labels for your organization, and they can be up to 1,000 characters in length.

23. What is the difference between a Role and Profile in Salesforce?

Ans:

As mentioned in one of the previous Salesforce interview questions, a profile will ultimately control access to which records a user has in a Salesforce org. No user can work on the Salesforce org without being assigned a profile. The Profile is therefore mandatory for every user.
Role however is not mandatory for every user. The primary function of the Role/ Role hierarchy is that it allows higher level users in hierarchy get access to records owned by lower level users in the hierarchy. An example of that is Sales Managers getting access to records owned by Sales Reps while their peers do not get access to it.

24. What are the examples of non-deterministic Force.com formula fields?

Ans:

Before I mention some of the examples, let me give you an introduction to deterministic and non-deterministic formula fields. Formula fields whose value will be static are referred to as deterministic fields. Whereas, formula fields whose value will be changed dynamically or whose values will have to be calculated on the fly, they are referred to as non-deterministic formula fields. A classic example of that is a formula returning the current date and time.
Some examples of non-deterministic fields in Force.com are:

  • Lookup fields
  • Formula fields whose reference spans over other entities
  • Fields having dynamic date functions like:- TODAY() or NOW()

25. Why do we need to write test classes? How to identify if a class is a test class?

Ans:

Software developers from around the world will unanimously agree that writing code in test classes makes debugging more efficient. Why? That is because test classes help in creating robust and error-free code be it Apex or any other programming language. Since Unit tests are powerful in their own right, Salesforce requires you to write test classes in Apex code.
Why are they so powerful? Because test classes and test methods verify whether a particular piece of code is working properly or not. If that piece of code fails, then developers/ testers can accurately locate the test class having the faulty bug.
Test classes can be determined easily because every test class will be annotated with @isTest keyword. In fact, if we do not annotate a test class with @isTest, then it cannot be defined as a test class. Similarly, any method within a class which has the keyword testMethod, is a test method.

26. What is minimum test coverage required for trigger to deploy?

Ans:

In Salesforce, if you want to deploy your code to production, then you must make sure that at least 75% of your Apex code is covered by unit tests. And all these tests must complete successfully.

27. What are the different ways of deployment in Salesforce?

Ans:

You can deploy code in Salesforce using:

  • Change Sets
  • Eclipse with Force.com IDE
  • Force.com Migration Tool – ANT/Java based
  • Salesforce Package

28. What is an external ID in Salesforce? Which all field data types can be used as external IDs?

Ans:

An external ID is a custom field which can be used as a unique identifier in a record. External IDs are mainly used while importing records/ data. When importing records, one among the many fields in those records need to be marked as an external ID (unique identifier).
An important point to note is that only custom fields can be used as External IDs. The fields that can be marked as external IDs are: Text, Number, E-Mail and Auto-Number.

29. How many callouts to external service can be made in a single Apex transaction?

Ans:

Governor limits will restrict a single Apex transaction to make a maximum of 100 callouts to an HTTP request or an API call.

30. How can you expose an Apex class as a REST WebService in Salesforce?

Ans:

You can expose your Apex class and methods so that external applications can access your code and your application through the REST architecture. This is done by defining your Apex class with the @RestResourceannotation to expose it as a REST resource. You can then use global classes and a WebService callback method.
Invoking a custom Apex REST Web service method always uses system context. Consequently, the current user’s credentials are not used, and any user who has access to these methods can use their full power, regardless of permissions, field-level security, or sharing rules.
Developers who expose methods using the Apex REST annotations should therefore take care that they are not inadvertently exposing any sensitive data. Look at the below piece of code for instance:-

global class AccountPlan {
webservice String area;
webservice String region;
//Define an object in apex that is exposed in apex web service
global class Plan {
webservice String name;
webservice Integer planNumber;
webservice Date planningPeriod;
webservice Id planId;
}
webservice static Plan createAccountPlan(Plan vPlan) {
//A plan maps to the Account object in salesforce.com.
//So need to map the Plan class object to Account standard object
Account acct = new Account();
acct.Name = vPlan.name;
acct.AccountNumber = String.valueOf(vPlan.planNumber);
insert acct;
vPlan.planId=acct.Id;
return vPlan;
} }

 

31. What is the difference between a standard controller and a custom controller?

Ans:

Standard controller in Apex, inherits all the standard object properties and standard button functionality directly. It contains the same functionality and logic that are used for standard Salesforce pages.
Custom controller is an Apex class that implements all of the logic for a page without leveraging a standard controller. Custom Controllers are associated with Visualforce pages through the controller attribute.

32. How can we implement pagination in Visualforce?

Ans:

To control the number of records displayed on each page, we use pagination. By default, a list controller returns 20 records on the page. To customize it, we can use a controller extension to set the pageSize.

33. How can you call a controller method from JavaScript?

Ans:

To call a controller method (Apex function) from JavaScript, you need to use actionfunction.

34. How to get the UserID of all the currently logged in users using Apex code?

Ans:

You can get the ID’s of all the currently logged in users by using this global function: UserInfo.getUserId().

35. How many records can a select query return? How many records can a SOSL query return?

Ans:

The Governor Limits enforces the following:-
Maximum number of records that can be retrieved by SOQL command: 50,000.
Maximum number of records that can be retrieved by SOSL command: 2,000.

36. What is an attribute tag? What is the syntax for including them?

Ans:

An attribute tag is a definition of an attribute of a custom component and it can only be a child of a component tag.
Note that you cannot define attributes with names like id or rendered. These attributes are automatically created for all custom component definitions.

37. What are the three types of bindings used in Visualforce? What does each refer to?

Ans:

There are three types of bindings used in Salesforce:-

  • Data bindings, which refer to the data set in the controller
  • Action bindings, which refer to action methods in the controller
  • Component bindings, which refer to other Visualforce components.

Data bindings and Action bindings are the most common and they will be used in every Visualforce page.

38. What are the different types of collections in Apex? What are maps in Apex?

Ans:

Collections are the type of variables which can be used to store multiple number of records (data).
It is useful because Governor Limits restrict the number of records you can retrieve per transaction. Hence, collections can be used to store multiple records in a single variable defined as type collection and by retrieving data in the form of collections, Governor Limits will be in check. Collections are similar to how arrays work.
There are 3 collection types in Salesforce:

  • Lists
  • Maps
  • Sets

Maps are used to store data in the form of key-value pairs, where each unique key maps to a single value.
Syntax: Map<String, String> country_city = new Map<String, String>();

39. How can you embed a Visualflow in a Visualforce page?

Ans:

Find the flow’s unique name.
From Setup, enter Flows in the Quick Find box, then select Flows.
Click the name of the flow.
Copy the unique name of the flow.
From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
Define a new Visualforce page, or open an existing one.
Add the component somewhere between the tags.
Set the name attribute to the unique name of the flow.
Click Save.
Restrict which users can access the Visualforce page.
Click Visualforce Pages.
Click Security next to your Visualforce page.
Move all the appropriate profiles from Available Profiles to Enabled Profiles by using the ‘add’ and ‘remove’ buttons.
Click Save.
Add the Visualforce page to your Force.com app by using a custom button, link, or Visualforce tab.

40. What is the use of “@future” annotation?

Ans:

Future annotations are used to identify and execute methods asynchronously. If the method is annotated with “@future”, then it will be executed only when Salesforce has the available resources.
For example, you can use it while making an asynchronous web service callout to an external service. Whereas without using the annotation, the web service callout is made from the same thread that is executing the Apex code, and no additional processing will occur until that callout is complete (synchronous processing).



 

41. What are the different methods of batch Apex class?

Ans:

Database.Batchable interface contains three methods that must be implemented:
Start method:
global (Database.QueryLocator | Iterable) start(Database.BatchableContext bc) {}
Execute method:
global void execute(Database.BatchableContext BC, list

){}
Finish method:
global void finish(Database.BatchableContext BC){}

42. What is a Visualforce component?

Ans:

A Visualforce Component is either a predefined component (standard from component library) or a custom component that determines the user interface behavior. For example, if you want to send the text captured from the Visualforce page to an object in Salesforce, then you need to make use of Visualforce components. Example:

43. What is Trigger.new?

Ans:

Triger.new is a command which returns the list of records that have been added recently to the sObjects. To be more precise, those records will be returned which are yet to be saved to the database. Note that this sObject list is only available in insert and update triggers, and the records can only be modified in before triggers.
But just for your information, 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.

44. What all data types can a set store?

Ans:

Sets can have any of the following data types:

  • Primitive types
  • Collections
  • sObjects
  • User-defined types
  • Built-in Apex types

45. What is an sObject type?

Ans:

An sObject is any object that can be stored in the Force.com platform database. Apex allows the use of generic sObject abstract type to represent any object.
For example, Vehicle is a generic type and Car, Motor Bike all are concrete types of Vehicle.
In SFDC, sObject is generic and Account, Opportunity, CustomObject__c are its concrete type.

46. What is the difference between SOQL and SOSL?

Ans:

The differences are mentioned in the table below:

SOQL (Salesforce Object Query Language)

SOSL (Salesforce Object Search Language)

Only one object can be searched at a time

Many objects can be searched at a time

Can query any type of field

Can query only on email, text or phone

Can be used in classes and triggers

Can be used in classes, but not triggers

DML Operation can be performed on query results

DML Operation cannot be performed on search results

Returns records

Returns fields

47. What is an Apex transaction?

Ans:

An Apex transaction represents a set of operations that are executed as a single unit. The operations here include the DML operations which are responsible for querying records. All the DML operations in a transaction either complete successfully, or if an error occurs even in saving a single record, then the entire transaction is rolled back.

48. What is the difference between public and global class in Apex?

Ans:

Global class is accessible across the Salesforce instance irrespective of namespaces.

Whereas, public classes are accessible only in the corresponding namespaces.

49. What are getter methods and setter methods?

Ans:

Get (getter) method is used to pass values from the controller to the VF page.
Whereas, the set (setter) method is used to set the value back to controller variable.

50. What is Salesforce?

Ans:

Salesforce is the most effective Customer Relationship Management (CRM) product that is delivered to subscribers as cost effective software-as-a-service (SaaS).




 

51. What is a custom object in Salesforce?

Ans:

In Salesforce, custom objects refer specifically to database tables that store data related to your company in Salesforce.com.

52. What does a custom object permit the user to do?

Ans:

Once the custom object is defined, the subscriber can perform the following tasks: create custom fields, relate the custom object to other records, track events and tasks, build page layouts, create a custom tab for the custom object, analyze custom object data, create dashboards and reports, and share custom tabs, custom apps, custom objects, and various other related components. None of these tasks can be accomplished until the custom object has definition.

53. What is a Self-Relationship?

Ans:

A Self-Relationship is a lookup relationship to the same object. It is this premise that allows users to take the object “Merchandise” and create relationships with other objects.

54. What is the Object Relationship Overview?

Ans:

In Salesforce, the object relationship overview links custom object records to standard object records in a related list. This is helpful to track product defects in related customer cases. Salesforce allows users to define different types of relationships by creating custom relationship fields on an object.

55. What can cause data loss in Salesforce?

Ans:

  • Data loss in Salesforce can be caused by a number of reasons, including:
  • Changing data and date-time
  • Migrating to percent, number, and currency from other data types
  • Changing from multi-select picklist, checkbox, auto number to other types
  • Altering to multi-select picklist from any type except picklist
  • Changing to auto-number except from text
  • Changing from text-area to e-mail, phone, URL, and text

56. How is SaaS beneficial to Salesforce?

Ans:

SaaS is subscription-based, so clients can choose not to renew and discontinue using the program at any time without penalty other than not being able to use Salesforce. SaaS is intended to help users avoid heavy initial startup fees and investments. SaaS applications use a simple Internet interface supported by easy integration.

57. How does Salesforce track sales?

Ans:

Salesforce is a tracking program that records a number of helpful basic details, such as:

  • Number of customers served daily
  • Daily sales volume
  • Detailed reports from Sales Manager
  • Sales figures by month or quarter
  • Most importantly, Salesforce tracks and reports repeat customer activity, which is the key to any sales organization.

58. How many types of relationships are offered by Salesforce.com?

Ans:

Salesforce recognizes two relationship types: Master-detail relationships and Lookup relationships.

59. What is the trigger?

Ans:

Trigger is the code that is executed before or after the record is updated or inserted.

60. What is the difference between Trigger and Workflow?

Ans:

Trigger is the code that is executed before or after the record is updated or inserted.


 

61. What is the difference between Trigger and Workflow?

Ans:

Workflow is an automated process that fires an action based upon evaluation criteria and rule criteria. As described above, Trigger is the code that is executed on or after the record is updated or inserted.

62. What is static resource in Salesforce?

Ans:

With Salesforce’s static resource, subscribers can upload zip files, images, jar files, JavaScript, and CSS files that can be referred in a Visualforce page. The optimum size of static resources in Salesforce is 250 MB.

63. What is the difference between Force.com and Salesforce.com?

Ans:

Force.com is Platform-as-a-Service (PaaS), while Salesforce.com is Software-as-a-Service (SaaS).

64. Is there a limit for data.com records?

Ans:

Salesforce users can see their limit form setup easily by simply clicking data.com administration/Users. From the data.com users section, the users can see their monthly limit and exactly how many records are exported during the month.

65. What are the three types of object relations in Salesforce?

Ans:

The three types of object relations in Salesforce are:

  • One-to-many
  • Many-to-many
  • Master-detail

The relation types are quite logical once the user becomes familiar with the software program.

66. What are the different types of reports available in Salesforce?

Ans:

The different types of reports in Salesforce are:

  • Tabular report that displays the grand total in table form
  • Matrix report where grouping is based upon both rows and columns
  • Summary reports that are detailed reports in which the grouping is based on columns.
  • Joined report which allows two or more reports to be joined in a single report

67. Is it possible to schedule a dynamic dashboard in Salesforce?

Ans:

In Salesforce, it is not possible to schedule a dynamic dashboard.

68. What is the junction object and what purpose does it serve?

Ans:

Junction objects are used to build many-to-many relationships between objects. For example, the user can take a recruiting application where a position for a job can be linked to many candidates or can link a candidate to many other jobs. In order to connect the data model, a third party object is referred to as a junction object. In the given example, the junction object is “job application.”

69. What is an Audit Trail?

Ans:

The Audit Trail function in Salesforce is useful for gaining information or for tracking all the recent setup changes that the administration has done in the organization. The audit trail can preserve data for up to six months.

70. Explain the Salesforce dashboard?

Ans:

In Salesforce, the dashboard is a pictorial representation of the report. 20 reports can be added to a single dashboard.



 

71. What is the difference between SOQL and SOSL?

Ans:

SOQL is Salesforce Object Query Language and SOSL is Salesforce Object Search Language. If you are sensing that Salesforce is a culture unto itself, you are correct!

72. What is a Wrapper Class?

Ans:

A Wrapper Class is a class whose instances are a collection of other objects and is used to display different objects on a Visualforce page in the same table.

73. What is the sharing rule?

Ans:

The sharing rules are applied when a user wishes to allow access to other users.

74. Salesforce Vs ServiceNow

Ans:

 

SalesForce

ServiceNow

Platforms

Desktop, Mobile, Cloud

Cloud

Type of Software

Stand alone, Cloud, Saas

Stand alone, Cloud, Saas

Key Features

Markeitng Sales Management, Customer Management, Customer Service

Information Technology, Customer Management, Customer Service

Price

Preferred by all types of customers as it is cost effective

Approximately four time more than Salesforce

Typical Customers

Small, Mid and Enterprise

Mid and Enterprise

Security

Moderate

Best when compared to Salesforce

75. What is Apex in Salesforce?

Ans:

  • Apex is a strongly typed object oriented programming language.
  • It allow the developer to execute flows and transaction control statements.
  • Apex enables developers to add business logic to most system events like button clicks related record updates and visualforce pages.

76. What is Apex Programming Language?

Ans:

  • Integrated: It provides built in support for DML Calls
  • Inline Salesforce Object Query Language
  • Easy to Use
  • Easy to Test
  • Version
  • Multi Tenant Aware Applications

77. When Should I Use Apex?

Ans:

To create Email services
Create web services
Perform complex validation over multiple objects
To create complex business processes that are not supported by workflow.
Create custom transaction logic
Attach custom logic to another operation

78. How Does Apex Work?

Ans:

All Apex programs runs entirely ON-Demand on Force.com Platform.
First the platform application server compiles the code into abstract set of instructions that can be understood by Apex runtime interpreter.
The compile code is stored to metadata.
When the end users triggers the execution of Apex by clicking button or visualforce page the application servers retrieves the compiled instructions from the metadata and send them to runtime interpreter before returning the result.

79. What is Apex Email Service?

Ans:

Email services is an automated process that use Apex classes to process the contents, Headers, Attachments of Inbound Email.
Note:
Visualforce email templates can not be used for mass emails.
We can associate each email services with one or more salesforce generated email address to which the users can send messages for processing.

80. What is Map Class in Apex Salesforce?

Ans:

  • Map Class Contains methods for the Map collection type.
  • A Map is collection of key values pairs where each unique key maps to a single value.
  • Map keys and values can be any data type primitive types, collections, sObjects, users defined types, and built in Apex Types.

For Example, the following table represents a map of countries and currencies

Country(Key)

‘United States’

‘Japan’

;France’

‘England’

‘India’

Currency (Value)

‘Dollar’

‘Yen’

‘Euro’

‘Pound’

‘Rupee’




 

81. What is SOQL?

Ans:

A query language that allows you to construct simple but powerful query strings and to specify the criteria that should be used to select the data from the platform database. SOQL Stands for Slaesforce Object Query Language.

82. What Are The Types of SOQL Statements in SalesForce?

Ans:

Salesforce Object Query Language is used to query that records from the database.com based on the requirement.
There are 2 types of SOQL Statements.
Static SOQL
Dynamic SOQL
1.Static SOQL: The oStatic SOQL Statement is written in [] (Array Brackets)
This statements are similar to IINQ(Ion Integrated Query)
Example: String search for =’Jones’;
Contact[] contacts=[select testfield__c, FirstName, LastName from Contact Where Last Name=:search for];
2. Dynamic SOQL:
It is used to refer to the creation of a SOQL string at run time with Apex code.
Dynamic SOQL enables you to create more flexible application.
To create Dynamic SOQL query at run time use Database.Query() method, in one of the following ways.
Return a single sObjects when the query returns a single record.
sObjects s = Database. Query(String_limit_l);
Return a list of sObjects when the query returns more than a single record.
Examples:
Eg1:
String myTestString = ‘TestName’;
List List= Database.Query(SELECT Id FROM MyCustomObject__c WHERE Name = :myTestString);
Eg2:
String resolviedfield L = myvariable.field__c;
List L = Database.Query(‘SELECT Id FROM myCustomObject__c WHERE field__c = ‘+resolvedfield_L);

83. What is The Syntax of SOQL Statement?

Ans:

SELECT field1, field2,…. FROM Object_Type [WHERE condition]
Example:
List accountList =
[SELECT ID, Name, FROM Account];
List accountList =
[SELECT ID, Name, FROM Account WHERE annual revenue<10000];

84. What is Apex Interface?

Ans:

Interface is a collection of unimplemented methods. This will specify the signature of the method, types of inputs that we pass the method specifies what type is given as an output.
NOTE: Generally the interface methods we give it as global.

85. What is Batch Apex in Salesforce?

Ans:

Batch Apex: Batch Apex allows you to define a single job that can be broken up into manageable chunks, whereas every chunk can be processed separately.
In the Batch Apex it will fetch all the records on which you want to perform the field update and divide them into list of 200 records and on every 200 records operation is performed separately.
This would help us to execute on more than 10,000 records as, it won’t perform an operation on all the records in a single transaction instead it dividing them into Number of subtasks where each subtask many contain the records upto 4000.
Example:
If you need to make a field update of every record of account object in your organization, then we have governing limits that would restrict us from achieving the above task.
Reason: In a single transaction we can process only 10,000 records. Now in the above case if we have more than 10,000 records in the organization then we can not perform this field update.

86. What is Apex Scheduler?

Ans:

It will invokes the Apex class to run at specific time.
Anybody who want to schedule their class they have to implement schedulable interface.
Schedule Interface:
The class that implements this interface can be scheduled to run at different intervals. This interface has several methods they are
Public void execute(schedulablecontext sc)
Example:

Public class mySchedule implements schedulable
{
Public void execute(schedulablecontext sc)
{
Account a = new Account(Name = ‘Faraz’)
Insert a;
}
}

87. @isTest Annotation?

Ans:

If you define any method as @isTest then the method is test method just like what we have defined.

88. What is the Apex Trigger in Salesforce?

Ans:

Trigger is a Apex Code that executes before or after.
The following types of DML Operation:

  • Insert
  • Update
  • Delete
  • Merge
  • Upsert
  • Updelete

89. What are The Types of Apex Triggers in Salesforce?

Ans:

Triggers Are divided into 2 types

Before Triggers
After Triggers

Before Triggers:
Before Triggers can be used to update or validate values of a record before they are saved to the database.
After Triggers:
After Triggers Before Triggers can be used to access field values of the records that are the stored in the database and use this values to make changes in other records.
Syntax:
Trigger trigger_name on Object_Name(trigger_events)
{
Code_block
}
WHERE trigger_events can be comma separated list of events.

90. Adding Flows to Visualforce Pages

Ans:

Adding Flows to Visualforce Pages


 

91. What is Apex Managed Sharing?

Ans:

  • Apex Managed Sharing provides developers with the ability to support an application to share a requirements.
  • This type of sharing available to only users with modify all data permissions. Only this users can add/change apex managed sharing.
  • Apex Managed Sharing uses a Sharing reason (Apex Sharing Reason)

92. What is the Usage of apex program with within visualforce page?

Ans:

When you want to call apex class in visualforce page we have to declare in the following format.

< Apex : page controller = “class name “ >

Whenever we call a visualforce page in which controller attribute is defined it will first create an object for the apex class which is defined in controller.

When object is created for the apex class first it involves the constructor.

93. GROUP BY?

Ans:

With ApI version 18.0 and later /you can use group by with aggregate functions, such as sum() or max() to summarize the data and enable you to rollup query results rather than having to process the individual records in your code.

Syntax :

[ GROUP BY field GROUP BY LIST]

94. SOSL Statements In Salesforce Apex?

Ans:

SOSL statement evaluate to a list of sobjects , where each list contains the search results for a particular sobject type, The result lists are always returned in the same order as they were specified in the query.
If a SOSL query does not return any records for a specified sObject type , the search results include an empty list for that sObject.
for example, you can return a list of accounts, contacts, opportunities and leds that begin with the phase map.
List < list < subject >> search list = [ find ‘map*’ In ALL FIELDS RETURNING Account (ID, Name), contact, opportunity, lead ];
Note :
The syntax of the classon Apex differs from the syntax of the FIND clause in the SOAP API.
In Apex, the value of the FIND cause is demarcated with single quotes.
Example:
FIND ‘map*’ IN ALL FIELDS RETURNING account (Id, Name], Contact, Opportunity, Lead.
In the Force.com API, the value of the FIND Clause is demarcated with braces.
For Example:
FIND {map*} IN ALL FIELDS RETURNING account [Id,name], contact ,opportunity,lead.
From search list , you can create arrays for each object returned.
Account [ ] accounts = (( list < accounts > ) search list [0] );
Contact [ ] contacts = [( list ) search list [0]) ;
Opportunity [ ] opportunities = ((list < opportunity> ) search list [2]) ;
Lead [ ] leads = (( list < lead> ) search list [3]);

95. Javascript remoting for apex controllers

Ans:

Use javascript remoting in visualforce to call methods in apex controllers from javascript.

Javascript remoting has 3 parts.

  • The remote method invocation you add to the visualforce page, written in javascript.
  • The remote method definition in your Apex controller class.
  • This method definition is written in apex, but there are few differences from normal action methods.
  • The response handles callback function you add to or include in your vf page, written in javascript.

96. Adding javascript remoting to a vf page

Ans:

To use javascript remoting in a vf page , add the request as a java script invocation with the following from.

[namespace.] controller.method ( 
[parameters….,]
Call back Function,
[configuration]
);

Name space is the namespace of the controller class
Controllers is the name of your apex controller.
Method is the name of your apex controller method you are calling.
Parameters is the comma-separated list of parameters that your method takes.
Callback function is the name of the javascript function that will handle the response from the controller.
Configuration configures the handling of remote call and response.

97. What is the main difference between using data table vs .page block table tags ?

Ans:

PageBlock: For default salesforce standard format .
Data table: To design custom formats

98. Which tag is used with both radio buttons and picklists to create the selectable values?

Ans:

tag

99. What is Multitenant Architecture ?

Ans:

An application model in which all users and apps share a single, Common infrastructure and code base.

100. What is metadata – driven development model ?

Ans:

An app development model that allows apps to be defined as declarative ‘blueprints”, with no code required. Data Models, objects, forms,workflows, and more are defined by Metadata.



 

101. What are force platform sites ?

Ans:

Public websites and applications that are directly integrated with your salesforce organization without requiring users to log in with a username and password.

102. What is AppExchange directory ?

Ans:

A web directory where hundreds of appexchange apps are available to salesforce customers to review, demo, comment upon, and /or install. Developers can submit their apps for listing on the appexchange directory if they want to share them with the community.

103. What are some apex classes that are commonly used within controller ?

Ans:

Standard controller, select option, page reference, message, etc,

104. What are the effects of using the transient keyword ?

Ans:

The transient keyword prevents the data from being saved into view state. This should be used for very temporary variables.

105. Configuring javascript remoting requests

Ans:

Configure a remoting request by proving an object with configuration settings when you declare the remoting request.
javascript remoting supports the following configuration parameters.

Name

Datatype

Description

Buffer

Boolean

Whether to group requests executed close to each other in time into a single request. The default is true.

Escap

Boolean

Whether to escape the apex methods response. The defaults is true.

Timeou

Integer

The timeout for the request in mill Seconds. Default is 30000(30 second)

106. How to invoke batch apex job (or) how to execute the batch apex job programmatically?

Ans:

We can use database.executebatch ( ) method to programmatically begin the batch job.
Syntax

Public static ID execute batch ( sObject class name)
Public static ID execute batch (sObject class name, integes scope)

The above two methods are static methods of database class. We can use any one of the method to execute the batch job.
NOTE:
The class name what we are passing to the database.execute batch( ) method should be object of the class which has implemented database.batchable interface.

107. What is Future Annotation(@Future)?

Ans:

Use the future annotation to specify that these methods that are executed asynchronously.
Methods with future annotation must be static methods
Methods with future annotation can only return a void type.

Syntax:

global class class_name
{
@future
Static void methodname(parameters)
{
//body of the method
}

108.What is Metadata-driven development model?

Ans:

An app development model that allows apps to be defined as declarative “blueprints,” With no code required. Data model, objects, forms, workflows, and more are defined by metedata.

109. What is S-Control?

Ans:

S-Controls are the predominant salesforce.com widgets which are completely based on JavaScript. These are hosted by salesforce but executed at client side. S-Controls are superseded by VisualForce now.

110. Will Visualforce still supports the merge fields usage like S-control?

Ans:

Yes. Just like S-Controls. Visualforce pages support embedded merge fields.




 

111. What is SOAP?

Ans:

A protocol that defines a uniform way of passing XML-encoded data. SOAP Stands for Simple Object Access Protocol.

112. What is a Time Trigger?

Ans:

A setting that defines when time-dependent workflow actions should fire.

113. Does user can create insert their own custom logo, while creating their own custom applications?

Ans:

Yes user can upload their custom logo in documents and then they choose that logo for organization.

114. List things that can be customized on page layouts?

Ans:

We can customize different things on page layout like, Fields, Buttons, Custom Links and Related Lists. We can also create sections.

115. What is a “Self Relationship”?

Ans:

Self Relationship is a lookup relationship to the same object. Suppose let’s take an object “Merchandise”. Here we can create relationship in between the Account to Account (same object) object. That is called “Self Relationship”.

116. What are the main things need to consider in the “Master-Detail Relationship”?

Ans:

Record level access is determined by the parent, Mandatory on child for reference of parent, cascade delete (if you delete the parent, it can cascade delete the child).

117. What is difference between trigger and workflow?

Ans:

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

118. What is Wrapper class?

Ans:

A Wrapper class is a class whose instances are collection of other objects.
It is used to display different objects on a VF (Visual Force) page in same table.

119. SOQL Vs SOSL?

Ans:

SOQL- Salesforce Object Query Language

  • Using SOQL we can Search only on one object one time.
  • We can query on all fields of any datatype
  • We can use SOQL in the Triggers and the classes.
  • We can perform DML operation on sql query results.

SOSL(Salesforce object Search Language)

  • Using SOSL we can search on many objects at one time.
  • We can query only on fields whose data type is text,phone and Email.
  • We cannot use in Triggers but can in calsses.
  • We cannot perform DML operation on search results.

120. What is difference insert() and database .insert() ?

Ans:

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.


 

121. What is Static Resources?

Ans:

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.

122. How to call java script using Static Resource in Visual Force page?

Ans:

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

123. What is sharing rule?

Ans:

If we want to give the access to other users we use sharing rules.

124. How many ways we can share a record?

Ans:

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.

OWD:

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.

125. Unit testing code which has logic around the CreatedDate

Ans:

You can create sObjects in memory with arbitrary CreatedDate values by using JSON.deserialize. This doesn’t enforce the normal read-only field attributes that prevent you from setting a createdDate value. However you can’t commit arbitrary CreatedDate values to the database (or else it would be a serious security issue).
An example of doing so :
String caseJSON = ‘{“attributes”:{“type”:”Case”,”url”:”/services/data/v25.0/sobjects/Case/500E0000002nH2fIAE”},
“Id”:”500E0000002nH2fIAE”,
“CreatedDate”:”2012-10-04T17:54:26.000+0000?}’;
Case c = (Case) JSON.deserialize(caseJSON, Case.class );
System.debug(c.createdDate);
Note that I built the caseJSON string by creating a test case and serializing it, which is the easiest way to get JSON similar to what you want, then you can just tweak the values.

126. Ignoring Validation rules when deploying code

Ans:

I have seen a solution that uses a Custom Setting of ValidationRuleEnabled.
ALL validation rules set up have the && $Setup.CustomSetting__c.ValidationRuleEnabled__c added.
When you want to deploy any code then the administrator changes the Custom Setting to FALSE, deploy the new code; don’t forget to re-enable the Custom Setting!
Again this is not ideal as the ‘legacy’ code should be updated to accommodate the new validation rules; ideally at the time of creating the new validation rules (but who checks code coverage after making a small change like a validation rule?)

127. Can I find out if the current user has access to a record without querying?

Ans:

To find out if a particular user has Edit access to a record, use the UserRecordAccess object. This object is available in API version 24.0 and later. You can use SOQL to query this object to find out if the user has edit access to the record in question.
SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId = [single ID] AND RecordId = [single ID]

If you want to check a batch of records you can use
SELECT RecordId FROM UserRecordAccess WHERE UserId=:UserInfo.getUserId()
AND HasReadAccess = true ANDRecordId IN :allRecordIds LIMIT 200
But make sure that allRecordIds is a LIST of IDs. It doesn’t work if allRecordIds is a SET of IDs. I guess that’s a bug.
Also, only a maximum amount of 200 recordIds can be checked in one query.

128. Detecting governor limits through apex

Ans:

First of all, the exception thrown by hitting a limit, System.LimitException is uncatchable and means that your script will be killed, even if it happens inside a try/catch block. There is a class, Limits, that contains a number of static methods that allow you to check your governor limit consumption,
see: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_limits.htm
With that said, your example of @future calls per day is one of the limits that simultaneously is and isn’t a governor limit as I believe it throws a System.AsyncException instead which is not catchable, and kills your script as a LimitException would.

129. What is a concise function that formats a (String) decimal into a currency format in Apex?

Ans:

@RickMeasham’s method is a good one, but I ran into a couple rounding issues with negative values and fractional values. Here’s my edited version of the method that passes the tests I needed it to (not rendering -0.001 as “-0.00”, not rendering -1.10 as “-1.09”).

public static String formatCurrency(Decimal i) {
if (i == null || Math.abs(i) < 0.005) return ‘$0.00’;
String s = (i.setScale(2) + (i >= 0 ? 0.001 : -0.001)).format();
return s.substring(0, s.length() – 1);
}
(EDIT: changed “<= 0.005” to “< 0.005” per @RickMeasham’s advice below.)
(EDIT 2: actually realized, when I finished tests, that this updated method still had a few shortcomings related to rounding. I updated to delegate to Math.roundToLong per code below [which uses round half even, not half up as I stated in my comments erroneously]. It now passes all my unit tests, which you can see here: https://codepad.org/ycttSXjq)
private String formatCurrency(Decimal i) {
if (i == null) return ‘0.00’;
i = Decimal.valueOf(Math.roundToLong(i * 100)) / 100;
String s = (i.setScale(2) + (i >= 0 ? 0.001 : -0.001)).format();
return s.substring(0, s.length() – 1);
}

130. How do you write a unit test for a trigger whose only function is to make a callout?

Ans:

Both future methods and callouts can be unit tested.
To test future methods simply make your call to any future method between Test.startTest();and Test.stopTest(); statements and the future method will return when Test.stopTest(); is called. See the documentation for the Test class here: System.Test
Testing callouts is a bit trickier though. Basically in your callout code you check to see if you’re executing within a unit test context by checking Test.isRunningTest() and instead of getting your callout response from an HttpResponse.send() request, you return a pre-built test string instead.
There’s also an older example of callout unit testing that uses a static variable you set in your unit test. Just replace that static variable with a call to Test.isRunningTest() and their example works fairly well as well.



 

131. Can report data be accessed programmatically?

Ans:

Update for Winter ’14
API:
I think the biggest announcement that developers have been waiting for API wise is the availability of our Analytics API. We introduced a limited pilot in summer 13 and now the Analytics REST API is generally available. The Analytics API lets you integrate Salesforce report data into your apps programmatically and has several resources that let you query metadata, and record details.
Source – Winter 14 Developer Preview

132. How do you unit test a trigger when you don’t know the required fields?

Ans:

Customers can have validation on custom fields via validation rules and triggers, so handling that in your unit tests without customer intervention is next to impossible. The first step to reducing issues is to have your test data populate all standard fields and ensure the data uses the most common formatting for your customer base (US style phone numbers and addresses for the US for example).

Beyond that you can use the new Reflection features added to Salesforce in Summer ’12 to allow customers to create unit test data classes that can be used by your managed package. Basically you define a test data generation interface and the customer creates an Apex class to generate data for you.

Using the method for unit tests run on install might be problematic as you’d have to have the customer create the class before they install your package and your package could only look for the class by name (or iterate through all default namespace classes and check for the correct interface). However, it’s no longer necessary for unit tests to run during installation for managed packages and by default they do not.

The Reflection method requires some coding knowledge on the customer side, but you could add a tool in your application to generate the custom unit test data class for the customer.

FYI, it’s no longer necessary for managed package unit tests to succeed in customer orgs. They’re not required on install, they will no longer prevent deployment to production and they don’t count as part of the customers unit test coverage percentage for purposes of deployment. The only exception to that is if the customer uses ANT and sets the runAllTests parameter to true.

133. Deleting a class without IDE

Ans:

This can be done with the Force.com Migration Tool:https://wiki.developerforce.com/page/Force.com_Migration_Tool
See the full documentation here: https://wiki.developerforce.com/page/Force.com_Migration_Tool

The tool can create or delete any meta-data that can be created through the Force.com IDE or Change Sets. It comes with a sample config file that contains example deployments for deploying objects and Apex code and deleting them as well. The documentation has a very detailed step-by-step guide here:
https://www.salesforce.com/us/developer/docs/daas/index_Left.htm#StartTopic=Content/forcemigrationtool.htm

134. Is there a defacto 3rd party utilities library for Apex such as Apache Commons is for Java?

Ans:

Apex-lang is about as close to a Java-style library as you can get. Contains several string, database, and collection utilities that mimmick Java functionality. Be aware though, some stuff including Comparing and Sorting collections is out of date with the advent of the Comparable interface in Apex.In addition to apex-lang, and like you suggest, I typically create or reuse static helper methods throughout my projects. Static helper methods are very convenient for reusing code in Chatter functionality, DML handling, Exception handling, Unit testing, etc.

135. Using transient keyword to store password in hierarchy custom setting

Ans:

Because your myPref property is transient the initialisation you perform in the constructor won’t round trip when the page posts back.
When I’ve used transient and a protected custom setting I use separate properties that are transient and then only work with the custom setting in the post back method.
Controller
Skip code block

public with sharing class TestCustomSettings {
// transient to ensure they are not transmitted as part of the view state
public transient String password1 {get; set;}
public transient String password2 {get; set;}
public PageReference save() {
// I’ve changed this to getInstance() rather than getValues()
TestR__c myPref = TestR__c.getInstance(UserInfo.getOrganizationId());
if(myPref == null) {
myPref = new TestR__c();
myPref.SetupOwnerId = Userinfo.getOrganizationId();
}
myPref.Password1__c = password1;
myPref.Password2__c = password2;
// Note that by using upsert you don’t need to check if the Id has been set.
upsert myPref;
}
}

Visualforce page
You can use inputSecret rather than inputField in the Visualforce page so that the browser will mask the input.

136. Is there a way to setup continous integration for apex tests?

Ans:

There are a couple of decent Dreamforce presentations here: Team Development: Possible, Probable, and Painless and Continuous Integration in the Cloud.
We ran into some issues with this in practice and there was no way to get true automation (i.e., set it and forget it). We were also setting it up with Selenium.
Here were the issues that I remember.
Some features aren’t supported in the metadata API and cannot be moved via the ant migration. If you have any unit tests that work with those features, you have to manually work on your CI org.
Deletions are harder to maintain. You have to manually update and apply a destructiveChanges.xml file or replicate the deletion in the CI org.
We ran into a situation where some metadata XML files had ‘invalid’ data in them. The suggested solution was to build a post checkout script that manipulates the offending XMLs into valid XMLs. Not ideal.
On projects, we wanted to track just our changes and push out just our changes in source control. In theory, this would allow much easier rebaselining. This would have required more manual maintenance of XML files (e.g., 2 new fields added on Account and only want to push those 2 fields not all (*) fields).
My conclusion is that it is worth doing if you can get it set up, but if you are working on shorter term projects and don’t have a decent amount of time budgeted in for it, it probably isn’t worth setting up.
Although it isn’t CI, check out https://developer.force.com/cookbook/recipe/automated-unit-test-execution. You could set it up to run every hour or something like that.

137. What are the implications of implementing Database.Stateful?

Ans:

Daniel Ballinger: No, batches do not ever run simultaneously. You are correct, however, that serialization is the culprit here.
grigriforce: what’s your batch size? If you’re doing a million records, and your batch size is 1, then you will serialize/deserialize your state 1M times. Even with a small serialized object, that’s gonna hurt.

138. What are the recommended ways to refactor in Apex?

Ans:

I use the second method. After refactoring, I select the ‘src’ folder, use File Search/Replace and all the changes are made and saved to the server in one go.

139. What is a good set of naming conventions to use when developing on the Force.com platform?

Ans:

Follow the CamelCase Java conventions, except for VF pages and components start with a lower case letter.

Triggers:

Trigger – The trigger itself. One per object.
TriggerHandler – Class that handles all functionality of the trigger
TriggerTest

Controllers:

Controller
ControllerExt
ControllerTest
ControllerExtTest

Classes:

Test (These might be Util classes or Service classes or something else).
Visualforce pages and components:
[optionalDescription] (without the suffix Controller). There might be multiple views so could also have an extra description suffix.
Object Names and custom Fields
Upper_Case_With_Underscores
Variables/properties/methods in Apex
camelCaseLikeJava – more easily differentiated from fields
Test methods in test classes
test – For example, testSaveOpportunityRequiredFieldsMissing, testSaveOpportunityRequiredFieldsPresent, etc.
Working on something that would be used as an app or in some cases just a project? If yes, then do the following:
Prefix all custom objects, apex classes, Visualforce pages and components with an abbreviation so that they are easier to identify (e.g., easier for changesets). For example the WidgetFactory app would have the prefix wf on those. Additionally, when adding custom fields to a standard object they would also be prefixed to identify them as part of the app/package.
The main reason for the Object and Fields Names using Upper_Case_With_Underscores is that when you type in the name field or object with spaces it automatically adds the underscores. Although Apex is case insensitive, always refer to the Objects and Custom Fields in the code as Upper_Case_With_Underscores as well for consistency all around and consistency with what is generated by the SOQL schema browser and other tools. Object and Field Labels (which are generally ignored by code but visible to users) should keep spaces, not underscores.

140. Why use Batch Apex?

Ans:

A Batch class allows you to define a single job that can be broken up into manageable chunks that will be processed separately.

  1. One example is if you need to make a field update to every Account in your organization. If you have 10,001 Account records in your org, this is impossible without some way of breaking it up. So in the start() method, you define the query you’re going to use in this batch context: ‘select Id from Account’. Then the execute() method runs, but only receives a relatively short list of records (default 200). Within the execute(), everything runs in its own transactional context, which means almost all of the governor limits only apply to that block. Thus each time execute() is run, you are allowed 150 queries and 50,000 DML rows and so on. When that execute() is complete, a new one is instantiated with the next group of 200 Accounts, with a brand new set of governor limits. Finally the finish() method wraps up any loose ends as necessary, like sending a status email.
  2. So your batch that runs against 10,000 Accounts will actually be run in 50 separate execute() transactions, each of which only has to deal with 200 Accounts. Governor limits still apply, but only to each transaction, along with a separate set of limits for the batch as a whole.

    Disadvantages of batch processing:

  • It runs asynchronously, which can make it hard to troubleshoot without some coded debugging, logging, and persistent stateful reporting. It also means that it’s queued to run, which may cause delays in starting.
  • There’s a limit of 5 batches in play at any time, which makes it tricky to start batches from triggers unless you are checking limits.
  • If you need access within execute() to some large part of the full dataset being iterated, this is not available. Each execution only has access to whatever is passed to it, although you can persist class variables by implementing Database.stateful.
  • There is still a (fairly large) limit on total Heap size for the entire batch run, which means that some very complex logic may run over, and need to be broken into separate batches.



 

141. Documenting Salesforce.com Apex class files

Ans:

I have used apexDoc for a while and we are starting to roll it out more fully for our use at my organisation. It is open source software and so you could always contribute some updates for it 🙂 What features are you wanting to add to it that it doesn’t have (just to give a flavour)?
In answer to your questions

  1. I don’t think anybody has successfully managed to do this. There is an idea of the ideas exchange for it to be done but it seems to gain very little support.
  2. Theoretically it should be pretty easy as apex is a Java DSL. Have you tried running Doxygen and if so what errors does it throw up?
  3. I use ApexDoc to generate some basic output and then have a little script tied in to copy across custom css and things. It isn’t perfect but it does for the small amount we need at the moment.

I believe the IDE is being open sourced at some time in which case I would imagine the antlr grammar file would become available which may help you out.
I know it is not really an answer for what you wanted to hear per se, but sadly it’s all we have atm (and I would love a nicer documentation generator!!)
Paul

142. Workarounds for Missing Apex Time.format() Instance Method

Ans:

You could just split the DateTime format() result on the first space – does that give you what you’re looking for?

public String myDateFormat(DateTime dt) {
String[] parts = dt.format().split(‘ ‘);
return (parts.size() == 3) ? (parts[1] + ‘ ‘ + parts[2]) : parts[1];
}
produces
6:38 PM
for me in English (United States), and
18:42
in French(France).
UPDATE
As tomlogic points out, the above method is not very robust – some locales may include spaces in the date or time portion of the format, and the ordering is not consistent. This second attempt assumes that the date and time are separated by zero or more spaces, but handles spaces within the two portions, and either ordering of date and time. The only assumption made is that the formatted Date is contained within the formatted Time:
public String myDateFormat(DateTime dt) {
return dt.format().replace(dt.date().format(), ”).trim();
}
Seems to work fine for Hebrew, Vietnamese & Korean, as well as English and French.

143. Is there an average method for apex math

Ans:

Unfortunately the standard math methods only include simpler operations (i.e. those that work on a single, or two values), so it looks as though you’ll have to roll your own method.
Of course the number of script statements executed will be proportional to the length of the list, so of the lists are ever of a fixed size it could be worth using a macro to generate the addition part for you:

Int sum = i[0] + i[1] + … i[n];
Doing so would only count for one statement, but you’ll only need this if governor limits are of concern which is often not a worry.
If govenor limits aren’t an issue you could create a function along these lines:
Skip code block
Integer[] myInts = new Integer[]{1, 2, 3, 4, 5, 6, 7};
Integer total = 0;
Double dAvg;
for (Integer i : myInts) {
total += i;
}
dAvg = Double.valueOf(total) / myInts.size();
return dAvg;

144. Grammar for creating an Apex parser

Ans:

Keep an eye on Apex tooling api, which is used in Developer console. This is supposed to be released to public access soon.

145. Does ‘default value’ do anything if the object is created through Apex?

Ans:

New feature coming in the next release:
Foo__c f = Foo__c.sobjecttype.newSObject(
recordTypeId, // can be null
true); // loadDefaultValues

146. Detect the current LoggingLevel in Apex

Ans:

Unfortunately, I don’t think there is a way to check the current logging level in APEX.

147. Call Apex class method on the fly (dynamically)

Ans:

While you can instantiate a class based on its name using the Type system class, you can’t dynamically locate a method and execute it. The best that you can do is to dynamically create an instance of a class that implements an interface and execute one of the methods on the interface.
There’s more information on the Type class and an example in the :
Apex Developer’s Guide

148. SOQL – query a query

Ans:

It sounds like you’re talking about using nested SOQL queries. Here’s an example of querying a parent and two child objects in one query, using the relationship name for each related list of objects:

list accswithchildren = [select Id, Name, CreatedDate,
(select Id, CreatedDate from Tasks order by CreatedDate desc limit 1),
(select Id, Service_Date__c from Custom_Object__r order by Service_Date__c desc limit 1)
from Account where Id in :setofids];
You can then loop through those Accounts in Apex, and for each one, there is a list (size 0 or 1) of Tasks and Custom_Object__c:
for (Account a : accswithchildren)
{
list theseTasks = a.Tasks;
list otherobjects = a.Custom_Object__r;
//do something with these records
}

149. What’s the best way to check if person accounts are enabled via Apex Code?

Ans:

I’ve found two methods to accomplish this.

Method 1

Try to access the isPersonAccount property on an Account and catch any exception that occurs if that property is missing. If an exception is generated then person accounts are disabled. Otherwise they’re enabled. To avoid making person accounts required for the package you assign the Accountobject to an sObject and use sObject.get( ‘isPersonAccount’ ) rather than accessing that property directly on the Account object.
This method takes ~3.5ms and negligible heap space in my testing.
Skip code block
// Test to see if person accounts are enabled.

public Boolean personAccountsEnabled()
{
try
{
// Try to use the isPersonAccount field.
sObject testObject = new Account();
testObject.get( ‘isPersonAccount’ );
// If we got here without an exception, return true.
return true;
}
catch( Exception ex )
{
// An exception was generated trying to access the isPersonAccount field
// so person accounts aren’t enabled; return false.
return false;
}
}

Method 2

Use the account meta-data to check to see if the isPersonAccount field exists. I think this is a more elegant method but it executes a describe call which counts towards your governor limits. It’s also slightly slower and uses a lot more heap space.
This method takes ~7ms and ~100KB of heap space in my testing.
// Check to see if person accounts are enabled.

public Boolean personAccountsEnabled()
{
// Describe the Account object to get a map of all fields
// then check to see if the map contains the field ‘isPersonAccount’
return Schema.sObjectType.Account.fields.getMap().containsKey( ‘isPersonAccount’ );
}

150. Can’t Deploy Due to Errors in 3rd Party Packages

Ans:

It was previously possible to install managed packages and Ignore APEX Test Errors this isn’t the case anymore.
Your probably going to have to uninstall them if you want to deploy from Sandbox to production, and reinstall them.
If it’s Milestones PM (the package) is you can probably get an unmanaged version to work with and fix the bugs.
UPDATE
Looks like you are using the unmanaged package. So I think if you don’t want to uninstall before going to production your going to have to fix those errors manually by fixing the code.
Unfortunately, SFDC test methods don’t live in a complete vacuum where you can run tests against your org without bumping other code, even when you go to deploy.


 

151. How Can I Tell the Day of the Week of a Date?

Ans:

Formulas
There isn’t a built-in function to do this for you, but you can figure it out by counting the days since a date you know. Here’s the concept: I know that June 29, 1985 was a Saturday. If I’m trying to figure out the day of the week of July 9 of that year, I subtract the dates to determine the number of days (10), and then use modular division to figure to remove all the multiples of 7. The remainder is the number of days after Saturday (1 = Sunday, 2 = Monday, etc.) and you can use that number in your logic:
MOD(DATEVALUE( Date_Field__c ) – DATE(1985,7,1),7)
Apex Code
You could do the same thing with time deltas, but you can also use the poorly documentedDateTime.format() function:
// Cast the Date variable into a DateTime
DateTime myDateTime = (DateTime) myDate;
String dayOfWeek = myDateTime.format(‘E’);
// dayOfWeek is Sun, Mon, Tue, etc.

152. What is App in Sales force?

Ans:

An app is a group of tabs that work as a unit to provide functionality. Users can switch between apps using the Force.com app drop-down menu at the top-right corner of every page.
You can customize existing apps to match the way you work, or build new apps by grouping standard and custom tabs.
Navigation to create app in Sales force: Setup ->Build ->Create->App-> Click on new and create your application according to your requirements.

153. What is the object in Salesforce.com?

Ans:

Objects are database tables that allow you to store data specific to your organization in salesforce. You can use custom objects to extend salesforce.com functionality or to build new application functionality.
When you create a custom object, we can create a custom tab, customized related lists, reports, and dashboards for users to interact with the object data. You can also access custom object data through the Force.com API.
Navigation to create object in sales force: Setup->Build->Create->Object-> Click on new object and create object according to your requirement.

154. How many relationships included in SFDC & What are they?

Ans:

We are having two types of relationships, they are

  • Lookup Relationship
  • Master-Detail Relationship

155. What is a “Lookup Relationship”?

Ans:

This type of relationship links two objects together,
Up to 25 allowed for object
Parent is not a required field.
No impact on a security and access.
No impact on deletion.
Can be multiple layers deep.
Lookup field is not required.

156. What is “Master-Detail Relationship”?

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.
Up to 2 allowed to object.
Parent field on child is required.
Access to parent determines access to children.
Deleting parent automatically deletes child.
A child of one master detail relationship cannot be the parent of another.
Lookup field on page layout is required.

157. How can I create Many – to – Many relationship?

Ans:

Lookup and Master detail relationships are one to many relationships. We can create many – to – Many relationship by using junction object. Junction object is a custom object with two master detail relationships.

158. A custom object contains some records, now my requirement is to create field in this object with master detail relationship. Can we create master detail relationship in this case?

Ans:

No, directly we cannot create master details relationship if custom object contains existing records.
Following are the steps to create to create master-detail relationship when records are available in custom object.
First create field with lookup relationship.
And then associate look field with parent record for every recordNext change the data type of the field from look up to Master detail.

159. List examples of custom field types?

Ans:

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.

160. What is TAB in Salesforce?

Ans:

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



 

161. What are the actions in workflow?

Ans:

Email Alert
Task
Field Update
Outbound Message
Go through the below link for the more information about workflow actions HTTP://WWW.SALESFORCETUTORIAL.COM/SALESFORCE-WORKFLOW-AUTOMATION-WORKFLOW-MANAGEMENT/

162. How many ways we can made field is required?

Ans:

While creation of field
Validation rules
Page Layout level

163. What is difference between Role and Profile?

Ans:

Role is Record level access and it is not mandatory for all users.
Profile is object level and field level access and it is mandatory for all users.

164. What is the maximum size of the PDF generated on visualforce attribute renderAs?

Ans:

15MB

165. How many controllers can be used in a visual force page?

Ans:

Salesforce come under SAAS so, we can use one controller and as many extension controllers.

166. What is the difference between Action support and Action function?

Ans:

Action function: Invoke the controller method from java script using AJAX and we can use action function from different places on visual force page.
Action support: Invoke the controller method using AJAX when even occurs on page like onMouseOver, onClick, ect… and we can use action support for particular single apex component.

167. How many ways we can call the Apex class?

Ans:

Visual force page
Web Service
Triggers
Email services

168. How to create Master Details relationship between existing records?

Ans:

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.

169. What is permission set?

Ans:

Permission sets extend user’s functional access without changing user’s profile.
Ex: A user has only read access through profile on custom object, administrator want to give access Edit and create operations to him without changing the profile. Administrator creates the permission set having edit and creates operation on custom object and assign to that user.

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




 

171. How we can change the Grant access using role hierarchy for standard objects?

Ans:

Not possible.

172. Explain the uses of “Transfer Record” in profile?

Ans:

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.

173. What is Field dependency?

Ans:

According to the field selection on one field filter the pick list values on other field.

174. Is check box performs like controlling field?

Ans:

Yes possible. Controlling field should be Check box or pick list.

175. How many field dependencies we can use in Visual Force page?

Ans:

Maximum we can use 10 field dependencies in VF page.

176. What is Roll-up summary?

Ans:

Roll-up displays the count of child records and calculate the sum, min and max of fields of the child records.

177. How to create Roll-up summary field on lookup relation?

Ans:

Not possible. Roll-up summary is enabled for only Master –Detail relationship.

178. What are Record Types?

Ans:

Record Types are restrict the pick list values and assign to the different page layouts for different Record Types.

179. What is Audit Trail?

Ans:

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.

180. What are Report Types?

Ans:

4 Types of reports in Salesforce

  • Tabular Reports
  • Summary Reports
  • Matrix Reports
  • Joined Reports

 

181. What is Dashboard?

Ans:

Dashboard is a pictorial representation of report. We can add up to 20 reports in single dashboard.