I. Programmatic features Flashcards

1
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How can we implement pagination in Visualforce?

A

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. Take a look at the sample code below:

{!a.name}

Previous
Next

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How can you call a controller method from JavaScript?

A

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

Look at the below piece of code to understand how a controller method is called using actionfunction.

function JSmethodCallFromAnyAction()
{
callfromJS();
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

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

A

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. The below piece of code shows the syntax for including them:

<p>
</p>
<p>
</p>
<p>
</p>
<h1 style="">
 </h1>
<p>
</p>
<p>
</p>
<p>
</p>
<p>

</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

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

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

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

A

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 country_city = new Map();
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How can you embed a Visualflow in a Visualforce page?

A
  1. Find the flow’s unique name.
    a. From Setup, enter Flows in the Quick Find box, then select Flows.
    b. Click the name of the flow.
    c. Copy the unique name of the flow.
  2. From Setup, enter Visualforce Pages in the Quick Find box, then select Visualforce Pages.
  3. Define a new Visualforce page, or open an existing one.
  4. Add the component somewhere between the tags.
  5. Set the name attribute to the unique name of the flow.

For example:

  1. Click Save.
  2. Restrict which users can access the Visualforce page.
    a. Click Visualforce Pages.
    b. Click Security next to your Visualforce page.
    c. Move all the appropriate profiles from Available Profiles to Enabled Profiles by using the ‘add’ and ‘remove’ buttons.
    d. Click Save.
  3. Add the Visualforce page to your Force.com app by using a custom button, link, or Visualforce tab.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the use of “@future” annotation?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What are the different methods of batch Apex class?

A

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<p>){}
Finish method:
global void finish(Database.BatchableContext BC){}</p>

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is a Visualforce component?

A

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:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Trigger.new?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What all data types can a set store?

A

Sets can have any of the following data types:

  • Primitive types
  • Collections
  • sObjects
  • User-defined types
  • Built-in Apex types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an sObject type?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the difference between SOQL and SOSL?

A

SOQL (Salesforce Object Query Language) -

  • Only one object can be searched at a time
  • Can query any type of field
  • Can be used in classes and triggers
  • DML Operation can be performed on query results
  • Returns records

SOSL (Salesforce Object Search Language)

  • Many objects can be searched at a time
  • Can query only on email, text or phone
  • Can be used in classes, but not triggers
  • DML Operation cannot be performed on search results
  • Returns fields
17
Q

What is an Apex transaction?

A

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.

18
Q

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

A
Global class is accessible across the Salesforce instance irrespective of namespaces.
Whereas, public classes are accessible only in the corresponding namespaces.
19
Q

What are getter methods and setter methods?

A

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.