Sie sind auf Seite 1von 5

What is the view state?

View-State is to maintain the state of the non-transient data members of


Controller and Controller extensions.
The Purpose of keeping view-state is to allow Salesforce to remember the
instance information of the controller and controller extensions.

Lets look at a simple example of how the instance information can be extracted and
passed around:
// a simple class
Class Person {
public string Name;
public Person(string Name) {
this.Name = Name;
}
}
// create an instance of Person
Person p = new Person ('Maurice');
// serialize the instance and store as a string
string sp = JSON.serialize(p);
system.debug(sp); // output: USER_DEBUG|[15]|DEBUG|{"Name":"Maurice"}
// Recreate an instance out of the string
Person q = (Person)JSON.deserialize(sp, Person.class);
system.debug(q.name); // output: USER_DEBUG|[19]|DEBUG|Maurice
// proof p and q are different instances
system.assert(p != q);
Well, with thousands of users you might guess it will be hard for SalesForce to keep all
the created instances of controllers and controller extensions in memory. Instead they
apply a principle similar to what was demonstrated above.
Whenever a page is served the instances are serialized and encrypted into what is
called the view state. Whenever you initiate a call back to SalesForce, the view state
is send back to SalesForce where the instances are recreated before handling your
code.

What effects the view state.?


As we mentioned before, View-State is to maintain the state of the non-transient data
members of Controller and Controller extensions.
So by not putting data into your controller, you already greatly control the view state.
Here is and example page and controller:

<apex:page controller="ViewStateTestController">
<apex:form>
<apex:dataTable value="{!myUsers}" var="u">
<apex:column >
<apex:facet name="header">Username</apex:facet>
<apex:outputText value="{!u.Username}"/>
</apex:column>
<apex:column >
<apex:facet name="header">Email</apex:facet>
<apex:outputText value="{!u.Email}"/>
</apex:column>
</apex:dataTable>
</apex:form>
</apex:page>

public class ViewStateTestController{


public final list<user> myUsers {get; set ;}
public ViewStateTestController() {
myUsers = [Select Username, Name, Id, Email, City, Alias From User Limit 500];
}
}
When we run this example in the Development Mode enabled I see that my view state
is 22KB. We are querying more columns than that we're displaying, let's see what
happens when we optimize this:
Total size of this view state is 135KB,
public class ViewStateTestController{
public final list<user> myUsers {get; set ;}
public ViewStateTestController() {
myUsers = [Select Username, Email From User Limit 500];
}
}
We removed the columns that are not displayed, now my view state reports: 15KB.
Wow, that's a reduction by 32%,
Were actually not manipulating the data in the list, we are only displaying it.
Here comes in the magic words called: transient and Static Variables
Transient tells Salesforce You can forgets all about the data in the list after it is
displayed in the page and we don't care for this data anymore, so you can forget it. If
we implement this we get:

public class ViewStateTestController{


transient public final list<user> myUsers {get; set ;}
public ViewStateTestController() {
myUsers = [Select Username, Email From User Limit 500];
}
}
Salesforce forgets all about the data in the list (after it is displayed in the page). And
does not add it to the view state. Now my view state reports: 5KB. Now we're talking,
we achieved a reduction of 77%.
Static: A static variable is not part of the instance. As mentioned only data in the
instance of the controller and controller extensions will go into the view state, so static
variables will not go into the view state.
public class ViewStateTestController{
static public final list<user> myUsers {get; set ;}
public ViewStateTestController() {
myUsers = [Select Username, Email From User Limit 500];
}
}
My view state size: 5KB just like when I was using transient.

Private variables (no no)


Although private variables are not visible from the "outside" this does not mean they
are not part of the view state. So private variable will go into the view state.
public class ViewStateTestController{
private final list<user> myUsers {get; set ;}
public ViewStateTestController() {
myUsers = [Select Username, Email From User Limit 500];
}
}
My view state size: 11KB a little lower then with public, but only 27%.
It will however data not display on the page anymore which is primarily why the
view state smaller.

1. What is Salesforce?
Salesforce is one of the most flexible and powerful web based databases available on the market. More
than 170,000 companies and 17,000 nonprofit organizations have already discovered the results
Salesforce.com can deliver.

Cloud for Synagogues is built on the Salesforce platform. It is a great starting point for any synagogue
looking to track constituents, members, donors, Yahrzeits, Aliyahs, donations, Sunday School attendance,
volunteers, and cases.
2. What is a cloud computing?
Cloud computing is a type of computing that relies on sharing computing resources hosted on the Internet
to store, manage, and process data rather than having local servers or personal devices to handle
applications.
3. What is App in Sales force?
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.
4. What is object in Sales force?
Custom objects are database tables that allow you to store data specific to your organization in
salesforce.com. You can use custom objects to extend salesforce.com functionality or to build new
application functionality.
Once you have created a custom object, you can create a custom tab, custom related lists, reports, and
dashboards for users to interact with the custom 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.
5. What is the difference between public cloud and private cloud? Is salesforce.com is a public cloud
or private cloud?
Public Cloud: Could services are provided as a service over the Internet with little or no control over the
underlying technology infrastructure. More than one tenant can use the same resources.
Private Cloud: This also offers activities and functions as a service but is deployed over a company
intranet or hosted datacenter. This is private product for a company or organization offering advance
security.
Salesforce.com: Is a public cloud as it is hosted on salesforce.com data centers and data of more than one
tenant resides on same servers.
6. What are different kinds of reports?

Tabular: Tabular reports are the simplest and fastest way to look at data. Similar to a spreadsheet,
they consist simply of an ordered set of fields in columns, with each matching record listed in a row.
Tabular reports are best for creating lists of records or a list with a single grand total. They cant be used
to create groups of data or charts, and cant be used in dashboards unless rows are limited. Examples
include contact mailing lists and activity reports.

Summary: Summary reports are similar to tabular reports, but also allow users to group rows of
data, view subtotals, and create charts. They can be used as the source report for dashboard
components. Use this type for a report to show subtotals based on the value of a particular field or when
you want to create a hierarchical list, such as all opportunities for your team, subtotaled by Stage and
Owner. Summary reports with no groupings show as tabular reports on the report run page.

Matrix: Matrix reports are similar to summary reports but allow you to group and summarize data
by both rows and columns. They can be used as the source report for dashboard components. Use this
type for comparing related totals, especially if you have large amounts of data to summarize and you
need to compare values in several different fields, or you want to look at data by date and by product,
person, or geography. Matrix reports without at least one row and one column grouping show as
summary reports on the report run page.

Joined: Joined reports let you create multiple report blocks that provide different views of your
data. Each block acts like a sub-report, with its own fields, columns, sorting, and filtering. A joined
report can even contain data from different report types.
7. What is a SALESFORCE.COM?
Salesforce.com is a global cloud computing company headquartered in San Francisco, California. Though
best known for its customer relationship management (CRM) product, It is currently ranked the most
innovative company in America by Forbes magazine.The company was founded in March 1999 by former
Oracle executive Marc Benioff.
8. What is a CRM?
Customer relationship management (CRM) is a model for managing a companys interactions with current
and future customers. It involves using technology to organize, automate, and synchronize
sales,marketing, customer service, and technical support.
9. What are the benefits of CRM?
Growth in Number of customers.
Maximization of opportunities.
Long term profitability and sustainability.
Helps sales staff closedealy faster.
Reduce cost.
Increase Customer satisfaction
Ensuring customer focus.
10. What are difference between SOQL and SOSL in Salesforce ?
SOQL

SOSL

Its a Salesforce Object Query Language.

Its a Salesforce Object Search Language.

Search in Single Object.

Search in Entire Organization or Data base.

Returns Records.

Returns Fields.

It can use in Triggers.

It can use in Triggers.

Das könnte Ihnen auch gefallen