Posts

Showing posts from 2016

Web-to-Case In Salesforce

Image
Creating a Web-to-Case form in Salesforce enables you to automatically convert customer inquiries submitted through your website into cases within your Salesforce. Turn On and Customize Web-to-Case Generate and Test Your Web-to-Case Form To test the Web-to-Case form, add the line <input type="hidden" name="debug" value="1"> to the code. This line redirects you to a debugging page when you submit the form. Don’t forget to remove it before publishing the Web-to-Case page on your website. Web-to-Case Limits 5,000 cases in a 24-hour period. When you reach the 24-hour limit, additional requests are stored in a pending request queue that contains both Web-to-Case and Web-to-Lead requests Unsupported Content Types Web-to-Case forms don’t support the following content types: Attachments Rich text area (RTA) fields—If you use these fields on your forms, any information entered in them is saved as plain text when the case is created. Multipart/form-data—Cases ...

Web-to-Lead In Salesforce

Image
Creating a Web-to-Lead form in Salesforce allows you to capture lead information directly from your website and automatically create leads within your Salesforce instance Generate a new HTML by going to Setup > App Setup > Customization > Leads > Web-to-Lead. Generate Leads from Your Website for Your Sales Teams We can have multiple web-to-lead forms for various websites or landing pages and can be used to send leads to Salesforce. Please note that using the Web-to-Lead form you can automatically generate up to 500 new leads a day. Some of the Lead Sources available in Salesforce Web Phone Inquiry Partner Referral Purchased List Other Employee Referral Twitter External Referral Partner Public Relations Trade Show Word of mouth Here are the steps to follow  Click on "Create Web-to-Lead Form" Once you fill in the details, Click on "Generate" Here's a simple example of what the HTML code for the Web-to-Lead form might look like: <form action="ht...

Dynamic DML in Salesforce

Dynamic DML (Data Manipulation Language) in Salesforce refers to the ability to perform insert, update, upsert, delete, and undelete operations on records dynamically at runtime. This is particularly useful when you need to work with records whose types or quantities are determined dynamically, based on user input or other runtime conditions. Salesforce provides several ways to perform dynamic DML operations, primarily through Apex, the programming language used on the Salesforce platform. Here's an overview of how dynamic DML operations can be achieved in Salesforce: Dynamic DML Operations in Apex: In Apex, you can use dynamic DML statements to perform DML operations on records dynamically. This involves constructing DML statements as strings and then executing them using methods like Database.insert(), Database.update(), Database.upsert(), Database.delete(), or Database.undelete(). Example // Define a list of sObjects to perform DML on List<SObject> recordsToInsertOrUpdate...

Salesforce Query Languages - SOQL & SOSL

In Salesforce, both SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language) are query languages used to retrieve data from the Salesforce platform, but they serve different purposes and have distinct syntaxes. SOQL (Salesforce Object Query Language) : SOQL is a query language used to retrieve records from a single object or related objects in Salesforce. It's similar to SQL (Structured Query Language) and is tailored specifically for querying Salesforce data. Key features of SOQL include: SELECT Statement: Used to retrieve specific fields from records. Filters and Conditions: WHERE clause allows filtering records based on specified conditions. Relationship Queries: Allows querying related objects using relationship fields. Aggregate Functions: Supports aggregate functions like SUM(), AVG(), MAX(), MIN(), and COUNT(). Ordering and Sorting: ORDER BY clause enables sorting results based on specified fields. Example of a SOQL query: SELECT Id, Name, Accou...

Dynamic Apex in Salesforce

Dynamic Apex in Salesforce refers to the ability to construct and execute code dynamically at runtime, rather than having it defined statically at compile time. This feature allows developers to build more flexible and adaptable solutions that can respond to changing requirements or conditions during program execution. Dynamic Apex enables developers to create more flexible applications by providing them with the ability to: Access sObject and field describe information- Metadata information about sObject and field properties includes details about operations supported by sObject types (such as create or undelete), name and label of sObjects, fields and child objects. Field information contains details like default value presence, calculated field status, and field type Apex provides two data structures and a method for sObject and field describe information: Token —a lightweight, serializable reference to an sObject or a field that is validated at compile time. This is used for token...

Add a Lightning application within a Visualforce page in Salesforce

  <!-- create a lightning app with global access that extends lightning outApp-->   YourLightningComponent.app <aura:application access="GLOBAL" extends="ltng:outApp">        <aura: dependency resource="lightning: button"/>   </aura: application>   <apex:page >     <apex:includeLightning />          <div id="lightningContainer"></div>     <script>         $Lightning.use("c:YourApp", function() {             $Lightning.createComponent(                 "c:YourLightningComponent",                 {},                 "lightningContainer",                 function(cmp) {                   ...

Dynamic SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language)

Dynamic SOQL (Salesforce Object Query Language) and SOSL (Salesforce Object Search Language) are powerful tools in the Salesforce ecosystem that allow developers to construct queries and search statements dynamically based on runtime conditions. This flexibility enables developers to build more dynamic and adaptable solutions. Here's an overview of dynamic SOQL and SOSL: Dynamic SOQL: Dynamic SOQL allows you to construct queries at runtime using string manipulation techniques. This is particularly useful when you don't know the structure of the query until the application is running. Here's a basic example of dynamic SOQL in Apex: String query = 'SELECT Id, Name FROM Account'; // You can add conditions dynamically based on runtime logic if(someCondition) {     query += ' WHERE CreatedDate > TODAY'; } List<Account> accounts = Database.query(query); Dynamic SOSL: Dynamic SOSL allows you to construct search queries dynamically. SOSL is used to search...

Salesforce MIXED_DML_OPERATION

The MIXED_DML_OPERATION error in Salesforce occurs when you attempt to perform a DML (Data Manipulation Language) operation on setup objects (such as User, Profile, UserRole, Group, etc.) within the same transaction as DML operations on regular sObjects (standard or custom objects).  This restriction is in place to maintain the integrity and security of Salesforce data because setup objects control system-wide settings and configurations that could impact multiple users and processes. Here's how you can handle the MIXED_DML_OPERATION error: Separate Setup and Non-Setup DML Operations : Split your DML operations into separate transactions, with one transaction handling DML operations on regular sObjects and another transaction handling DML operations on setup objects. public void handleMixedDML() {     // Perform DML operations on regular sObjects     List<Account> accountsToUpdate = [SELECT Id, Name FROM Account LIMIT 10];     // Perform DML oper...

Pagination in Visualforce using StandardSetController

Image
The StandardSetController is a controller class that enables you to create a Visualforce page to showcase a list of records. It has built-in capabilities to handle pagination, thus simplifying displaying extensive data sets on a Visualforce page. Here are some key features and functionalities of StandardSetController: Pagination : StandardSetController automatically handles pagination, allowing you to display a subset of records on each page. It provides methods for navigating between pages, such as first(), previous(), next(), and last(). Sorting and Filtering : StandardSetController allows you to specify sorting and filtering criteria for the records displayed on the Visualforce page. You can define sorting order and filter conditions using the setSortOrder() and setFilterId() methods. Record Navigation : You can easily navigate to the first, last, previous, or next page of records using methods provided by StandardSetController. This simplifies the implementation of navigation contr...

Salesforce Cron expression for Scheduling the Job

Image
In Salesforce, you can use cron expressions to schedule jobs to run at specific times or intervals. Cron expressions are strings comprised of six or seven fields that represent various components of time (seconds, minutes, hours, days, months, and optionally, years).  Apex Scheduler Note Salesforce schedules the class for execution at the specified time. Actual execution can be delayed based on service availability.The System.schedule method uses the user's timezone for the basis of all schedules. Here's the format: Seconds Minutes Hours Day_of_month Month Day_of_week Optional_year The following are the values for the expression: The special characters are defined as follows: The following are some examples of how to use the expression. Here are some examples of cron expressions commonly used for scheduling jobs in Salesforce: Every day at midnight: 0 0 0 * * ? Every hour: 0 0 * * * ? Every 15 minutes: 0 0/15 * * * ? Every weekday at 9 AM: 0 0 9 ? * MON,TUE,WED,THU,FRI Every 30...

Salesforce Batchable Apex and Schedulable Apex with an Example

Salesforce provides two powerful features for executing code asynchronously: Batchable Apex and Schedulable Apex. These features allow developers to perform complex data processing tasks, integrations, or other long-running operations without impacting the user interface or causing performance issues. Below, I'll explain each feature along with an example for better understanding. Batchable Apex: Batchable Apex allows you to process large data sets in smaller, more manageable batches. It is particularly useful when dealing with large volumes of records that cannot be processed synchronously due to Salesforce's governor limits. Here's an example of how Batchable Apex works: // Example Batchable Apex class global class MyBatchableClass implements Database.Batchable<sObject> {          global Database.QueryLocator start(Database.BatchableContext BC) {         // Query the records you want to process         return Datab...