Posts

S-Controls in Salesforce

Image
Use s-controls to add your own functionality to your Salesforce organization. Whether you are integrating a hosted application of your own or are extending your current Salesforce user interface, use s-controls to store your code or refer to code elsewhere. Custom s-controls can contain any type of content that you can display in a browser, for example a Java applet, an Active-X control, an Excel file, or a custom HTML Web form. Here're the steps to create a new S- Control The custom s-control library is a place where you can store and upload content for use in many areas within Salesforce such as, custom links, Web tabs, custom buttons, and dashboards. From Setup, enter S-Controls in the Quick Find box, then select S-Controls. To create a new custom s-control, click New Custom S-Control. To change an existing custom s-control, click Edit. Enter s-control attributes. To validate all Salesforce merge fields and functions, click Check Syntax. Click Save when you finish or click Quick...

Display error messages with different severity levels in a Visualforce page

Image
To display error messages with different severity levels in a Visualforce page using ApexPages.addMessage, you can follow the same approach as before but with different severity levels. Here's how you can add messages with different severity levels and display them in a Visualforce page: Add Messages with Different Severities in Apex Controller: In your Apex controller, add error messages with different severity levels using ApexPages.addMessage. public class MyController {     public void someAction() {         try {             // Perform some action             if (someCondition) {                 // Add error message with severity                 ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'An error occurred: Some error message'));             } else if (another...

Working with Large Sets of Data

Visualforce custom controllers and controller extensions are subject to Apex governor limits. For more information about governor limits, see Execution Governors and Limits . Additionally, Visualforce iteration components, such as <apex:pageBlockTable> and <apex:repeat>, are limited to a maximum of 1,000 items in the collection they iterate over. Sometimes your Visualforce pages may need to work with or display larger sets of data, but not need to make modifications to that data; for example, if you are providing custom reporting and analytics. Visualforce offers developers a “read-only mode”, which relaxes the limit on the number of rows which can be queried in one request, and increases the limit on the number of collection items which can be iterated over within the page. You can specify read-only mode either for an entire page or, with certain limitations, on individual components or methods. Note - You can only iterate over large sets of data if you specify read-only ...

Rendering PDF Files Using Visualforce Page

Rendering PDF files using a Visualforce page in Salesforce is a common requirement, especially when you need to generate printable documents such as reports, invoices, or statements. Salesforce provides a way to generate PDF files directly from Visualforce pages using the renderAs attribute.    Visualforce <apex:page controller="PDFRenderingController" renderAs="pdf">   <apex:form >     <apex:pageBlock >         <apex:pageBlockTable value="{!accList}" var="acc" border="2">            <apex:column value="{!acc.Name}"/>            <apex:column value="{!acc.AnnualRevenue}"/>            <apex:column value="{!acc.Type}"/>            <apex:column value="{!acc.AccountNumber}"/>            <apex:column value="{!acc.Rating}"/>       ...

Wrapper Class in Apex Salesforce

A wrapper class in Salesforce Apex is a custom class that allows you to combine different types of data into a single object. It's particularly useful when you need to work with complex data structures or display multiple pieces of information in a Visualforce page.  Wrapper classes are commonly used in scenarios like: Visualforce Pages : You can use wrapper classes to display data from multiple related objects in a single table or form on a Visualforce page. Apex Controllers : Wrapper classes can be used to pass complex data structures between Apex controllers and Visualforce pages. Lightning Components : In Lightning development, wrapper classes are often used to format data for display in Lightning components or to simplify the structure of data passed between components. Integration : When working with external systems or APIs, wrapper classes can help structure data in a way that's easier to work with in Apex code. Here's an example of how you can use a wrapper class w...

Mass Updating Records with a Custom Controller Using Visualforce Page

Here's an example illustrating these steps: Controller public with sharing class MassUpdateController {     public List<MyObject__c> records { get; set; }     public Set<Id> selectedIds { get; set; }     public MassUpdateController() {         // Fetch records to display         records = [SELECT Id, Name, Active__c FROM Agent__c LIMIT 10];         selectedIds = new Set<Id>();     }     // Method to handle the mass update operation     public PageReference performMassUpdate() {         List< Agent__c > recordsToUpdate = new List< Agent__c >();         // Fetch selected records to update         for (Agent__c record : records) {             if (selectedIds.contains(record.Id)) {                 // ...

Integrating Visualforce and Google Charts

Integrating Visualforce with Google Charts allows you to create dynamic and visually appealing charts within your Salesforce environment. Visualforce is Salesforce's markup language for building custom user interfaces, and Google Charts is a powerful visualization library provided by Google. Here's a basic guide on how to integrate Visualforce with Google Charts: <!-- MyChartPage.page --> <apex:page controller="ChartController">     <apex:includeScript value="https://www.gstatic.com/charts/loader.js"/>     <script>         google.charts.load('current', {'packages':['corechart']});         google.charts.setOnLoadCallback(drawChart);         function drawChart() {             var data = google.visualization.arrayToDataTable({!chartData});             var options = {                 title:...