Posts

Depth First Search [DFS]

Image
Graph traversal algorithms are also called graph search algorithm. Two such algorithms for traversing the graphs : Depth First Search [DFS] Breadth First Search [BFS] Depth First Search [DFS]: DFS algorithm works in a manner similar to a preorder traversal of the trees. We encountered the following types of edge: Tree edge: encounter new vertex. Back edge: from descendant to ancestor. Forward edge: from ancestor to descendant. Cross edge: between a tree or subtree. To track the vertices two colours are enough: false → Vertex is unvisited. true  → Vertex is visited. Source code in Java: import java.util.LinkedList; import java.util.Iterator; /**  *  * @author Rohan  */ public class Graph  {     private int V;   // No. of vertices     // Array  of lists for Adjacency List Representation     private LinkedList<Integer> adj[];     /...

Wrapper Class in Salesforce

What is the Wrapper Class? A wrapper or container class is a class, a data structure, or an abstract data type which contains different objects or collection of objects as its members. For example, we want to delete one or more than one account using checkbox and button. So wrapper class looks like shown below- Apex Class public class Checking {          public List<ContactWrp> cw {get;set;}          public Checking()          {                   for(Contact con : [select id,name from Contact])                   {                             cw.add(new ContactWrp(con,false));                   }          }          pu...

Salesforce Workflow Rules

Image
What is the workflow rules? Automation: Certain steps are defined and the system follows those step to execute the solution for the problem. Workflow Rules are the automated process to send E-mails Alerts, Field Update, Outbound Message, Existing Action on trigger criteria based requirements. How to create workflow rules? 1. Go to Setup. 2. Search for workflow in  Quick Find/Search  box and then clicks on  Workflow Rules. 3. Clicks on New Rule button.  4. Select an object which you want this workflow rule to apply and then clicks on the Next button. 5. Enter a Rule Name . 6. Enter a Description for the rule. 7. Select the evaluation criteria. created: Evaluate the rule criteria each time a record is created. With this option, the rule never runs more than once per record. created, and every time it's edited: Evaluate the rule criteria each time a record is created or updated. With this option, the ...

Salesforce Collection

What is a collection? A group of elements or similar types of elements is called collection. There are three types of Salesforce Collection:- Map Set List Map: Map is key-value pairs. Syntax:  Map<Key,Value> nameOfMap = new Map<Key,Value>(); Key → is a set.  Value or Values → is a list.   Methods in Map: put()       → add a key-value pairs. get()       → retrieve a value for a key. keySet() → retrieve all the keys and return type is set. values() →  retrieve all the values and return type is list. size()     → return the number of components in the map. Set: Set is an ordered collection of elements which will not allow duplicate. Syntax: Set<Type> NameOfSet = new Set<Type>(); Type → String or Integer or any data type. Methods in Set: add() → to add. get() → to get value by index. List:  List is an unordered collection of e...

Apex Trigger

What is the trigger? A trigger is an Apex code that executes before or after the following types of operations: Insert, Delete, Update, Upsert . Triggers are used to manipulate the data or put the validations on data. Events of the triggers do have some prefixes: Before After Syntax: Trigger Trigger_Name on Object_Name(triggers Events) {         //Implement the logic here } Trigger Context Variables:- new: Returns a list of the new version of sObject records. old: Returns a list of the old version of sObject records. isInsert: Returns true if the trigger was fired due to the insert operation. isUpdate: Returns true if the trigger was fired due to  the update  operation. isDelete: Returns true if the trigger was fired due to the  delete  operation. isBefore: Returns true if the trigger was fired before a record  is saved. isAfter: Returns true if the trigger was fired afte...

Data types in Apex Programming

Image
Data types in Apex programming:- 1. Auto Number:   A system-generated sequence number that uses a display format you define. The number is automatically incremented for each record. 2. Formula:   A read-only field that derives its value from a formula expression you define. The formula field is updated when any of the source fields change. 3. Roll-Up Summary: A read-only field that displays the sum, minimum or maximum value of a related list.    4. Lookup Relationship:   Create a relationship that links this object to another object. The relationship allows users to click on a lookup icon to select a value from a popup list. 5. Master-Detail Relationship: Create a special type of parent-child relationship between this object(the child or "detail") and another object(the parent or "master"). 6. External Lookup Relationship:   Create a relationship that links this object to an external object whose data is stored out...

Apex Class

Image
What is Apex Class? It is a collection of variables and library of methods that can be reused. Apex is a strongly typed object-oriented programming language and it will run on Force.com platform. class keyword is used to define an Apex class. Below is the example to create a simple class : public class ClassName {                 //Body of the Apex class.        //Here we can define variables and methods. } How to create an Apex class in Salesforce:- Login to your Salesforce account. Go to setup. Search for Apex in Quick Find/Search box then clicks on Apex Classes.    4. Then clicks on the New button.    5. Write an Apex code.    6. Clicks on the save button.