We studied the basics of App Development on Force.com. We created database objects, page layouts, and tabs. Now that we have created our model and view, it is time to add some business logic. Business logic is the brain of the application; it makes sense of the data and responds to the button clicks in the UI.
A controller in the Model-View-Controller architecture forms the bridge between a Model (Data) and View (Display). We can write the business logic in the Apex code as well as in a declarative syntax. In this chapter, we will focus on the declarative syntax to write business logic.
In this chapter, we will cover the following topics:
There are different ways to automate repetitive business processes on the platform. We can use any of the following tools to do this:
The automation tool that we need depends on the type of business process that we are automating.
For example:
One of the biggest drawbacks for all the process automation tools on Salesforce has been the inability to perform actions on the data, while it was being entered. This limitation is solved using Visual Workflow.
For example, creating an Opportunity capture wizard that lets the customer representative fill out a form to create opportunities.
If the process requires an approval from a manager in the hierarchy, we can use an approval process.
The following table explains the features used in the various tools:
Workflow |
Process Builder |
Visual Workflow |
Approvals | |
---|---|---|---|---|
Single if/then Statement |
YES |
YES |
YES |
YES |
Complex if/then- if/then statements |
No |
No |
YES |
No |
Drag and Drop designer |
No |
Yes |
Yes |
No |
Is triggered when |
The record is changed |
The record is changed |
A user clicks on a button or link A user accesses the custom tab The process starts The Apex method triggers |
A user clicks on a button or link A process or flow calls the Submit for Approval action The Apex method triggers |
Supports time-based actions |
Yes |
Yes |
Yes |
No |
Supports user interaction |
No |
No |
Yes |
Yes (Only for approvals) |
Call Apex methods |
No |
Yes |
Yes |
No |
Create and Delete Object records |
Only Tasks |
Only Create |
Create and Delete |
No |
Post to Chatter |
Yes (Pilot) |
Yes |
Yes | |
Send email |
E-mail alerts |
E-mail alerts |
Yes |
E-mail alerts |
Send outbound messages without code |
Yes |
No |
No |
No |
Submit for approval |
No |
Yes |
Yes |
No |
Update fields |
The record or its parent |
Any related record |
Any record |
The record or its parent |
3.12.160.66