Posts

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:...

Salesforce Data collections List ,Set ,Map

In Salesforce Apex, data collections such as lists, sets, and maps are used to store and manipulate data. These collections offer different functionalities and are suited for different use cases. Here's an overview of each:  List : A list is an ordered collection of elements where each element has an index. Lists allow duplicate elements. Elements in a list can be accessed using their index. Lists are represented by the List class in Apex. Example : List<String> names = new List<String>(); names.add('Alice'); names.add('Bob'); names.add('Alice'); // Adding duplicate element System.debug(names); // Output: (Alice, Bob, Alice) Set : A set is an unordered collection of unique elements. It does not allow duplicate elements. Sets are useful when you need to ensure uniqueness and don't require the elements to be in a specific order. Sets are represented by the Set class in Apex. Example : Set<String> uniqueNames = new Set<String>(); uni...

Dynamic Menu Using JDock

Image
Show Sleek and Dynamic Menu on the Visualforce Page. jqdock is a jQuery plugin inspired by Mac .jqdock is a jQuery plugin inspired by Mac Dock Menu. jqDock   Visualforce Page <apex:page sidebar="false" showHeader="false" controller="JqueryController">  <head>    <style> bPageHeader{       display:none;   }   .heading{       background-color:#ccc;       text-align:center;   }   .data table,td,th {       border:1px solid #000;   }   </style>  <apex:includeScript value="{!$Resource.jquery}"/>  <apex:includeScript value="{!$Resource.jqDock}"/>   <style type='text/css'>  /*position and hide the menu initially - leave room for menu items to expand...*/ #page {padding-top:150px; padding-bottom:20px; width:100%;} #menu {position:absolute; top:0; left:0; width:100%; display:none;} /*dock styling...*/ /*...centre the dock...*/ ...

Master-Detail and Lookup relationships in Salesforce

Image
In Salesforce, Master-Detail and Lookup relationships establish relationships between objects. Here's an explanation of each: Dependency and Data Integrity: Master-Detail Relationship: Child records are tightly bound to parent records. If a parent record is deleted, all associated child records are deleted. This ensures strong data integrity and dependency between records. Lookup Relationship: Child records can exist independently of parent records. Deleting a parent record does not automatically delete associated child records. This offers more flexibility but results in weaker data integrity than Master-Detail relationships. Ownership and Control: Master-Detail Relationship: The parent object owns the relationship, and the child object is subordinate. The child record inherits security and sharing settings from the parent record. Master-detail relationships are typically used for objects with a clear parent-child relationship where the parent owns the child's records. Lookup ...

Visualforce Best Practices

Visualforce is a powerful framework for building user interfaces in Salesforce applications. Here are some best practices to keep in mind when working with Visualforce: Best Practices for Improving Visualforce Performance Best Practices for Accessing Component IDs Best Practices for Static Resources Best Practices for Controllers and Controller Extensions Best Practices for Using Component Facets Best Practices for Page Block Components Best Practices for Rendering PDF Files Rendering a Visualforce page as a PDF file is a great way to share information about your Salesforce organization. Here are some best practices for you to consider. Best Practices for <apex:panelbar> Documentation Typographical Conventions