background preloader

Sumitdatta

Facebook Twitter

Your first Salesforce Apex Trigger from scratch!!! - SalesforceNextGen. Writing your first Salesforce Apex Trigger from scratch!!!

Your first Salesforce Apex Trigger from scratch!!! - SalesforceNextGen

Before we dive deep into the abyss of Salesforce Trigger, we should know a little more about Triggers and why do we need a Trigger. Triggers are set of code lines which are scheduled to run on a DML event, i. e. when a record is created, updated, deleted, merged or recovered and automate the flow of execution before or after the DML event. But we have another tool to automate business logic on DML event and that is Workflows. As we know that there are certain scenarios, in which we are not able to use Workflow for e.g., If we want to create a record of the separate object, on an update of standard contact object then we simply cannot use workflow.

With workflow we can only perform few task i.e., field update, send email, send an outbound message and create a task. Writing a Simple Apex Trigger !! Writing a Simple Apex Trigger !!

Writing a Simple Apex Trigger !!

Now we know where to write a Trigger, let’s begin with a simple example. In this scenario I would like to add a custom text in the last name of a contact. Making Apex trigger a bit more complex. Making the Apex trigger a bit more complex!!

Making Apex trigger a bit more complex

Making a Call to class’s method from the Trigger. This way we are able to implement the OOPs concept, our trigger’s code is efficient and maintenance of the code is easier. In the following code, we are going to call a method from a utility class, this method is used for sending an email to a recipient. To create the trigger, go to Developer Console->file->New-> Apex Trigger. Design Patterns for Bulkifying an Apex Trigger. Design Patterns for bulkifying an Apex Trigger As Salesforce is built on the multi-tenant architecture, it has multiple platform limits which govern the uses of resources at one particular transaction.

Design Patterns for Bulkifying an Apex Trigger

As the Apex trigger can operate on multiple records at the same time, it can easily breach the governor limits and therefore it is suggested that Apex trigger should be bulkified before it is moved to production. Benefits of bulkified Trigger are many for e.g.: Better performanceConsume fewer resources and time over the serverIt rarely breach the governor limits. Visualforce for salesforce Beginners. Visualforce for Beginners What is Visualforce?

Visualforce for salesforce Beginners

It is a web development framework. Developers can make complex UI both for mobile and desktop which can be hosted on forc.com environment. Visualforce provides access to Salesforce inbuilt features and enables us to extend them and introduce a new or custom functionality. Data Model and Management - SalesforceNextGen. A data model is a way to represent the tables in the database which makes sense to humans, they help in understanding the relationship between different objects and Salesforce provides a very intuitive way to model the database.

Data Model and Management - SalesforceNextGen

In the database a table is equivalent to an object, fields of the object are referred as a column of the table and a row of this table is known as a record. The data model is a collection of these objects and field in an app. There are many types of objects supported by Salesforce like standard object, custom object, external objects, Big Objects and Platform events. Salesforce interview Questions Latest - SalesforceNextGen. In this post, I have collected all the Salesforce interview Questions which were asked to me in Salesforce interview for 2-3 years of experience.

Salesforce interview Questions Latest - SalesforceNextGen

I have compiled these questions to the best of my knowledge. The answer provided here are answered to the best of my knowledge and they can be wrong, so kindly refer Apex developer guide and visualforce guide and other means to verify the answers. If you think any answer is incorrect then do mention the same in the comments. Asynchronous Apex, Batch Apex, Future method, Queuable and Schedule. Asynchronous Apex, we all know how sometimes Salesforce Governor Limit can haunt us at times.

Asynchronous Apex, Batch Apex, Future method, Queuable and Schedule

With the limited amount of resource available due to the multi tenant architecture, we have to restrict our self with the optimum usage of the resources. But what if we want to use the platform to its maximum limit, what if we want to do the process on huge volume of data. To overcome the above-mentioned crisis, Salesforce Apex has provided us with the feature of Asynchronous Apex. To start with Asynchronous Apex provides us with the double governor limits in most of the cases and in some, we can perform a bulk operation on records up to 50 million. There are lots of benefits of using Asynchronous Apex, but we are supposed to choose which Asynchronous apex would be the best way to reach our business goal.

Image Source: How Asynchronous calls are handled by Salesforce’s Queue store and is then distributed to the application servers. Salesforce Admin Certification Mock Exam - SalesforceNextGen. Then go through the series of Salesforce Admin Mock exams and test your skills. 0 of 60 questions completed Questions:

Salesforce Admin Certification Mock Exam - SalesforceNextGen

Apex Trigger Best Practices and the Trigger Framework - SalesforceNextGen. Apex Trigger Best Practices In this section we will understand the best practices a user needs to follow to ensure the Trigger runs smoothly throughout its lifetime.

Apex Trigger Best Practices and the Trigger Framework - SalesforceNextGen

We have always run in the situation where we have begun with a trigger which has a few lines of codes and serves a single purpose. But as the time progress our trigger becomes more and more complex with addition of new business logic and keeps on growing. Asynchronous Apex, Batch Apex, Future method, Queuable and Schedule. Salesforce Interview Question and Answers Part 2. Salesforce Interview questions on DML Q. Salesforce Interview Questions and Answers Part. Salesforce Interview Questions and Answers What is Salesforce and what is the architecture of Salesforce?

A. Salesforce is a Cloud based software made on Force.com platform, it has a pre-built feature to serve as a CRM, but Salesforce is not limited to be called CRM, It has many out of the box features. Salesforce uses Multitenant architecture 2. A. Images sourced from site 3. A. 4. Salesforce Interview Questions on Trigger. Salesforce Interview Questions on Trigger What is a Trigger? Trigger can invoke Apex code, they come in handy when we want to perform some custom task just before or after a record is either created updated or deleted.

What are the various event on which a trigger can fire? Salesforce Live, Working, Demo of Projects. Here you will find the Live working demo of projects made with the help of Salesforce platform using Apex, VisualForce, SOQL, SOSL, Lightening. SOQL2SQL – this code utilizes all the concept from Salesforce dynamic apex, Dynamic SOQL, sObject Describe call etc. With the help This app you can create/structure SOQL query without even typing a single line of code yourself, this is a perfect tool for beginners to check their knowledge of SOQL and cheat tool for advanced developer to quickly build SOQL query for their requirement. All this possible without logging on to an external website like Workbench. Link : SOQL2SQL. Salesforce interview questions on Batch Class. Salesforce Interview Question on Batch class What is Batch Apex?

It is a class which is capable of accepting records in bulk and then depending upon the batch size the group of records are broken into Batches and are processed asynchronously. When should we use a batch class? We should batch apex when we are dealing with records in bulk mainly the record size above 10000 and cannot be handled by the normal DML operations. What is the basic structure of a Batch class?

Salesforce Interview Question Test Class. Salesforce Interview Questions on Test Class here you will find interview questions related to Apex Test Class, this will help you in acing the interview. SalesforceNextGen. Playing with sObject Collections. SalesforceNextGen. SalesforceNextGen. DML Operation contd Upserting records This command incorporates two DML operation i.e. insert and update in one statement. It has to be provided with a unique identifier such as Record Id, so that it can search the database and find the requested record, if there is no record matching the record Id then a new record is created, if a match found then the record is updated.

But if the record Id or key passed have multiple matches, then it neither updates nor creates a record and throw an error Upsert operation is supported in Dataloader, Apex, and API. Below is the schematic representation of an Upsert Statement. Benefits of using Upsert: It simplifies the process of insertion and updating the records, information about Salesforce Id is not mandatory we can use external Id for this purpose. Best Practice for Upsert: Make external Id, Unique and case insensitive. Use Case for Upsert: Export data from production to sandbox. Merge Records Steps to merge these standard objects are mentioned below: DML Operations in detail. DML Operations in detail: Data manipulation language operations mainly consist of insertion of record and committing it to the database, but we can also do following operations. Data Manipulation Language.

Data Manipulation Language Data Manipulation Language is the way we perform CRUD operations in the database i.e. create, retrieve, update and delete records in the Salesforce Database. Working with Data in Apex. Apex Programming for Beginners. Salesforce : Dynamic Apex. Salesforce Dynamic Apex sobjectfield. Salesforce: Dynamic SOQL Chapter 3. Salesforce: Dynamic SOQL Chapter 3 contd. SalesforceNextGen.