Wednesday, 9 April 2025

Display Map with List Value in a Lightning Component #Salesforce

🗺️ Displaying a Map with List Values in a Lightning Component

When working with complex data structures in Salesforce, using a Map with a List as its value is common in Apex. But displaying this structure in a Lightning Component (Aura or LWC) requires a few tricks. This blog walks through how to pass and render a Map<String, List<Object>> in a user-friendly way.


📦 Use Case

You're retrieving a list of Contacts grouped by Account Name, like:


Map<String, List<Contact>> contactsByAccount = new Map<String, List<Contact>>();

Now, you want to display each account with its related contacts in a Lightning component.


⚙️ Apex Controller


@AuraEnabled(cacheable=true) public static Map<String, List<Contact>> getContactsByAccount() { Map<String, List<Contact>> result = new Map<String, List<Contact>>(); for (Account acc : [SELECT Id, Name, (SELECT Id, Name, Email FROM Contacts) FROM Account LIMIT 10]) { result.put(acc.Name, acc.Contacts); } return result; }

🧩 Aura Component Example


<aura:component controller="YourApexClass"> <aura:attribute name="contactsMap" type="Object"/> <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> <aura:iteration items="{!v.contactsMap}" var="key"> <p><strong>{!key}</strong></p> <aura:iteration items="{!v.contactsMap[key]}" var="con"> <p>- {!con.Name} ({!con.Email})</p> </aura:iteration> </aura:iteration> </aura:component>


⚡ Client-side Controller (JS)


doInit: function(component, event, helper) { var action = component.get("c.getContactsByAccount"); action.setCallback(this, function(response) { if (response.getState() === "SUCCESS") { component.set("v.contactsMap", response.getReturnValue()); } }); $A.enqueueAction(action); }


✅ Best Practices

  • Use @AuraEnabled(cacheable=true) for better performance.

  • Always check for null values in JS to avoid runtime errors.

  • For LWC, transform the map into an array format using Apex before returning.


💬 Final Thoughts

Using a Map<String, List<Object>> structure allows powerful grouping in Apex. With the right approach, rendering it in the Lightning UI is clean and intuitive.


🏋️‍♂️ Boosting Query Performance with Skinny Tables in Salesforce

Salesforce is known for its powerful platform, but performance can take a hit when working with large datasets. This is where Skinny Tables come into play. They’re a Salesforce-supported performance optimization feature that helps speed up reports, dashboards, and queries—especially in data-heavy orgs.



🔍 What is a Skinny Table?

A Skinny Table is a custom, read-only table maintained by Salesforce. It contains a subset of fields from a standard or custom object—indexed and denormalized to avoid joins and speed up queries.

  • Managed internally by Salesforce

  • Updated near real-time with the source object

  • Limited to 100 fields per table

  • Fields must be of certain data types (e.g., no long text, rich text, etc.)


📘 Use Case: Slow Report on Opportunities

Problem: A report filtering on multiple Opportunity fields (e.g., StageName, Amount, OwnerId, Custom_Field__c) is running slow due to large volume (~10M rows) and non-indexed filters.

Solution: Create a skinny table with just the critical fields used in the report filter and display.


Skinny Table: Opportunity_Skinny Fields: - Id - StageName - Amount - OwnerId - Custom_Field__c - CloseDate

Result: Queries now pull from a smaller, indexed table with no joins—improving performance drastically.


🛠 How to Use Skinny Tables

You cannot create skinny tables via UI or Apex. You must raise a Salesforce Support case with:

  • Object name

  • Fields to include

  • Use case (e.g., performance bottleneck on reporting or SOQL)


✅ Best Practices

  1. Use only when needed
    Ideal for high-volume objects and slow queries. Avoid overuse—each skinny table adds overhead to SFDC's backend.

  2. Pick frequently used fields
    Focus on filter and output fields. Avoid large text, formula, or lookup fields.

  3. Test before and after
    Benchmark SOQL or report runtime to validate the improvement.

  4. Be aware of limitations

    • Doesn’t support sandbox refresh automatically

    • No support for all field types

    • Changes require support ticket

  5. Combine with other optimizations
    Skinny tables work well alongside custom indexes and selective queries.




✅ Steps to Enable:

  1. Open a Salesforce Support Case

  2. Case Details to Provide:

    • Subject: Request to create a skinny table

    • Reason: Performance optimization

    • Details:

      • API name of the object (e.g., Opportunity)

      • List of fields to include (up to 100)

      • Example SOQL query or report that’s slow

      • Sandbox or Production org

      • Justification: Performance issues, query time, or user impact

  3. Salesforce Support Review:

    • They’ll validate field compatibility

    • Implement the skinny table on backend

    • Provide confirmation once it’s live

  4. Test & Monitor:

    • Validate performance improvements

    • Monitor regularly—especially after schema changes



🧠 Pro Tip

You can use Query Plan Tool in Developer Console to identify whether a query is selective—and whether skinny tables or custom indexes could help.



📌 Final Thoughts

Skinny tables are a powerful lever for performance, especially in data-intensive orgs. Use them strategically, monitor their impact, and pair them with indexing and query optimization for maximum benefit.

Tuesday, 21 January 2025

Unleashing the Power of Salesforce AI: Transforming Business

Artificial Intelligence (AI) is no longer a futuristic concept; it is the driving force behind innovation in today’s business landscape. Salesforce, a leader in Customer Relationship Management (CRM), has fully embraced AI to help businesses deliver smarter, faster, and more personalized customer experiences. This blog explores Salesforce’s AI capabilities with a spotlight on Einstein GPT and Tableau AI, showcasing their impact through examples and data points.




Einstein GPT: Revolutionizing Customer Interactions

Einstein GPT, Salesforce’s generative AI tool, combines Salesforce’s proprietary AI models with generative capabilities to revolutionize how businesses engage with customers. By integrating AI directly into the Salesforce platform, Einstein GPT enables real-time, contextually relevant responses across sales, service, and marketing functions.

Use Case: Enhancing Customer Support

A leading e-commerce company implemented Einstein GPT in their Salesforce Service Cloud to streamline customer support. Here’s what they achieved:

  • Reduction in Response Time: Automated response generation reduced customer query response time by 45%.

  • Improved Customer Satisfaction: Customer satisfaction scores (CSAT) improved by 30% due to accurate and faster resolutions.

  • Cost Efficiency: The company reduced support staff workload by 25%, reallocating resources to more complex cases.

Key Features

  1. Dynamic Email Responses: Einstein GPT drafts personalized emails based on historical interactions and customer preferences.

  2. Smart Chatbots: AI-powered chatbots handle routine queries with human-like responses, ensuring 24/7 support.

  3. Predictive Insights: Proactively recommends next-best actions based on customer sentiment analysis.

Tableau AI: Turning Data into Actionable Insights

Salesforce’s Tableau AI takes business intelligence to the next level by embedding AI into analytics. It empowers users to uncover trends, predict outcomes, and make data-driven decisions effortlessly.

Example: Sales Forecasting for Retail

A retail chain leveraged Tableau AI to improve sales forecasting. Here are the results:

  • Sales Prediction Accuracy: Forecast accuracy increased by 38% through predictive models analyzing historical and real-time data.

  • Inventory Optimization: Reduced overstocking by 20% due to accurate demand forecasting.

  • Revenue Growth: Achieved a 15% year-over-year revenue increase by identifying high-demand products and regions.

Key Features

  1. Explainable AI: Provides clear insights into how predictions are made, fostering trust in the analytics.

  2. What-If Scenarios: Enables scenario modeling to evaluate potential business decisions.

  3. Automated Alerts: Notifies users of significant trends or anomalies in real time.

AI’s Business Impact: By the Numbers

Salesforce’s 2023 State of AI report highlights the transformative impact of AI on businesses:

  • 88% of IT Leaders report that AI is critical to their digital transformation strategies.

  • 44% Improvement in customer retention rates among organizations leveraging Salesforce AI.

  • 40% Productivity Boost for teams using AI-driven workflows and automation.

Looking Ahead: The Future of AI in Salesforce

Salesforce continues to innovate in AI, focusing on ethical AI use, seamless integrations, and industry-specific solutions. With tools like Einstein GPT and Tableau AI, businesses can not only keep pace with change but also drive it.



Stay tuned for more updates on Salesforce’s AI advancements and how they can impact your industry.