Jira Code: SMT-6
This article briefs about Apex object-oriented language, its triggers, opportunity creation, and remote site access etc.
Apex
Apex is an object-oriented language
Multi-tenant language
On demanding lang
How to initialize a variable in Apex
String method = ‘POST’;
Triggers
- Apex triggers are used to find the triggers.
- Apex can be invoked by using triggers. Apex triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions.
- A trigger is Apex code that executes before or after the following types of operations:
- insert
- update
- delete
- merge
- upsert
- Undelete
There are two types of triggers:
- Before triggers are used to update or validate record values before they’re saved to the database.
- After triggers are used to access field values that are set by the system (such as a record’s Id or LastModifiedDatefield) and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue. The records that fire the after trigger is read-only.
How to navigate
Setup -> Build -> Develop -> Apex Triggers
Classes
- A class is a template or blueprint from which objects are created. An object is an instance of a class.
- A class can contain other classes, exception types, and initialization code.
- An interface is like a class in which none of the methods has been implemented—the method signatures are there, but the body of each method is empty. To use an interface, another class must implement it by providing a body for all of the methods contained in the interface.
How to navigate
Setup -> Build -> Develop -> Apex Classes
Opportunity
Create an opportunity
Create New -> opportunity
View opportunity
Opportunities
Remote Site Access: Remote site settings. Salesforce allows you to access external website resources from a Salesforce application for your organization. You can access these external websites through Visualforce pages, Apex Callout, and via XmlHttpRequest calls.
Adding Remote Site Settings
- From Setup, enter Remote Site Settings in the Quick Find box, then select Remote Site Settings.
- Click New Remote Site.
- Enter a descriptive term for the Remote Site Name.
- Enter the URL for the remote site.
- Optionally, enter a description of the site.
- Click Save.