Saturday, 17 December 2011

Triggers

This is the  tutorial in series and we will see that how to create a Trigger and Test Cases in salesforce.


A trigger is an Apex script that executes before or after specific data manipulation language (DML) events occur, such as before object records are inserted into the database, or after records have been deleted.
Triggers are stored as metadata in Salesforce.com. A list of all triggers in your organization is located at Setup | Develop | Apex Triggers. In addition to this list, triggers are associated and stored with specific objects.
To define a trigger:




1. For a standard object, click Setup | Customize, click the name of the object, then click Triggers.For a custom object, click Setup | Create| Objects and click the name of the object.For campaign members, click Setup | Customize | Campaigns | Campaign Member| Triggers.For case comments, click Setup | Cases | Case Comments | Triggers.
For email messages, click Setup | Cases | Email Messages| Triggers.


2. In the Triggers related list, click New.


3. Click Version Settings to specify the version of Apex and the API used with this trigger. If your organization has installed managed packages from the AppExchange, you can also specify which version of each managed package to use with this trigger. Generally, you should use the default values for all versions. This associates the trigger with the most recent version of Apex and the API, as well as each managed package. You can specify an older version of a managed package if you want to access components or functionality that differs from the most recent package version. You can specify an older version of Apex and the API to maintain specific behavior.


4. Select the Is Active checkbox if the trigger should be compiled and enabled. Leave this checkbox deselected if you only want to store the script in your organization’s metadata. This checkbox is selected by default.


5. In the Body text box, enter the Apex for the trigger. A single trigger can be up to 32,000 characters in length.


To define a trigger, use the following syntax:


trigger triggerName on ObjectName (trigger_events) {
code_block
}
where trigger_events can be a comma-separated list of one or more of the following events:
• before insert
• before update
• before delete
• after insert
• after update
• after delete
• after undelete
So, lets start with creating trigger.
I want that duplicate student should not be created on the basis of Email id. we can achieve this by other way also, like during creation of email field, we can specify it as unique field.
Open eclipse and right click on salesforce project and select Create new Trigger, as shown in below image


As you can see, to create trigger we have to select the Apex version and operations in wizard.


During Trigger creation, keep in mind that it may be required in bulk operations so governor limit may be problem.


So instead of getting query for all triggers individually, I created an array and after that created a set of email entered for all records, and loop through all records invidually and checked for duplicity.


Only one SOQL is fired instead of all triggers individually and thus can work for bulk insert.


For SOQL Best Practice refer :
http://wiki.developerforce.com/index.php/Best_Practice:_Avoid_SOQL_Queries_ Inside_FOR_Loops


Q:1I want that duplicate student should not be created on the basis of Email id. we can achieve this by other way also, like during creation of email field, we can specify it as unique field.
Open eclipse and right click on salesforce project and select Create new Trigger, as shown in below image




Code:

=========
trigger Trigonstudent on Student__c(before insert){


List<Student__c> studentlist=Trigger.new;
set<String> emailset=new set<String>();


        for(Student__c s:studentlist){
        
              emailset.add(s.Email__c);
  
}
List<Student__c> duplicatestudentlist=[select s.name,s.email__c from Student__c   s where s.Email__c in : emailset];
set<string> duplicateemailset=new set<string>();


for(Student__c s:duplicatestudentlist){


  duplicateemailset.add(s.Email__c);
  }
  for(Student__c s:studentlist){


    if(duplicateemailset.contains(s.Email__c)) {


      s.Email__c.addError('Record already exist with some emailid');
           }
  }
}




Then We get  the things like below:







Note: You can add, edit, or delete Apex using the Salesforce.com user interface only in a Developer Edition organization, a Salesforce.com Enterprise Edition trial organization, or sandboxorganization. In a Salesforce.com production organization, you can only make changes to Apex by using the Metadata API


deploy call, the Force.com IDE, or theForce.com Migration Tool. The Force.com IDE and Force.com Migration Tool are free resources provided by salesforce.com to support its users and partners, but are not considered part of our Services for purposes of the salesforce.com Master Subscription Agreement.

Test Cases in Salesforce :

Test case integral part of code developement.
·         You must have at least 75% of your Apex scripts covered by unit tests to deploy your scripts to production environments. In addition, all triggers should have some test coverage.
·         Salesforce.com recommends that you have 100% of your scripts covered by unit tests, where possible.
·         Calls to System.debug are not counted as part of Apex code coverage in unit tests.
So, here we are going to create Test Case for trigger which we have written:


Testclass for it:
=============
@isTest 
private class TestonstudentTriggers {
    static testMethod void myUnitTest() {
         Student__c s = new Student__c();
            s.Name = 'Om Test';
            s.Lastname__c = 'LastName';
            s.Installment__c = 2000;
            s.Email__c = 'admin@shivasoft.in';
      try{
             insert s;
        }
        catch(System.DMLException e){
                                                System.assert(e.getMessage().contains('Record already exist with same email Id'));
       }
 }
}

When we run this we get through setup->Develop->ApexClasses




3)Trigger on Account
===============
Q)When we create an account then automatically 5 or more  contacts are created with that account name.

trigger accountTestTrggr2 on Account (after insert,after update,after undelete) {
List<Account> acc=[select BillingCountry from Account];
List<Contact> con=new List<Contact>(); 
List<Case> lstcase=new List<Case>();
if(Trigger.isInsert){
for(Account a: Trigger.new){
  for(Integer i=1;i<=5;i++){
    Contact con1=new Contact(accountid=a.id,lastname=a.Name+'.'+i,MailingCountry=a.BillingCountry);
      con.add(con1);
    
  }
  }
if(con.size()>0){
     insert con;
   
}

 if(trigger.isUndelete){
for(Account actobj:trigger.new){
Case csobj=new  Case();
csobj.Accountid=actobj.id;
csobj.Status='New';
csobj.origin='Email';
csobj.Description='An Account :'+actobj.Name+' has been created from Recyclebin';
lstcase.add(csobj);
}
if(lstcase!=null && lstcase.size()>0){
insert lstcase;
}
 }
}







Introduction to Force.com

Introduction to Force.com

This excerpt is from the book, Development with the Force.com Platform: Building Business Applications in the Cloud', authored by Jason Ouellette, Pearson/Addison-Wesley Professional, ISBN 0321767357, published July 2011." Jason also has given an one-hour webcast on Force.com platform.

This chapter introduces the concepts, terminology, and technology components of the Force.com platform and its context in the broader Platform as a Service (PaaS) landscape. The goal is to provide context for exploring Force.com within a corporate software development organization.

If any of the following sentences describe you, this chapter is intended to help:

You have read about cloud computing or PaaS and want to learn how Force.com compares to other technologies.
You want to get started with Force.com but need to select a suitable first project.
You have a project in mind to build on Force.com and want to learn how you can leverage existing development skills and process.
This chapter consists of three sections:

Force.com in the Cloud Computing Landscape:Learn about PaaS and Force.com's unique features as a PaaS solution.
Inside a Force.com Project:Examine how application development with Force.com differs from other technologies in terms of project selection, technical roles, and tools.
Sample Application:A sample business application is referenced throughout this book to provide a concrete basis for discussing technical problems and their solutions. In this chapter, the sample application's requirements and use cases are outlined, as well as a development plan, mapped to chapters of the book.
Force.com in the Cloud Computing Landscape

Phrases like "cloud computing" and "Platform as a Service" have many meanings put forth by many vendors. This section provides definitions of the terms to serve as a basis for understanding Force.com and comparing it with other products in the market. With this background, you can make the best choice for your projects, whether that is Force.com, another PaaS product, or your own in-house infrastructure.
Platform as a Service (PaaS)

The platform is infrastructure for the development of software applications. The functionality of a platform's infrastructure differs widely across platform vendors, so this section focuses on a handful of the most established vendors. The suffix "as a Service" (aaS) means that the platform exists "in the cloud," accessible to customers via the Internet. Many variations exist on this acronym, including SaaS (Software as a Service), IaaS (Infrastructure as a Service), and so forth.
PaaS is a category within the umbrella of cloud computing. "Cloud computing" is a phrase to describe the movement of computing resources away from physical data centers or servers in a closet in your company and into the network, where they can be provisioned, accessed, and deprovisioned instantly. You plug a lamp into an electrical socket to use the electrons in your region's power grid. Running a diesel generator in your basement is usually not necessary. You trust that the power company is going to provide that service, and you pay the company as you use the service.

Cloud computing as a general concept spans every conceivable configuration of infrastructure, well outside the scope of this book. The potential benefits are reduced complexity and cost versus a traditional approach. The traditional approach is to invest in infrastructure by acquiring new infrastructure assets and staff or redeploying or optimizing existing investments. Cloud computing provides an alternative.

Many companies provide PaaS products. The following subsections introduce the mainstream PaaS products and include brief descriptions of their functionality. Consult the Web sites of each product for further information.

Amazon Web Services

Amazon Web Services refers to a family of cloud computing products. The most relevant to PaaS is Elastic Beanstalk, a platform for running Java applications that provides load balancing, auto-scaling, and health monitoring. The platform is actually built on several other Amazon Web Services products that can be independently configured by advanced users, with the most significant being Elastic Compute Cloud (EC2). EC2 is a general-purpose computing platform, not limited to running Java programs. You can provision virtual instances of Windows or Linux machines at will, loading them with your own custom operating-system image or one prebuilt by Amazon or the community. These instances run until you shut them down, and you are billed for usage of resources such as CPU, disk, and network.
A raw machine with an OS on it is a great start, but to build a business application requires you to install, manage access to, maintain, monitor, patch and upgrade, back up, plan to scale, and generally care and feed in perpetuity an application platform on the EC2 instance. Many of these tasks are still required of Amazon's higher-level Elastic Beanstalk offering. If your organization has the skills to build on .NET, J2EE, LAMP, or other application stacks, plus the OS, database administration, and IT operations experience, Amazon's virtual servers in the cloud could be a strong alternative to running your own servers in-house.

Amazon provides various other products that complement Elastic Beanstalk and EC2. These include Simple Queue Service for publish-and-subscribe-style integration between applications, Simple DB for managing schemaless data, and Simple Storage Service, a content repository.

Microsoft Azure

Azure consists of two products. The first is Windows Azure, an operating system that can utilize Microsoft's data centers for general computation and storage. It is a combination of infrastructure and platform designed to take existing and new .NET-based applications and run them in the cloud, providing similar features for scalability and elasticity as Amazon Web Services. Most Azure applications are developed in C# using Microsoft Visual Studio, although other languages and tools are supported. The second part is SQL Azure, a hosted version of Microsoft SQL Server. The cost of these products is based on resource consumption, defined as a combination of CPU, network bandwidth, storage, and number of transactions.
Google App Engine

App Engine is a platform designed for hosting Web applications. App Engine is like having an unlimited number of servers in the cloud working for you, preconfigured with a distributed data store and Python or Java-based application server. It's much like Amazon's Elastic Beanstalk but focused on providing a higher-level application platform. It lacks the configurable lower-level services like EC2 to provide an escape hatch for developers requiring more control over the infrastructure. App Engine includes tools for managing the data store, monitoring your site and its resource consumption, and debugging and logging.
App Engine is free for a set amount of storage and page views per month. Applications requiring more storage or bandwidth can purchase it by setting a maximum daily dollar amount they're willing to spend, divided into five buckets: CPU time, bandwidth in, bandwidth out, storage, and outbound email.,/p>

Force.com

Force.com is targeted toward corporate application developers and independent software vendors. Unlike the other PaaS offerings, it does not expose developers directly to its own infrastructure. Developers do not provision CPU time, disk, or instances of running operating systems. Instead, Force.com provides a custom application platform centered around the relational database, one resembling an application server stack you might be familiar with from working with .NET, J2EE, or LAMP.
Although it integrates with other technologies using open standards such as SOAP and REST, the programming languages and metadata representations used to build applications are proprietary to Force.com. This is unique among the PaaS products but not unreasonable when examined in depth. Force.com operates at a significantly higher level of abstraction than the other PaaS products, promising dramatically higher productivity to developers in return for their investment and trust in a single-vendor solution.

To extend the reach of Force.com to a larger developer community, Salesforce and VMware provide a product called VMforce. VMforce brings some of the features of the Force.com platform to Java developers. It consists of development tools from the Salesforce community and virtualized computing resources from VMware. With VMforce, you can create hybrid applications that use Force.com for data and services, but are built with Java standard technologies such as Spring. Along the same lines, Salesforce's acquisition of Heroku is expected to extend Force.com features to Ruby developers.

Force.com is free for developers. Production applications are priced primarily by storage used and number of unique users.

Facebook

Facebook is a Web site for connecting with your friends, but it also provides developers with ways to build their own socially aware applications. These applications leverage the Facebook service to create new ways for users to interact while online. The Facebook platform is also accessible to applications not built inside Facebook, exposing the "social graph" (the network of relationships between users) where permitted.
Much of the value of Facebook as a platform stems from its large user base and consistent yet extensible user experience. It is a set of services for adding social context to applications. Unlike Force.com and App Engine, for example, Facebook has no facility to host custom applications.

Force.com as a Platform

Force.com is different from other PaaS solutions in its focus on business applications. Force.com is a part of Salesforce.com, which started as a SaaS Customer Relationship Management (CRM) vendor. But Force.com is not CRM. It provides the infrastructure commonly needed for any business application, customizable for the unique requirements of each business through a combination of code and configuration. This infrastructure is delivered to you as a service on the Internet.
Because you are reading this book, you have probably developed a few business applications in your time. Consider the features you implemented and reimplemented in multiple applications, the unglamorous plumbing, wiring, and foundation work. Some examples are security, user identity, logging, profiling, integration, data storage, transactions, workflow, collaboration, and reporting. This infrastructure is essential to your applications but expensive to develop and maintain. Business application developers do not code their own relational database kernels, windowing systems, or operating systems. This is basic infrastructure, acquired from software vendors or the open-source community and then configured to meet user requirements. What if you could do the same for your application infrastructure? This is the premise of the Force.com.

The following subsections list differentiating architectural features of Force.com with brief descriptions.

Multitenancy

Multitenancy is an abstract concept, an implementation detail of Force.com, but one with tangible benefits for developers. Figure 1-1 shows a conceptual view of multitenancy. Customers access shared infrastructure, with metadata and data stored in the same logical database.
The multitenant architecture of Force.com consists of the following features:

Shared infrastructure: Every customer (or tenant) of Force.com shares the same infrastructure. They are assigned an independent logical environment within the Force.com platform.
At first, some might be uncomfortable with the thought of handing their data to a third-party where it is co-mingled with that of competitors. Salesforce's whitepaper on its multitenant technology includes the technical details of how it works and why your data is safe from loss or spontaneous appearance to unauthorized parties.

NOTE The whitepaper is available at
http://wiki.developerforce.com/index.php/Multi_Tenant_Architecture.
Single version: Only one version of the Force.com platform is in production. The same platform is used to deliver applications of all sizes and shapes, used by 1 to 100,000 users, running everything from dog-grooming businesses to the Japanese national post office.
Continuous, zero-cost improvements: When Force.com is upgraded to include new features or bug fixes, the upgrade is enabled in every customer's logical environment with zero to minimal effort required.
Salesforce can roll out new releases with confidence because it maintains a single version of its infrastructure and can achieve broad test coverage by leveraging tests, code, and configurations from their production environment. You, the customer, are helping maintain and improve Force.com in a systematic, measurable way as a side effect of simply using it. This deep feedback loop between the Force.com and its users is something impractical to achieve with on-premise software.

Relational Database

The heart of Force.com is the relational database provided as a service. The relational database is the most well-understood and widely used way to store and manage business data. Business applications typically require reporting, transactional integrity, summarization, and structured search, and implementing those on nonrelational data stores requires significant effort. Force.com provides a relational database to each tenant, one that is tightly integrated with every other feature of the platform. There are no Oracle licenses to purchase, no tablespaces to configure, no JDBC drivers to install, no ORM to wrangle, no DDL to write, no queries to optimize, and no replication and backup strategies to implement. Force.com takes care of all these tasks.
Application Services

Force.com provides many of the common services needed for modern business application development. These are the services you might have built or integrated repeatedly in your past development projects. They include logging, transaction processing, validation, workflow, email, integration, testing, reporting, and user interface.
These services are highly customizable with and without writing code. Although each service can be valued as an individual unit of functionality, their unification offers tremendous value. All the features of Force.com are designed, built, and maintained by a single responsible party, Salesforce. Salesforce provides documentation for these features as well as support staff on-call, training and certification classes, and accountability to its customers for keeping things running smoothly. This is in contrast to many software projects that end up as a patchwork of open-source, best-of-breed tools and libraries glued together by you, the developer, asked to do more with fewer people, shorter timelines, and cheaper, often unsupported tools.

Declarative Metadata

Almost every customization configured or coded within Force.com is readily available as simple XML with a documented schema. At any point in time, you can ask Force.com for this metadata via a set of Web services. The metadata can be used to configure an identical environment or managed with your corporate standard source control system. It is also helpful for troubleshooting, allowing you to visually compare the state of two environments. Although a few features of Force.com are not available in this declarative metadata form, Salesforce's stated product direction is to provide full coverage.
Programming Language

Force.com has its own programming language, called Apex. It allows developers to script interactions with other platform features, including the user interface. Its syntax is a blend of Java and database stored procedure languages like T/SQL and can be written using a Web browser or a plug-in to the Eclipse IDE.
Other platforms take a different approach. Google's App Engine simultaneously restricts and extends existing languages such as Python so that they play nicely in a PaaS sandbox. This offers obvious benefits, such as leveraging the development community, ease of migration, and skills preservation. One way to understand Apex is as a domain-specific language. Force.com is not a general-purpose computing platform to run any Java or C# program you want to run. Apex is kept intentionally minimalistic, designed with only the needs of Force.com developers in mind, built within the controlled environment of Salesforce R&D. Although it won't solve every programming problem, Apex's specialized nature leads to some advantages in learning curve, code conciseness, ease of refactoring, and ongoing maintenance costs.

Force.com Services

Force.com can be divided into four major services: database, business logic, user interface, and integration. Technically, many more services are provided by Force.com, but these are the high-level categories that are most relevant to new Force.com developers.
Database

Force.com is built around a relational database. It allows the definition of custom tables containing up to 800 fields each. Fields contain strongly typed data using any of the standard relational database data types, plus rich types such as currency values, picklists, formatted text, and phone numbers. Fields can contain validation rules to ensure data is clean before being committed, and formulas to derive values, like cells in a spreadsheet. Field history tracking provides an audit log of changes to chosen fields.
Custom tables can be related to each other, allowing the definition of complex data schemas. Tables, rows, and columns can be configured with security constraints. Data and metadata is protected against accidental deletion through a "recycling bin" metaphor. The database schema is often modifiable instantly, without manual migration. Data is imported from files or other sources with free tools, and APIs are provided for custom data-loading solutions.

Data is queried via a SQL-like language called SOQL (Salesforce Object Query Language). Full-text search is available through SOSL (Salesforce Object Search Language).

Business Logic

Apex is the language used to implement business logic on Force.com. It allows code to be structured into classes and interfaces, and it supports object-oriented behaviors. It has strongly typed collection objects and arrays modeled after Java.
Data binding is a first-class concept in Apex, with the database schema automatically imported as language constructs. Data manipulation statements, trigger semantics, batch processing, and transaction boundaries are also part of the language.

The philosophy of test-driven development is hard-wired into the Force.com platform. Methods are annotated as tests and run from a provided test harness or test API calls. Test methods are automatically instrumented by Force.com and output timing information for performance tuning. Force.com prevents code from being deployed into production that does not have adequate unit test coverage.

User Interface

Force.com provides two approaches for the development of user interfaces: Page Layouts and Visualforce. Page Layouts are inferred from the data model, including validation rules, and then customized using a WYSIWYG editor. Page Layouts feature the standard Salesforce look-and-feel. For many applications, Page Layouts can deliver some or all of the user interface with no development effort.
Visualforce allows developers to build custom user interfaces. It consists of a series of XML markup tags called components with their own namespace. As with JSP, ASP.NET, Velocity, and other template processing technologies, the components serve as containers to structure data returned by the Controller, a class written in Apex. To the user, the resulting Web pages might look nothing like Salesforce, or adopt its standard look-and-feel. Visualforce components can express the many types and styles of UIs, including basic entry forms, lists, multistep wizards, Ajax, Adobe Flex, mobile applications, and content management systems. Developers can create their own components to reuse across applications.

User interfaces in Visualforce are public, private, or some blend of the two. Private user interfaces require a user to log in before gaining access. Public user interfaces, called Sites, can be made available to anonymous users on the Internet.

Integration

In the world of integration, more options are usually better, and standards support is essential. Force.com supports a wide array of integration technologies, almost all of them based on industry-standard protocols and message formats. You can integrate other technologies with Force.com using an approach of configuration plus code. Here are some examples:
Apex Web Services allows control of data, metadata, and process from any platform supporting SOAP over HTTP, including JavaScript. This makes writing composite applications that combine Force.com with technology from other vendors in many interesting and powerful ways possible. Force.com's Web services API has evolved over many years, spanning more than 20 versions with full backward compatibility.
The Force.com database is accessible via Representational State Transfer (REST) calls. This integration method is much lighter weight than Web Services, allowing Web applications to query and modify data in Force.com with simple calls accessible to any development language.
Business logic developed in Apex can be exposed as a Web service, accessible with or without a Force.com user identity. Force.com generates the WSDL from your Apex code. Additionally, Force.com converts WSDL to Apex bindings to allow access to external Web services from within the platform.
You can create virtual email inboxes on Force.com and write code to process the incoming email. Sending email from Force.com is also supported.
Force.com provides an API for making HTTP requests, including support for client-side certificates, SSL, proxies, and HTTP authentication. With this, you can integrate with Web-based resources, everything from static Web pages to REST services returning JSON.
Salesforce-to-Salesforce (S2S) is a publish-and-subscribe model of data sharing between multiple Force.com environments. If the company you need to integrate with already uses Force.com and the data is supported by S2S, integration becomes a relatively simple configuration exercise. There is no code or message formats to maintain. Your data is transported within the Force.com environment from one tenant to another.
If your requirements dictate a higher-level approach to integration, software vendors like IBM's Cast Iron Systems and Informatica offer adapters to Force.com to read and write data and orchestrate complex transactions spanning disparate systems.

Inside a Force.com Project

This section discusses what makes a Force.com project different from a typical corporate in-house software development effort, starting with project selection. Learn some tips for selecting a project in Force.com's sweet spot. Then examine how traditional technical roles translate to development activities in a Force.com project and how technologies within Force.com impact your product development lifecycle. Lastly, get acquainted with the tools and resources available to make your project a success.
Project Selection

Some projects are better suited to implementation on Force.com than others. Running into natural limits of the PaaS approach or battling against the abstraction provided by the platform is possible. Always strive to pursue projects that play into Force.com strengths. No absolute rules exist for determining this, but projects with the following characteristics tend to work well with Force.com:
The project is data-centered, requiring the storage and retrieval of structured data.

Structured data is the most important point. Implementing a YouTube-like application on Force.com is not the best idea, because it primarily works with unstructured data in the form of video streams. Force.com supports binary data, so a video-sharing Web site is certainly possible to build. But handling large amounts of binary data is not a focus or core competency of Force.com. A hotel reservation system is an example of a more natural fit.
The user interface is composed primarily of wizards, grids, forms, and reports.

Force.com does not restrict you to these user interface patterns. You can implement any type of user interface, including "rich" clients that run using Flash in the browser, and even full desktop applications that integrate with Force.com via its Apex Web Services API. But to capture the most benefit from the platform, stick with structured, data-driven user interfaces that use standard Web technologies such as HTML, CSS, and JavaScript.
The underlying business processes involve email, spreadsheets, threaded discussions, and hierarchies of people who participate in a distributed, asynchronous workflow.

Standard Force.com features such as Chatter, workflow, approvals, and email services add a lot of value to these applications. They can be configured by business analysts or controlled in-depth by developers.
The rules around data sharing and security are fine-grained and based on organizational roles and user identity .

User identity management and security are deep subjects and typically require high effort to implement in a custom system. With Force.com, they are standard, highly configurable components that you can leverage without coding. You can then spend more time thinking through the "who can see what" scenarios rather than coding the infrastructure to make them possible.
The project requires integration with other systems.

Force.com is built from the ground up to interoperate with other systems at all its layers: data, business logic, and user interface. The infrastructure is taken care of, so you can focus on the integration design. Exchange a million rows of data between your SQL Server database and Force.com. Call your Apex services from a legacy J2EE application or vice versa. Add an event to a Google calendar from within your Visualforce user interface. These scenarios and more are fully supported by the platform.
The project manipulates data incrementally, driven by user actions rather than a calendar.

Force.com is a shared resource. Simultaneously, other customers of varying sizes are using the same infrastructure. This requires Force.com to carefully monitor and fairly distribute the computing resources so that all customers can accomplish their goals with a high quality of service. If one customer's application on Force.com was allowed to consume a disproportionate share of resources, other customers' applications would suffer resource starvation. The limitations in place, called governors, prevent too much memory, CPU, disk, or network bandwidth from being concentrated in the hands of any one customer. The platform strongly enforces these governor limits, so the best Force.com applications involve computing tasks that can be split into small units of work.
The data volume is limited, below a few million records per table.

Data volume is important to think about with any system: How large is my data going to grow and at what rate? Force.com consists of a logical single transactional database. No analytical data store exists. Applications that require access to large volumes of data, such as data warehousing and analytics, cannot be built on Force.com. Other software vendors such as GoodData provide solutions in this area, but all involve copying data from Force.com to their own products.
Force.com is not an all-or-nothing proposition. If your project does not fit within these guidelines, you might still want to explore Force.com but in conjunction with other PaaS solutions such as Amazon's EC2. Thanks to Force.com's integration capabilities, EC2 and Force.com can be used together as a composite solution, EC2 augmenting Force.com where general-purpose computing is needed. VMforce takes a similar augmentation approach to give Java developers a streamlined way to extend the platform without the hassles of maintaining their own hardware, or even managing their own EC2-based environments.

Team Selection

The best people to staff on Force.com projects might already work at your company. Projects do not require brand-new teams staffed with Force.com experts. With the majority of the platform based in mature technology such as relational databases and Web development, adapting existing teams can be a straightforward task.
Here are some examples of traditional software development roles and how they can contribute to a Force.com project:

Business Analyst

Substantial Force.com applications can be built entirely by configuration, no computer science background or coding skills required. Salesforce refers to this as "clicks, not code." Business analysts who are proficient with Microsoft Excel and its macro language, or small-scale databases like Microsoft Access and FileMaker Pro, can get hands-on with the Force.com data model, validation rules, workflows, approval rules, and page layouts.
Data Modeler

A data model forms the core of a Force.com application. Data modelers can use their existing Entity-Relationship tools and techniques to design the data layer, with some deltas to account for Force.com-specific idiosyncrasies. Rather than scripts of DDL statements, their work output is Force.com's metadata XML or manual configuration of the data objects. Data modelers can also design reports and report types, which define data domains available to business users to build their own reports.
Database Administrator

Many traditional DBA tasks are obsolete in Force.com because there is no physical database to build, monitor, and tune. But a DBA still has plenty of work to do in planning and implementing the Force.com object model. There are objects to define or permissions to configure, and the challenges of data transformation and migration are still as relevant in Force.com as in any database-backed system.
Database Developer

The design of Force.com's programming language, Apex, has clearly been inspired by stored procedure languages like T-SQL and PL/SQL. Existing database developers can adapt their skills to writing Apex code, particularly when it requires detailed work on the data like triggers.
Object-Oriented Analysis and Design Specialist

Force.com includes an object-oriented language, and persistent data is represented as objects. With all of these objects floating around, people with skills in traditional techniques like Unified Modeling Language (UML) are valuable to have on your project team. Larger applications benefit from a well-designed object model, and as in any language, designing before writing Apex code can be a real timesaver.
User Interface Designer

Force.com supports modern Web standards for creating usable, flexible, and maintainable UIs. UI designers can help by building screen mock-ups, page layouts, and the static portions of Visualforce pages to serve as templates and assets for developers.
Web Developer

Developers who have built Web applications can quickly learn enough Apex and Visualforce and build similar applications on Force.com, typically with much less effort. Skills in HTML, CSS, JavaScript, or Adobe Flex are needed to build custom Force.com user interfaces.
4GL Developer

Developers proficient in fourth-generation languages such as Java, C#.NET, and PHP usually have no problem picking up Apex code. It has the same core syntax as Java, without the Java-specific libraries and frameworks.
Integration Specialist

Force.com is a producer and consumer of Web services and supports REST as well as any integration strategy based on HTTP. An integration expert can design the interaction between systems, define the remote operations, and implement them using Force.com or a specialized integration product.
Quality Assurance Engineer

Testing is a critical part of any software project, and on Force.com testing is mandatory before code is deployed to production. A QA engineer can write automated unit tests in Apex and test plans for security and integration testing. Standard tools like Selenium can be used to automate UI testing.
Operations Specialist

Although there are no servers or operating systems to manage, larger deployments of Force.com can involve integration with on-premise systems. Single Sign-On (SSO) integration and data migration are two common examples. Operations experts can help in this area, as well as with application deployment and Force.com administration tasks such as user maintenance.
Lifecycle

The software development lifecycle of a Force.com project is much like an on-premise Web application development project, but with less toil. Many moving parts exist in J2EE, .NET, or LAMP projects. Most require a jumble of frameworks to be integrated and configured properly before one line of code relevant to your project is written.
This section describes areas of Force.com functionality designed to streamline the development lifecycle and focus your time on the value-added activities related to your application. Each of these areas has implicit costs and benefits. On the cost side, there is usually a loss of control and flexibility versus technologies with less abstraction. Evaluating these features and judging whether they constitute costs or benefits for your project is up to you.

Integrated Logical Database

Relational databases are still the default choice for business applications, despite the availability of alternatives like NoSQL, XML, and object-oriented databases. The relational model maps well onto business entities, data integrity is easily enforceable, and implementations scale to hold large datasets while providing efficient retrieval, composition, and transactional modification.
For business applications coded in an object-oriented language, accessing relational databases introduces an impedance mismatch. Databases organize data in terms of schemas, tables, and columns. Programs organize data and logic into objects, methods, and fields. Many ways exist to juggle data between the two, none of them ideal. To make matters more complicated, many layers of protocol are needed to transport queries, resultsets, and transactions between the program and the database.

In Force.com, the database tables are called objects. They are somewhat confusingly named because they do not exhibit object-oriented behavior. The name comes from the fact that they are logical entities that act as tables when being defined, loaded with data, queried, updated, and reported on, but are surfaced to programs as typed data structures. No mismatch exists between the way data is represented in code and the way it's represented in the database. Your code remains consistent and concise whether you are working with in-memory instances of your custom-defined Apex classes or objects from the database. This enables compile-time validation of programs, including queries and data manipulation statements, to ensure that they adhere to the database schema. This one seemingly simple feature eliminates a whole category of defects that were previously discovered only through unit tests or in production by unfortunate users.

The logical aspect of the database is also significant. Developers have no direct access to the physical databases running in Salesforce's data centers. The physical data model is a meta-model designed for multitenant applications, with layers of caches and fault tolerance, spanning servers in multiple data centers. When you create an object in Force.com, no corresponding Oracle database table is created. The metadata describing your new table is stored and indexed by a series of physical tables, becoming a unified, tenant-specific vocabulary baked into the platform's higher-level features. The synergy of integrated, metadata-aware functionality makes Force.com more than the sum of its individual features.

Metadata-Derived User Interface

As described previously, the definition of your objects becomes the vocabulary for other features. Nowhere is this more evident than in the standard Force.com user interface, commonly referred to as the "native" UI. This is the style pioneered by the Salesforce Sales and Service Cloud products: lots of tabular displays of data, topped with fat bars of color with icons of dollar signs and telescopes, and a row of tabs for navigation.
It is worth getting to know the capabilities of native UI even if you have reservations about its appearance or usability. To some, it is an artifact of an earlier era of Web applications. To others, it is a clean-cut business application, consistent and safe. Either way, as a developer, you cannot afford to ignore it. The native UI is where many configuration tasks are performed, often for features not yet visible to Eclipse and other tools.

If your project's user interface design is amenable to the native UI, you can build screens almost as fast as users can describe their requirements. Rapid application prototyping is an excellent addition or alternative to static screen mock-ups. Page layouts are descriptions of which fields appear on a page in the native UI. They are automatically created when you define an object and configured with a simple drag-and-drop layout tool.

Simplified Configuration Management

Configuration management is very different from what you might be accustomed to from on-premise development. Setting up a development environment is trivial with Force.com. You can provision a new development environment in a few clicks and deploy your code to it using the familiar Eclipse IDE.
When added to your Eclipse IDE or file system, Force.com code and metadata are ready to be committed to an existing source control system. Custom Ant tasks are available to automate your deployments. Sandboxes can be provisioned for testing against real-world volumes of data and users. They are automatically refreshed from snapshots of production data per your request. Force.com's packaging feature allows you to partition your code into logical units of functionality, making it easier to manage and share with others at your company or in the larger community.

Integrated Unit Testing

The ability to write and execute unit tests is a native part of the Apex language and Force.com development environment. Typically, a test framework is an optional component that you need to integrate into your development and build process. With the facility to test aligned closely with code, writing and executing tests becomes a natural part of the development lifecycle rather than an afterthought.
In fact, unit tests are required by Force.com to deploy code into production. This applies to all Apex code in the system: user interface logic, triggers, and general business logic. To achieve the necessary 75% test coverage often requires as much if not more code than the actual Apex classes.

To make sure you don't code yourself into a corner without test coverage, a great time to write tests is while you code. Many development methodologies advocate test-driven development, and writing tests as you code has benefits well beyond simply meeting the minimum requirements for production deployment in Force.com. For example, a comprehensive library of tests adds guardrails to refactoring and maintenance tasks, steering you away from destabilizing changes.

Integrated Model-View-Controller (MVC) Pattern

The goal of the MVC pattern is maintainable user interface code. It dictates the separation of data, visual elements that represent data and actions to the user, and logic that mediates between the two. If these three areas are allowed to collide and the codebase grows large enough, the cost to fix bugs and add features becomes prohibitive.
Visualforce adopts MVC by design. For example, its view components do not allow the expression of business logic and vice versa. Like other best practices made mandatory by the platform, this can be inconvenient when you just want to do something quick and dirty. But it is there to help. After all, quick-and-dirty demos have an uncanny tendency to morph into production applications.

Integrated Interoperability

Force.com provides Web services support to your applications without code. You can designate an Apex method as a Web service. WSDL is automatically generated to reflect the method signature. Your logic is now accessible to any program that is capable of calling a Web service, given valid credentials for an authorized user in your organization. You can also restrict access by IP address or open up your service to guests.
As in other languages, Apex provides you with a WSDL-to-Apex tool. This tool generates Apex stubs from WSDL, enabling you to integrate with SOAP-enabled business processes existing outside of Force.com. Lower-level Apex libraries are also available for raw HTTP and XML processing.

End of Life

Retiring a production application requires a few clicks from the system administrator. Users can also be quickly removed or repurposed for other applications. Applications can be readily consolidated because they share the same infrastructure. For example, you might keep an old user interface online while a new one is being run in parallel, both writing to the same set of objects. Although these things are possible with other technologies, Force.com removes a sizable chunk of infrastructure complexity, preserving more intellectual bandwidth to devote to tackling the hard problems specific to your business.
Tools and Resources

Force.com has a rich developer ecosystem, including discussion groups for reaching out to the development community on specific subjects, a source-code repository for open-source projects, a Web site called AppExchange where you can browse for free and paid extensions to the platform, services companies to help you plan and implement your larger projects, and Ideas, a site for posting your ideas for enhancing the platform.
The following subsections list some tools and resources that exist to make your Force.com projects successful.

Developer Force

Developer Force is a rich source of information on Force.com. It contains documentation, tutorials, e-books written by Salesforce, a blog, and a wiki with links to many more resources inside and outside of Salesforce.
Developer Discussion Boards

The developer discussion boards are a public discussion forum for the Force.com development community, divided into a dozen separate boards by technology area. Users post their questions and problems, gripes, and kudos. Other users in the community contribute answers and solutions, including Salesforce employees. The boards are a great way to build a reputation as a Force.com expert and keep current on the latest activity around the platform.
Ideas

If you have a suggestion for improving Force.com or any Salesforce product, visit the Ideas site and post it. Other users in the community can vote for it. If your idea is popular enough, it might be added to the next release of Force.com. Incidentally, Ideas is a reusable component of Force.com, so you can build your own customized idea-sharing sites for your company.
Code Share

Code Share is a directory of open-source code contributions from the Force.com community, with links to the source code hosted on Google Code. Salesforce employees have contributed many projects here. Code Share projects include the Facebook Toolkit, a library for integrating with Facebook, and the Toolkit for PayPal X Payments platform, to leverage PayPal's Adaptive Payments API in Force.com applications.
Platform Documentation

Salesforce provides documentation through online, context-sensitive help within the Web user interface, as well as HTML and PDF versions of its reference manuals. You can find all documentation at Developer Force.
AppExchange

AppExchange is a directory of ready-to-install applications developed on Force.com. The applications consist of metadata, such as Visualforce pages and Apex code, deployable into your Force.com environment. Users can rate applications from one to five stars and write reviews. Many free applications are written by Salesforce employees to illustrate new platform features. Commercial applications are also available for trial and purchase. AppExchange is how independent software vendors distribute their Force.com applications to Salesforce customers.
Dreamforce

Salesforce has a series of user conferences every year called Dreamforce. San Francisco hosts the largest Dreamforce venue, with thousands attending to participate in training sessions, booths, product demos, keynote speeches, breakout sessions, executive briefings, and, of course, the parties. Dreamforce is a fun way to stay up to date with the technology.
Systems Integrators

For deployments including significant numbers of users, integration with other enterprise systems, or complex data migrations, consider contracting the services of a systems integrator. You can find systems integrators who have competency with Force.com, Sales Cloud, Service Cloud, and other Salesforce products. They include pure-play cloud consultancies such as Appirio and Model Metrics, as well as traditional players like Accenture and Deloitte.
Technical Support

When you encounter undocumented or incorrect behavior in the system, submit a defect report. If the issue can be described simply, like a cryptic error message, search for it in the discussion groups. In many cases, someone else has already run into the same problem before you, posted about it, and attracted the attention of Salesforce employees. If not, the ability to log and track Force.com platform support cases is available in Force.com's Web user interface.
Sample Application: Services Manager

Every following chapter in this book contributes to the construction of a sample application called Services Manager. Services Manager is designed for businesses that bill for their employees' time. These businesses need accurate accounting of when and where employees are staffed, numbers of hours worked, skills of the employees, project expenses, amounts billed to customers, and so forth. This section describes these features in preparation for later discussions of their design and implementation.
The goal is not to build a fully functional application for operating a professional services business, but to provide a logically related set of working code samples to accompany the technical concepts covered in this book.

Background

Imagine you own a professional services business. The services your company provides could be architecture, graphic design, software, law, or anything with the following characteristics:
High cost, highly skilled employees
Complex projects lasting a week or more
Resources billed out at an hourly rate
High cost of acquiring new customers
Your profit comes from the difference between the billing rate and the internal cost of resources. This is typically small, so your process must be streamlined, repeatable, and scalable. To increase profit, you must hire more resources and win more customer projects.

User Roles

The users of the Services Manager application span many roles in the organization. The roles are covered in the following subsections, with a summary of their responsibilities and how they use Services Manager.
Services Sales Representative

Sales reps work with customers to identify project needs and manage the relationship with the customer. Reps use the Sales Cloud product from Salesforce to manage their sales process. In general, they do not use Services Manager directly, but start the process by winning the contract.
Staffing Coordinator

Staffing coordinators manage and schedule resources for projects. When the opportunity is closed, they are notified via email. They then create a project using Services Manager and staff it by matching the availability and skills of resources against the scheduling and skill requirements of the project.
Project Manager

Project managers are responsible for success of projects on a daily basis. They direct and prioritize project activities. They use Services Manager to manage the detailed weekly schedules of their consultants and monitor the health and progress of their projects.
Consultant

The consultant is engaged directly with the customer and is responsible for the project deliverables. In Service Manager, he or she logs time spent on the project, indicates the completion of project milestones, and submits expenses.
Accounts Receivable

Accounts receivable is responsible for invoicing and collecting customers based on work that has been delivered. At the end of each billing cycle, they use Services Manager to generate invoices for customers.
Services Vice President

The VP is responsible for the services P&L and success of the team. Services Manager provides the VP with reports on utilization and other metrics for assessing the team's overall performance.
Development Plan

The Services Manager sample application is developed incrementally throughout this book, each chapter building on the previous. Every chapter covers a set of technical concepts followed by the relevant Services Manager requirements, design, and implementation. The goal is to expose you to the abstract technology and then make it practical by getting your hands dirty on the sample application.
The following list names the remaining chapters in this book, with brief descriptions of the features of Services Manager to be covered:

Chapter 2, "Database Essentials":Design and create the database and import data.
Chapter 3, "Database Security": Define users, roles, and profiles. Configure sharing rules.
Chapter 4, "Additional Database Features": Define fields for reporting and make a subset of data accessible offline.
Chapter 5, "Business Logic": Build triggers to validate data and unit test them.
Chapter 6, "Advanced Business Logic": Write services to generate email notifications based on user activity.
Chapter 7, "User Interfaces": Construct a custom user interface for tracking the skills of consultants.
Chapter 8, "Advanced User Interfaces": Enhance the skills-tracking user interface with Ajax.
Chapter 9, "Batch Processing": Locate missing timecards using a batch process.
Chapter 10, "Integration": Calculate and transmit corporate performance metrics to a fictional industry benchmarking organization.
Chapter 11, "Advanced Integration": Develop a Java program to update Force.com with information from a human resources database.
Chapter 12, "Additional Platform Features": Build a custom dashboard component to visualize the geographic distribution of consultants on projects.
Chapter 13, "Social Applications": Automate built-in platform collaboration features to help project teams communicate.
Summary

This chapter has introduced you to Force.com, explained how it differs from other PaaS technologies and what infrastructure it's designed to replace, and given guidelines for its use on your projects. Here are a few thoughts to take away from this chapter:
Force.com is a PaaS uniquely designed to make business applications easy to build, maintain, and deliver. It consists of database, business logic, user interface, and integration services, all of them interoperable and interdependent, accessible through configuration or code.
The most suitable applications for implementation on Force.com operate primarily on structured data. Traditional software development roles are still relevant in the Force.com world, particularly Web and client/server developers. Data modeling takes on a new importance with the platform, as data objects are tightly integrated with the rest of the technology stack, and unit testing is mandatory.
Services Manager is the sample application built on throughout this book. It's designed to serve companies in the professional services space, those selling projects to customers and billing them for the time of its skilled employees.

Salesforce Tutorial for certification(Developer 401)


Salesforce Applications

  1. To access Force.com platform visit the URL https://login.salesforce.com and click on the Setup link in the top nav bar.
  2. To access apps, select Create|Apps menu in the left navbar.
  3. To create a new Application, a developer needs to specify App Label, App name, description, custom app logo and a list of tabs. App Label is displayed to users, and App name is the internal name referred in code.
  4. An application is a set of tabs.
  5. Tabs are of three types
    1. Custom object Tab
    2. Web Tab
    3. Visual force Tab
  6. Tabs are used to organize objects and records. Each tab is associated with a unique object. A tab also lets you specify a color and an image.
  7. One of the tabs in the application is a default landing page.
  8. Saved applications appear in the Apps menu on the top left navbar
  9. Salesforce provides a Force.com IDE. This is an eclipse plugin application that provides a development environment for VisualForce and Apex.
  10. In Salesforce code without desired test coverage cannot be deployed. A minimum of 75% test coverage must be achieved before deployment.
  11. Native User Interface refers to the default user interface that Salesforce provides

Force.com's objects, fields and relationships

  1. Objects logically correspond to database tables in a relational database. Fields of an object is similar in concept to column in relational database.
  2. Objects can be standard or custom. Standard are objects are predefined by Salesforce like Accounts, Case, Contact etc. Custom objects are created by developers based upon application requirements.
  3. Custom objects have the following characteristics
    1. Custom objects store information that is unique and important to your organization.
    2. Custom objects are reportable and search-able.
    3. Custom objects have configurable access control features.
  4. Force.com provides undelete functionality on objects. Deleted objects go to a recycle bin with an expiry date of 45 days. An administrator may delete objects from recycle bin.
  5. Fields of type Picklist cannot be made required.
  6. There are three type of page layouts:
    1. Detail
    2. Mini
    3. Console
  7. Objects have following fields that need to be entered by developers -
    • Label
    • Plural Label
    • Object Name
    • Description
    • Record Name
    • Record Type
  8. The field for record name is displayed by default when the object has to be displayed (for example in search results). The record type can be text or auto-number. Auto-number can take values like A-{0001}, A-{0002} etc.
  9. The Object name is used to access the object programmatically. __c is added as a suffix to the custom object names. The label name is used for display of the object.
  10. The standard fields are added automatically. Examples of standard fields are Created By, Owner etc.
  11. Custom Fields are added to an object by developers. In the custom object definition detail screen there is a section of custom fields. Click New to create new custom fields in this area.
  12. Custom Fields have properties like:
    • Data Type
    • Field Label
    • Field Name
    • Required checkbox
    • Description
    • Default Value
  13. Examples of valid field types are
    Field TypeComments
    TextText can be upto 255 characters
    Text AreaText Area can be either 255 characters or 32K characters
    URL
    PicklistCan be single select or mult-select. The developer needs to provide valid values
    Currency
    Checkbox
    Percent
    Number
    The field types are aligned to user interface elements like picklist and checkbox.
  14. Changing the data type of existing custom fields is possible, but doing so may cause data loss.
  15. Fields can be set as unique, required or as external id. A required field is always displayed in the edit page. A field of type external id is a record id from another system. The performance of reports and SOQL is better for fields defined as external ids. Fields of type number, text and email can be set as external id. Each object can have up to three external ids.
  16. A field defined as encrypted is not visible to users. Typical usage of encrypted field is for password. Only users with "View Encrypted Data" can view the encrypted fields. Encrypted fields are editable.
    1. This is a provisioned feature, so you must contact Salesforce to enable it.
    2. Encrypted custom field cannot be unique, an external ID, or have default values.
  17. Objects can have upto 500 custom fields.
  18. When an object is created, a user interface is created automatically for Create, Update, Read and Delete operations.
  19. Fields of two Picklists can be made dependent on each other. As an example consider an application with customers in US and Canada. If there are two picklists - one for country and the other for state. Based upon user's selections of country, the state settings need to get updated. This is implemented by defining controlling and dependent picklists. In the above scenario, country becomes the controlling picklist and state becomes dependent picklist. The controlling and dependent picklists are defined using "Field Dependency" button in "Custom Field and Relationship" section.
  20. Standard picklist can be controlling picklist but not dependent picklist. Maximum number of values allowed in controlling field is 300. A custom multi-select picklist cannot be controlling field in a picklist.
  21. Merge fields are fields that display values based upon formula calculations.
  22. Salesforce supports history tracking on change in values of fields. This can be enabled for up to 20 fields in an object.
  23. Custom objects can be represented using a Metadata XML.
  24. Deleted data and metadata is stored in recycle bin.
  25. Database tuning is managed by Salesforce. How Objects and fields are stored in the database is internal to Salesforce.
  26. Object Relationships

  27. Force.com allows you to create relationship between objects. The "Custom Fields & Relationship" section of objects is used to define relationship between objects.
  28. There are a two types of object relationships that Salesforce supports -
    1. Lookup relationship
    2. Master-detail relationship
    These relationships are used to implement one-to-many relationship. They are created as fields in the child record. As an example in a recruitment application if one applicant can have many interviewFeedbacks, we could create a lookup (or master detail) relationship in the interviewFeedback object pointing to the applicant object.
  29. In Master Detail relationship, if the parent record is deleted, then all its children records are deleted.
  30. Child records in master-detail relationship do not have owners. They inherit ownership from the parent record.
  31. In Master detail relationship, the parent field is required. Also the parent field once specified cannot be changed.
  32. Standard Object cannot be on detail side of Master-Detail relationship.
  33. In the related list section of parent objects, only one field of the child object is displayed by default. This is the field specified as Record Name in the child object. To add more fields, search lookup layout needs to be updated.
  34. Rollup-summary fields are supported in master detail relationship. The parent object can use roll-up summary field type to perform operations of sum, maximum, minimum, count among its children records. These fields are read only fields and are used to calculate values from a set of records.
  35. Many-to-Many relationships are implemented using two master-detail objects. One Junction object is used as the child of the objects between which many-to-many relationship needs to be established.
  36. The table below compares Master Detail and Lookup relationship
    Lookup relationshipMaster Detail relationship
    Is Parent a required fieldNoYes
    Maximum number of relationship in an object252
    Security of parent determines child record's accessNoYes
    Deleting parent record deletes childrenNoYes
    Parent can be a child in another relationshipYesNo
    Roll-up summary in parent supportedNoYes
  37. Self relationship is a lookup relationship to itself. An example usage could be organization chart where an employee's manager is also an employee.
  38. Hierarchy Relationship exists only for User object. In this, developers create a manager field in User object to relate to another object.

Approvals and Workflow in Salesforce

Salesforce provides extensive support for implementation of workflow and approvals.
  1. A queue can hold a predefined set of objects and consists of a set of users. Any of the queue members can pick up tasks assigned to the queue. Users or Queues can be owners of records.
  2. Approval processes

    Salesforce supports wizard based easy to configure approval process. After an object is selected, the wizard guides the user through a step-by-step setup. Approval process is triggered when a user clicks on the "Submit for approval" button.
  3. The approval process consists of the following steps -
    1. Process definition
    2. Initial submission actions
    3. Step definitions
    4. Final Rejection actions
    5. Final Approval actions
    6. Final Recall actions
  4. The Process Definition step consists of the following sub-steps:
    1. Provide the name of process
    2. Specify entry criteria for records
    3. Specify who is going to approve
    4. Specify email template
    5. Fields to be displayed in the approver page
    6. Specify who is going to send approval mail
  5. Workflow rules are like triggers. Action is triggered when a record meets an evaluation criteria. Workflow rules definition does not impact existing records. Workflow rule gets applied to new record creation or edits.
  6. Workflow rule consists of three steps
    1. Select the object
    2. Specify evaluation criteria (when should the workflow rule be executed, example for new records are created)
    3. Define rule criteria (example when status of job applicant is approved)
  7. Workflow actions can include sending an email, setting values to fields, sending an external message or creating a task.
  8. There are two differences between Workflows and Approval process
    WorkflowApproval process
    They are activated when a record is saved.approval process are triggered by explicitly clicking the "Submit for Approval" button.
    Workflow consists of single step and single actionApproval process consists of multiple steps. Also different action is taken based upon whether the record is approved or rejected.
    Workflows can be modified or deleted.In approvals some attributes cannot be modified. Processes must be deactivated before approvals can be deleted.
  9. Time-based workflow allows action to be triggered after a delay. As an example we could implement following business logic using time-based workflow: In a recruitment application if for no high priority position no candidates are assigned in a week, then send a mail to Recruitment Manager.
  10. Time-based workflow cannot be executed when evaluation is set to "Every time a record is created or updated".
  11. Approval processes can be single or multiselect process. Multi-select processes require end user authorization for record promotion.
  12. Approval process is unique for object type.
  13. Parallel approval process allows specifying (upto 25) multiple approvers simultaneously. The approver setting could be set to unanimous or first action. In unanimous parallel approval process, all approvers must approve a request, before it is considered as approved.
  14. Possible actions of workflow and approval process are -
    1. Creating a task
    2. Sending a message to external system (outbound message)
    3. Updating a field value
    4. Sending an email
    5. Locking a record
  15. Outbound message helps keeping salesforce coordinated with other applications.
  16. Dynamic approval process is used to route approval requests to users listed in lookup fields on the record requiring approval. In this, approver names are defined dynamically from an object.
  17. Process Visualizer provides Read only visual of an Approval process. It can be accessed by clicking on “View Diagram” button.

    Salesforce Business Logic

      Business logic is a set of rules and calculations that handle information exchange between User Interface and Database. Declarative Business Logic includes: Queues, Workflows, Validation and Assignment Rules, Rollup summary fields, Cross Object fields.Programmatic Business Logic includes Apex, Visualforce Controllers, Web Services API. Automated processes are:
      • Validation Rules
      • Assignment Rules
      • Auto Response Rules
      • Workflow Rules
      • Escalation Rules
      Queues are used to manage a shared workload more effectively.
    1. Validation rules can be attached to fields. They are executed when a record is created or updated.
    2. When defining a validation rule, an error condition and error message are defined. If evaluation of error condition results in true value, record is not saved, and the error message is generated.
    3. Some fields are of type Formula. They are derived from other fields. Validation rules and formula follow the same expression language.
    4. A set of functions used in Formulae are included below.
      FormulaeDescription
      TODAY()Returns todays date
      IF(expr,x,y)if expr is evaluated to true, x is returned, else y is returned
      TEXT(field)Returns the text value of a picklist
      ISPICKVAL(field,value)Checks whether value of field matches the input parameter. Returns true if there is a match
      ISBLANK(field)Returns true if field is blank
      AND(expr1,expr2)Performs a logical AND
      OR(expr1,expr2)Performs a logical OR
      HYPERLINK(url,text)Creates a link to the specified url
      ISCHANGED(field)Checks id the field's value has changed
      PRIORVALUE(field)Returns the previous value of field
      ISNEW()Returns true if a new record is being created.
      INUMBER()Returns true if the field is a number
      IMAGE()Used to display an image
      REGEX()Compares a text field to a regular expression and returns true if there is a match
      VLOOKUP()In an object consisting of key value pair, VLOOKUP returns value for a key
      A few things on these functions:
      • Case(), If() and IsNumber() are available for all features like approval, workflow, validation and formula.
      • Image() is only for Formula fields.
      • Vlookup() is for Validation rules.
      • IsChanged() and PriorValue() are for workflow, only when “everytime a record is created or updated”.
    5. Methods are used in Formulae fields, Validation rules, Workflow rules, Field updates, Default values and Approval process. Some of these methods are only available in certain areas. CASE, IF, ISNUMBER are available in all places. IMAGE is available only in formulae fields. VLOOKUP is available only in validation rules.
    6. Cross-object formula span two or more objects by referencing merge fields.
    7. Difference between Roll Up and Cross Object Fields:
      1. In cross object formulas, we navigate from child object to parent or grand parent object(up to 5 levels). Field is displayed on child object. While in Roll Up Summary Fields, we navigate from Parent to Child object.
      2. Formula fields do not store the value on the record but Roll Up Summary fields stores the value and changes can be seen on parent.
    8. Limitations of Cross Object Fields:-
      1. You can’t reference cross obect formula in roll up summary field.
      2. You cannot reference merge field for objects related to activities.
      3. You cannot reference record owner merge field for any object.
    9. Debugging Tools

    10. View Setup Audit Trail is used to view list of configuration changes. It is available in Security Controls menu in the Setup area. Examples of audit trail are creation of object, adding a new field, changing field type or setting up a new approval process. By default 20 last configuration changes are displayed. Changes made in last 180 days can be exported into a csv file. It can be configured by admin or developer.
    11. Field history tracking can be enabled at object level at the time of creation of objects. Up to 20 fields can be tracked for one object. As an example, any changes in field values are stored as part of Field history tracking. During Field history tracking, Time of change, user who made the change, prior value and new values are stored. For data types Multiselect Picklist and text area (long), previous and new values are not saved.In the Custom Fields and Relationship area of Object configuration, "Set History Tracking", is used to enable field level tracking. Review History related list can then be added to page layout to view changes to fields.
    12. Force.com platform provides three main mechanisms for debugging errors. These are also known as Auditing tools:-
      1. Field history allows developers to track changes to field values of up to 20 fields for any object.
      2. Debug Logs is a persistent store in which logs are stored for transactions performed by up to 20 users.
      3. System Logs allows developers to run apex commands and view the logs
      4. Setup Audit trail allows developers to view all configuration changes (example creation of object, changing field type, creating a workflow etc.) made in last 180 days.
    13. Setup Audit Trail of Salesforce is used to track configuration changes made. Example of configuration changes are date of change, description of the change, user who made the change. Twenty most recent changes are displayed in the audit trail. Last 180 days changes can be exported into a csv file. View Setup Audit Trail feature is available via the Security Control menu.
    14. There is a link to System Log at the upper right corner of the page. System Log allows developers to enter Apex code and see the results of running this code. System Log display information about workflow rules, validation rules, debugging information and resource utilization.
    15. To control quantum of logging, system log takes two parameters Log category and Log level. Log categories can take the following values -
      • None
      • Database
      • Workflow
      • Validation
      • Callout
      • Apex code
      • Apex profiling
      Log level indicates level of detail in the message. It takes the following values
      • None
      • Error
      • Warn
      • Info
      • Debug
      • Fine
      • Finer
      • Finest
    16. Debug log is an organization-wide persistent log. It can store debug log for transactions performed by specific users. Logs for up to 20 users can be persisted. Debug Log is available via the Monitoring menu.
    17. Salesforce supports history tracking on change in values of fields. This can be enabled for up to 20 fields in an object. In Custom Fields and Relationship, set history tracking is enabled for a set of fields. Review history can be added to page layout. Information stored includes - changes to field values, time of change, user who changed the field. Old and new values of fields are not stored for multi-select picklist and long text area.

Salesforce DataLoader

  1. Every object has a standard field called id. There is no need to define an explicit primary key in custom objects. The standard id field can be used as primary key.
  2. The id is alphanumeric. id can be either 18 digit case-insensitive or 15 digit case-sensitive.
  3. The first three characters of the id identify the object. Ids can be identified in three ways -
    • From the URL when a record is displayed in Salesforce
    • From reports
    • Through the web services api. Data Loader uses web services api to display the ids.
  4. The id displayed by a report is the 15-digit case-sensitive id. The ids returned by web services api are 18-digit id. For updates web service accept both the 15-digit and 18-digit ids.
  5. 15-digit id can be converted to 18-digit id and vice-versa.
  6. There are two types of Data Loader logs:
    • sd1.log
    • sd1_out.log
  7. When loading data into a salesforce application dependencies between objects determine the order in which objects are loaded. If there is a one-to-many relationship between A and B, the data for A should be loaded before the data for B.
  8. Data Management is an ongoing process to keep data in your application up-to-date, accurate and clean whereas Data Migration is one time task.
  9. External ids option can be specified on custom fields for fields of type text, number or email. This creates custom index in database. A maximum of three fields can be set as external ids. Specifying a field as external ids, leads to improved reporting and SOQL performance. External ids prevent duplicate entries when exporting data. Both upsert and external ids are used for migration and integration of data.
  10. If "Modifiable System Field" configuration is enabled, then system fields (like creation date) can be set to any value during initial data load. These values can however not be updated after the initial upload. These fields are accessible through the API. These are backward compatible with all SOAP based APIs available for all custom objects. These are Read only fields.
  11. Salesforce determines an operation Upsert. Upsert stands for update + insert. When an upsert is performed, if a record exists it gets updated. If the record does not exist, it gets inserted. This is useful in large data uploads, and if the connectivity is not stable. Matching of record can be performed on the basis of Salesforce id or External id. When performing an upsert, only single external id field is used.
  12. Import wizard are available via the standard Salesforce application using easy to use interface and do not require programming. Import wizard can be used to load up to 50,000 records. Import wizard can be used for de-duplication of data. Import wizard can be used to import accounts, contacts, leads, solutions and custom objects.
  13. Web Services API based tools can load more than 50,000 records and can support all object types. It also allows developers to schedule regular data loads. These support nightly feeds. APIs can delete multiple objects at the same time.
  14. Data Loader is an API based product by Salesforce. It can be run from command-line. It can generate and import from csv (Comma Separated values) files. It supports custom relations imports using upserts. It also support loading from JDBC.
  15. Data Loader can be installed on a desktop from the Salesforce Data Management menu. Operations supported by data loader are -
    • Extract
    • Upsert
    • Insert
    • Delete
    • Update
  16. Command-line version of data-loader supports regular scheduling of loads.
  17. Mass Transfer Tool is used to transfer multiple objects data from one user to another. User should have the following permissions:
    • Transfer record permission
    • Edit permissions
    The tool can be used to change the ownership of the record.

Force.com development platform

  1. Salesforce provides two type of licenses
    1. Salesforce: full access to CRM standards, Force.com custom and application exchange apps
    2. Salesforce platform:. Salesforce platform license allows access to custom apps, it does not allow access to online CRM product.
    Feature licenses can be purchased for additional features such as Marketing User, offline user, Apex mobile user etc. CRM access means access to Standard objects like Cases, Campaigns, Opportunities etc. Platform access means access to Custom and Standard objects.
  2. Force.com platform uses the standard Model View Controller design pattern. The MVC pattern is implemented as below in Force.com platform.
    PatternForce.com implementation
    ModelObject (custom or standard)
    ViewVisualForce pages
    ControllerLogic written in Apex that controls navigation
  3. The Create menu is used to provide the declarative framework of Force.com platform. The Develop menu is used to provide the programmable framework.
  4. Page Builder is used to generate user interface for CRUD (Create, Read, Update, Delete) operations of objects. This user interface is created automatically by Salesforce and can be used to create reasonably complex applications withot writing VisualForce or Apex code.
  5. Salesforce allows data types of existing fields to be changed, however this may lead to loss of data.
  6. When you add a custom object tab, all the following will be accessible with the object:
    • Recent items
    • Sidebar search
    • Added to new link/ Create new object drop down
  7. To make a field required, there are a few different ways.
    • Check the box for required on Object Definition
    • Create a Validation Rule
    • Specify that the field is required in the Page layout
  8. Page Layout supports a drag-and-drop interface to develop screens. It allows addition of space and sections, and moving of fields across the screen. It supports making a field read-only or required.
  9. There are two type of activities:
    • Task: It is related to a record , assigning a task
    • Events: Any calendaring event, meeting etc
  10. A deleted record is stored in recycle bin with an expiry date. Deleted records can be recovered for upto 45 days.
  11. SOQL stands for Salesforce Object Query Language. SOQL is used for performing queryies on objects.
  12. SOSL stands for Salesforce Object Search Language. SOSL is used for performing full text search.
  13. S-controls were used to upload contents such as java applets or active X controls for use in dynamic custom links or web tabs. These have been superseded by visualforce pages. S-controls provide client side programming.
  14. Salesforce provides sandboxes that may be used for development and testing. Full Copy Sandbox allows copies of metadata/configuration along with all the application data to be copied from production to a sandbox environment. The sandbox can then be used for testing and simulating reported problems. Record ids in production and full copy sandbox are also same.Configuration only sandbox copies all your production organisation’s reports, dashboards but exclude all your organisation’s standard and custom object records, documents and attachments. There is a size limit of 500MB(250,000 records)
    Developer sandbox is a special configuration sandbox only for single developer. It also allows copying of metadata and configuration, but not copying of application data. Changes from the active development can be isolated until they are ready to be shared. Size limit is 10MB(5000 records)
    Developer edition license does not allow copying of configuration from production developer environment.
  15. Territory Management: It is used to define more than 1 role hierarchy.

Reports and Dashboards in Salesforce

Salesforce provides powerful reporting and generation tools on the data stored in the objects.
  1. In reports data displayed is as per running user's security access. Reports can be run on both standard and custom objects. Reports are stored in folders. Users with access to these folders can run the reports.
  2. Reports data is always generated in real time. When a report is saved, reports configuration parameters are stored - but the generated data is not stored.
  3. There are four type of reports
    1. Tabular report. This is the most basic report. It displays just the row of records in a table like format with grand total. Tabular reports cannot be used for generating dashboards.
    2. Summary report. This is the most commonly type of report. It allows grouping of rows of data. It supports sorting and displaying subtotals. For example in a recruiting app, a summary report could be used to display open positions classified by department name.
    3. Matrix report. This is the most complex report format. Matrix report summarize information in a grid format. Matrix reports allows records to be grouped by both columns and rows.
    4. Joined report:A joined report can contain data from multiple standard or custom report types. You can add report types to a joined report if they have relationships with the same object or objects. For example, if you have a joined report that contains the Opportunities report type, you can add the Cases report type as well because both have a relationship with the Accounts object.
    Summary and Matrix reports can be used to generate dashboards.
  4. Reports provide two options of exporting data into Excel.
    1. Printable View - Export report with formatting into Excel
    2. Export Details - Export raw data
  5. Reports present in public folders can be emailed to SalesForce users.
  6. Report display upto 2000 rows of data. Larger reports can be emailed to Excel.
  7. Generation of reports requires following steps.
    1. Selection of object
    2. Selection of report type
    3. Select type of information to be displayed (example count, average)
    4. For summary and matrix reports, specify how fields should be grouped
    5. Select columns on the report
    6. Select column order on the report
    7. Specify filtering criteria which should be used to select records
  8. Custom reports let the developers define which all fields should be available in a report. Custom report allows user to change field names. Custom reports allow developers to select related fields (upto four levels). The custom reports also allow developers to add sections to group fields. Once a custom report is created it is available in reports tab and user may create reports from it.
  9. Object relationships that are supported by Custom Report Types are -
    1. Include all records that have children
    2. Include all records that may or may not have children
    As an example consider a recruiting application with two custom objects Position and InterviewFeedback. Also assume that InterviewFeedback is the child of Position object. The first option above will display only those Position objects that have at least one InterviewFeedback as their child. The second option will display all Positions. It is not possible to display Positions that do not have any InterviewFeedback using Salesforce's reporting mechanism.
  10. There are three steps in creating custom reports -
    1. Select an object, folder and report label.
    2. Select related objects that need to be included.
    3. Select fields available for report using a drag-and-drop layout editor.
  11. Custom report types are available via the menu option Create-->Report Types
  12. Analytical snapshot allows reports run at scheduled time to be stored as objects. Analytical snapshots are used to perform trend analysis. As an example if we want to view how monthly sales are growing, fields in a report with sales figure can be stored in a custom object every month using Analytical snapshot. Data in this custom object can then be used to perform trend analysis.
  13. Analytical snapshot are available from the Data Management menu option. Source report in Analytical snapshot can be of the type Tabular or Summary.
  14. Setup Analytical reports require a four step process
    1. Select source report
    2. Select custom object
    3. Map source report fields to custom object fields
    4. Schedule the frequency for taking the snapshots
  15. There are two type of Reports
    1. Standard Report type
      • Created when a object is created
      • created when relationships between objects are created
      • Always inner joins
      • Cannot be modified.
    2. Custom Report type
      • Created by Admin or users with “Manager Custom Report types”.
      • Used to streamline the reporting process.
  16. Key concepts on Custom Report Type
    1. Saving a custom report only saves the parameters of the report. The data is always real time.
    2. CRTs are reporting templates that admin or users create to streamline the reporting process.
  17. Dashboard

  18. Dashboards are graphical representation of reports. Dashboards can be generated for summary or matrix reports (and not for tabular reports). Dashboards display data as per last time report was run.
  19. A dashboard can have upto 20 components
  20. There are five type of dashboards
    ChartUsed for comparisons
    TableGood for showing top five, bottom five lists.
    GaugeUsed to show progress towards a goal
    MetricShows a single number
    VisualForce pageused to pull data from other sources
  21. Further there are six type of charts
    1. Vertical column
    2. Horizontal bar
    3. Line
    4. Donut
    5. Funnel
    6. Pie
    Funnel is used to show proportion of values against each other. Pie is used to demonstrate proportion of single value against total. Donut is used to demonstrate proportion of single value against total and also show the total value.
  22. The folder in which dashboards are stored determines which user has access to running the dashboard. The dashboard data is based upon the reports data. When a user views the drill-down report for a dashboard component. running user's access permissions determine what data is displayed on the drilldown report. Hence it is possible that the data in the drill down report does not match the cumulative dashboard data.
  23. Dashboard also support automatic refresh and email. The refresh and email can also be scheduled at intervals - daily, weekly, monthly.
  24. Two things that determine access to dashboards:
    • Dashboard Folder
    • Running User
  25. Limitations of Salesforce reports

  26. Although fairly powerful, Salesforce reports have certain limitations. These are explained below.
    1. Support for trend analysis in Salesforce is fairly limited.
    2. User Interface of Salesforce reports and dashboards is fixed. Salesforce does not support pixel perfect report.
    3. Salesforce reports do not support importing data from other sources
    4. When displaying objects and their children, Salesforce does not support reporting on objects that do not have any children.
    5. If an object has two different related lists, then Salesforce reporting does not support displaying both these related lists together.
  27. To work-around these limitations, Salesforce customers have the following three options.
    1. Reporting as a service: Data resides on Salesforce. New Reports get generated from same data source
    2. BI as a service: Data is moved to a different destination on cloud. Reporting is performed on this new data server.
    3. Datawarehousing as a service: Data is exported to the customers server and reports are generated from the server located at customers location.

Overview of Security in Force.com development platform

  1. Every user in Salesforce has a profile. Profiles are of two types.
    1. Standard profile
    2. Custom profile
    A user's profiles determines access to objects, and fields in objects.
  2. There are six type of standard profiles -
    1. Standard user
    2. System Administrator
    3. Contract Manager
    4. Marketing User
    5. Read Only
    6. Solution Manager
  3. Profiles control-
    1. The objects the user can access
    2. The fields of the object the user can access
    3. The tabs the user can access
    4. The apps the user can access
    5. The page layout that is assigned to the user
    6. The record types available to the user
  4. Standard profiles cannot be deleted. Access permissions to objects (and their fields) of standard profiles cannot be edited. Standard profiles have access to all standard objects. Read-only profile have read-only access to objects. However access to tabs and applications can be configured for standard profiles.
  5. Access permissions of Custom profiles can be edited. Custom Profiles are created by developers by cloning from a standard profile.
  6. For each profile one application has default status.
  7. Record Types are associated with profiles. Record type play two important roles in Salesforce -
    1. They help define values to be shown in picklist for different profiles.
    2. They are used to define a mapping between page layout and profiles. This ensures that different users are displayed different views of the same page, depending upon the layout template selected.
  8. A record is an instance of an object.
  9. Removing a field from page layout does not ensure that security of that field. The field may still be accessible using the API.
  10. Security in Salesforce is defined at multiple levels. These levels are -
    1. Security at object level
    2. Security at field level
    3. Security at record level
      1. Organization-wide defaults
      2. Role-hierarchy
      3. Sharing rules
      4. Manual Sharing
  11. Object level security is given to profile level. Object level security is set up via Manage Users-->Profile section. Access for Read, Create, Edit & Delete can be set at standard and custom objects.
  12. Field-level security is also applied at profile level. The field-level security is available via the "Set Field-level security" button in the field definition page. At field level, for each profile valid settings are Visible and Read-only.When a user logs in the list of objects that are displayed to her is determined by object level security, and list of fields that are displayed to the user is determined by field level security settings of that profile.
  13. The next set of security concepts work at record level. These constraints determine which records should be displayed to the users. The four constraints that determine record level access are - organization-wide defaults, role-hierarchy, sharing rules and manual sharing.
  14. OWD stands for Organization wide defaults. This setting is defined at object level. OWD defined the default record level sharing for objects. All profiles get at least the privileges defined in OWD. OWD takes three different values -
    1. Private (Cant view and edit)
    2. Public Read only (Can view)
    3. Public Read-Write (Can view and edit)
  15. Key concepts about Organization wide default -
    1. To find out what should be set as OWD for an object, first find out which user requires least access to an object. OWD is set based upon this users access requirement.
    2. Most restrictive record access is defined using OWD. Access to additional records is made available through Role hierarchy, Sharing rules, Manual sharing.
    3. We can set OWD settings for both Standard and Custom Objects.
    4. Changing OWD settings can delete Manual Sharing if that sharing is no longer needed.
    5. Public Read/Write is default OWD settings.
  16. Role Hierarchy allows additional users access to records. A hierarchy of roles is defined based upon access requirements at record level. Each user belongs to a unique role. If a role has access to some record, than its parent and ancestors will also have access to this record. Roles can be created using the Manager Users menu. Roles are used to control record access, where as profiles are used to specify access at object and field level.
  17. Public group used in a sharing rule. It is used to give access to folders. It consists of users, roles or "roles and subordinates". The default Public Group is “Entire Organization”. We cannot assign Public Groups to profiles.
  18. Another related concept that Salesforce defines is Public group. Public group consists of users, roles or "roles and subordinates".
  19. Sharing rule is defined using public groups. Record that match certain condition can be assigned to users in public groups using Sharing Rules. Sharing rules functionality is available via the menu Sharing Settings.
  20. Manual Sharing is used to grant one-off access. Manual sharing can be granted by record owner, any one above the owner in role hierarchy and System Administrator. Manual sharing is used to handle exception cases where access to a particular record needs to be given to a specific user. There is a Sharing button on the records page. This is used to provide manual sharing. The Ownership of the record can be transferred to any user who has at least Read permission on the record.
  21. If the Read permission for the object is revoked from the users profile, the user will not be able to see their own record.
  22. Full access to the records means user can View, Edit, Transfer Ownership, Delete and Share the record. Full access is granted to:
    • Record Owner
    • Users above record owner in role hierarchy.
    • Users with “Modify All Data “ permission i.e. Admin
  23. Apex Sharing Reasons can have upto 10 Apex Sharing Reasons. It can only be given for Custom Objects.

Salesforce Sites

  1. User Interface can be private (internal Salesforce users) or public. Public interfaces are provided to anonymous users using Sites - anyone could access a website built on Sites without having a Salesforce login.
  2. If Sites is licensed, the functionality of Sites is available at Develop-->Sites.
  3. A sites user has a unique domain name. One domain name can be used to support multiple websites. Example domain name could be - http://ap1.mydomain.salesforce.com/siteName . The domain name must be unique among all site users and can represent the organization's name.
  4. Creation of sites requires specifying fields like Site label, Site Name, Site contact, Default web address, active site home page, inactive site home page.
  5. Once an organization has registered a domain name with a domain name registrar, it can point the url to sites url.
  6. Site template is a VisualForce page that defines the default look-and-feel of the sites page.
  7. Force.com sites are
    1. Public, unauthenticated websites
    2. Accessed from branded domain names
    3. Build with VF pages
    4. From data and content in a Salesforce application
  8. Creating a Force.com Site requires performing the following steps
    1. Build a Force.com App
    2. Design your web interface in visual force
    3. Create a Force.com site
    4. Activate the Force.com site
  9. Key concepts about Force.com Sites security
    1. Security for your site is controlled through public Access Settings
    2. Access can also be restricted by specifying an IP range.

VisualForce

  1. SalesForce provides two ways to build user interfaces. These are Page Builder and VisualForce. PageBuilder automatically generates pages with default look-and-feel. VisualForce allows developers to define their own user interface.
  2. VisualForce plays the role of JSP or ASP in SalesForce. It is used to develop user interface for SalesForce applications.
  3. Standard tags are included in VisualForce using apex keyword. As an example the top level tag in VisualForce is <apex:page>.Rest of the code is included in <apex:page>. Custom tags use tags use the prefix c:.
  4. The syntax to access fields in VisualForce is {!object.Field}. The expression in between {!} is evaluated. $User gives the details of the user that is logged in. {!$User.FirstName} displays the first name of the logged in user.
  5. A VisualForce page contains HTML, VisualForce components, JavaScript, Flash and text. All elements need to be well-formed. Visual Force gets converted into HTML at the server.
  6. VisualForce can be used to support other devices like phones, PDAs.
  7. <apex:inputfield value="{!account.name}"/> generates an input element. Based upon the data type of account,name field, appropriate user interface element is displayed (such as text box, pick list). This is an example of data binding. The value of the name field is displayed in the user interface, and changes are saved back to the object.
  8. <apex:form> is used to display a form. Other VisualForce display elements like text box, checkbox are included in a form.
  9. <apex:detail/> is used to print the details page for an object. If the attribute "relatedlist" is set to false, then related lists are not displayed. Specific related lists can be added using the VisualForce component <apex:relatedlist>
  10. VisualForce supports development mode. Development mode can be enabled using Setup|My Personal Information}Personal Information. In development mode, VisualForce provides two main features.
    1. Split screen development: In this the browser window is divided into two parts. The bottom part is used to show VisualForce code. Changes can be saved and resulting page is displayed on the same browser window.
    2. Creation of new pages by just typing the URL www.servername.com/apex/PageName where servername is the SalesForce server that is allocated to you.
  11. Page layouts support one or two columns. VisualForce can support more than two columns.
  12. Previous version of VisualForce is S-controls. It is now being phased out. Visual force two advantages over S-control
    1. Visual force having much better performance as compared to S - control.
    2. Visual force is a tag Markup language and S - controls are a javascript procedural code language.
  13. VisualForce components and pages have version numbers. SalesForce stores the version numbers along with pages. All older versions are supported.
  14. VisualForce elements take attributes similar to XML format. As an example in the statement below, sidebars and top headers are not displayed.
    <apex:page showHeader="false">
    </apex:page> 

    <apex:page> also takes an attribute renderAs as input which supports pdf generation.
  15. Record's id is sent via request parameter, and made available to the page. In the above example the id identifies the account for which name has to be displayed.
  16. VisualForce consists of three type of elements
    1. VisualForce pages: These are used to define the user interface. VisualForce pages support multiple devices
    2. VisualForce components: Standard prebuilt or custom user interface components available through a tag library
    3. VisualForce controllers:
  17. There are three type of controllers -
    Standard Controller
    The standard controllers provide access to standard Salesforce.com behavior.<:apex:page standardController="Account"> They are available for all API entities/objects, such as Account, Contact, Opportunity etc as well as custom objects. They Provide access to standard Salesforce data and behavior - Standard object record data and Standard actions like save, edit , delete.
    Custom Controller
    Custom Controllers is used for custom behavior or non-standard data-sets.<:apex:page controller="MyAccount"> They can be used to create wizards or leverage call outs.
    Controller Extensions
    Controller Extensions extend the behavior of standard controllers.<:apex:page standardController="Contact" extensions="ClassA, ClassB"> They are used to add custom behaviour or additional data to controllers




  18. Static resources are accessible through global variables $Resource. It can be used to access CSS stylesheets, images, flash movies and JavaScript libraries.




  19. Error messages are displayed in pageMessages component and can be displayed by the statement <apex:pageMessages/>




  20. To perform the save operation, the save() method can be invoked on the object. This is an example of action binding. <apex:commandButton value="Save" action={!save}"/>




  21. The look-and-feel of VisualForce is managed using StyleSheets. Default SalesForce look-and-feel can be changed.




  22. The size of VisualForce page cannot be more than 15MB.




  23. Web Services can also be invoked from VisualForce.




  24. Layout Editors

  25. Layout editor provides a drag-and-drop interface to define the user interface. Using Layout editor, fields of a page can be moved around, sections and space can be added.




  26. Layout editor supports one-column and two-column layout.




  27. Double-clicking on a field allows fields to be made read-only and required.



What’s the difference between Einstein Article Recommendations and Suggested Articles?

How Does Einstein Article Recommendations Work? Einstein Article Recommendations helps support agents resolve customer cases efficiently by ...