Posts

Salesforce Approval Process

Approval Process An approval process automates how records are approved in Salesforce. An approval process specifies each step of approval, including from whom to request approval and what to do at each point of the process. Salesforce Approval Processes allow organizations to automate their approval processes for records, such as leads, opportunities, and custom objects. Here's an example of how you can create an Approval Process for Opportunity records and programmatically submit them for approval using Apex: Define Approval Process in Salesforce Setup: Navigate to Setup > Create > Workflow & Approvals > Approval Processes. Create a new Approval Process for the Opportunity object. Define entry criteria, approval steps, approval actions, and any additional criteria or actions as needed. Activate the Approval Process. Submit Opportunity for Approval using Apex: public with sharing class OpportunityApprovalService {          // Method to submit an O...

Anonymous blocks in the Salesforce Developer Console

Image
Anonymous blocks in the Salesforce Developer Console enable you to run Apex code snippets without defining a separate class or method. This feature is helpful for quickly testing small pieces of Apex code or performing ad-hoc operations in the Salesforce environment.  Log into your org. Click on your name and choose the Developer Console. Here's an example of an anonymous Apex code block that queries the Account object and prints the names of the first 5 accounts: Here are some of the key advantages: Quick Testing: You can quickly test small snippets of Apex code without creating a separate class or method. This makes it easy to experiment with different code constructs, queries, or operations before incorporating them into your larger projects. Ad-hoc Operations: Anonymous blocks allow you to perform ad-hoc operations in the Salesforce environment without writing formal code. For example, you can execute data manipulation operations, perform calculations, or query records direct...

Salesforce provided Enterprise & Partner WSDL

Salesforce Partner WSDLs The API provides two WSDLs to choose from: Enterprise Web Services WSDL —Used by enterprise developers to build client applications for a single Salesforce organization. The enterprise WSDL is strongly typed, which means that it contains objects and fields with specific data types, such as int and string. Customers who use the enterprise WSDL document must download and re-consume it when changes are made to the custom objects or fields in their org or when they want to use a different version of the API.  To access the current WSDL for your organization, log in to your Salesforce organization and from Setup, enter API in the Quick Find box. Then, on the API page, select Generate Enterprise WSDL. Partner Web Services WSDL —Used for client applications that are metadata-driven and dynamic in nature. It is particularly—but not exclusively—useful to Salesforce partners who are building client applications for multiple organizations. As a loosely typed represen...

Overview of Salesforce Apex REST and SOAP APIs:

Salesforce provides two primary mechanisms for integrating with external systems: REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) APIs. Both REST and SOAP APIs allow you to interact with Salesforce data and metadata programmatically, including querying, creating, updating, and deleting records. Here's an overview of Salesforce Apex REST and SOAP APIs: Apex REST (RESTful Web Services): Description: Apex REST allows you to expose custom RESTful web services within Salesforce. You can define custom REST endpoints using Apex classes and methods, which can then be invoked by external systems using HTTP requests. Usage: Apex REST is well-suited for building lightweight, stateless APIs that adhere to RESTful principles. It's commonly used for integrating with mobile applications, external web services, and other systems that communicate over HTTP. Authentication: Apex REST supports various authentication mechanisms, including OAuth 2.0, Session ID, and ...

Validate Salesforce User

Image
 Here's a piece of code to verify the password of a user.            HttpRequest request = new HttpRequest();         request.setEndpoint('https://login.salesforce.com/services/Soap/u/22.0');         request.setMethod('POST');         request.setHeader('Content-Type', 'text/xml;charset=UTF-8');         request.setHeader('SOAPAction', '""');         request.setBody( prepareSoapLoginRequest ('me_raja1@test.com','QW@232323'));         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.Info, String.valueOf(new Http().send(request).getBody())));  public static String  prepareSoapLoginRequest (String username, String password){         XmlStreamWriter w = new XmlStreamWriter();         w.writeStartElement('', 'login', 'urn:partner.soap.sforce.com');         w.w...

Salesforce Workflow Rules vs Process Builder

Process Builder and Workflow Rules are automation tools in Salesforce that allow users to automate business processes without writing code. While they serve similar purposes, there are differences in their capabilities and use cases.  Workflow Rules: Purpose: Workflow Rules are used to automate standard business processes in Salesforce. They allow you to define criteria and actions to be executed when records meet specified conditions. Capabilities: Criteria: You can define entry criteria based on record field values or related objects. Immediate Actions: Actions such as field updates, email alerts, outbound messages, task creation, and posting to Chatter can be triggered immediately when the criteria are met. Time-Dependent Actions: You can schedule time-dependent actions, such as email alerts or task creation, to occur after a specified period. No Rollbacks: Workflow Rules do not support record rollbacks if an error occurs during execution. Usage: Workflow Rules are suitable for ...

Pass by Value or Pass by Reference in Salesforce

Pass by Value: When you pass a primitive data type (such as Integer, Boolean, String) as an argument to a method, a copy of the value is passed to the method. Any changes made to the parameter within the method do not affect the original value of the variable passed in. This behavior is consistent with most programming languages and is commonly referred to as pass-by value. Example: public void incrementValue(Integer x) {     x++; // Changes made to 'x' do not affect the original value of the variable passed in } Integer value = 10; incrementValue(value); System.debug(value); // Output: 10 (unchanged) Pass by Reference (for non-primitive data types): When you pass a non-primitive data type (such as List, Map, Set, or custom objects) as an argument to a method, a reference to the original variable is passed to the method. This means that changes made to the parameter within the method can affect the original value of the variable passed in. However, assigning a new value to the...