Tuesday, 23 December 2025

Fixing Salesforce Emails Going to Spam: DKIM Setup Step-by-Step (QA to Prod)

 If your Salesforce emails are landing in SPAM (or not being trusted by Gmail / Outlook), the most common reason is missing DKIM configuration.

This guide walks through:

  • What DKIM is

  • Why Salesforce emails fail without it

  • How to set up DKIM safely in a lower sandbox

  • DNS validation, activation, and testing

  • How to roll it cleanly into Production

This is written from a real implementation + troubleshooting perspective, not theory.


What Is DKIM (and Why It Matters)

DKIM (DomainKeys Identified Mail) allows Salesforce to cryptographically sign outgoing emails using your company’s domain.

Mail providers use DKIM to verify:

  • The email genuinely came from Salesforce

  • Salesforce is authorized to send on behalf of your domain

  • The email content wasn’t altered

Without DKIM:

  • Emails look spoofed

  • Spam filters downgrade trust

  • Automated Salesforce emails often land in junk


How DKIM Works with Salesforce (High-Level Flow)

  1. Salesforce generates DKIM keys internally

  2. Salesforce provides CNAME DNS records

  3. IT publishes those records in the domain’s DNS

  4. Salesforce verifies DNS

  5. DKIM is activated

  6. Salesforce signs all outbound emails

⚠️ The private DKIM key never leaves Salesforce.


Why You Should Start in a Lower Sandbox

DKIM is org-specific, which means it is safe and recommended to test in:

  • QA

  • UAT

  • PDX

Benefits:

  • No Production risk

  • Full validation of DNS and headers

  • Easy troubleshooting before rollout

Only SPF is domain-level; DKIM can be validated per org.


Step 1: Create DKIM Keys in Salesforce (Sandbox)

Navigate to:

Setup → DKIM Keys → Create New Key

Recommended values:

FieldValue
Key Size2048-bit
Selectorsfdc-qa
Alternate Selectorsfdc-qa2
Domainyourcompany.com
Domain Match Pattern.*@yourcompany\.com

Some orgs require an Alternate Selector. This supports key rotation and is a good long-term practice.


Step 2: Understand the DNS Records Salesforce Generates

After saving, Salesforce generates CNAME records like:

sfdc-qa._domainkey.yourcompany.com → sfdc-qa.xxxxxx.custdkim.salesforce.com sfdc-qa2._domainkey.yourcompany.com → sfdc-qa2.yyyyyy.custdkim.salesforce.com

These CNAMEs are the only thing IT needs.

❌ You do NOT send a “DKIM key”
✅ You send DNS records


Step 3: Where IT Adds DKIM Records

IT adds these records in the DNS provider that manages your domain, for example:

  • AWS Route 53

  • Cloudflare

  • GoDaddy

  • Azure DNS

Each record must be:

  • Type: CNAME

  • Hostname: exactly as Salesforce provides

  • Value: exactly as Salesforce provides

Both primary and alternate selectors must exist.


Step 4: Verify DNS Before Activating DKIM

Before clicking Activate, confirm DNS resolution:

nslookup sfdc-qa._domainkey.yourcompany.com nslookup sfdc-qa2._domainkey.yourcompany.com

If either returns NXDOMAIN, Salesforce will disable Activate.

This is the #1 reason people get stuck.


Step 5: Activate DKIM in Salesforce

Once both records resolve:

  • Refresh the DKIM page

  • Click Activate

Activation is instant. No deploy. No downtime.

From this moment, Salesforce signs all outbound emails.


Step 6: Send Test Emails and Verify Headers

Send test emails to:

  • One internal address

  • One external Gmail / Outlook address

Check email headers. You should see:

DKIM=PASS dkim=pass header.d=yourcompany.com

SPF may still show SOFTFAIL until SPF is updated — that’s expected.


Common Issues (and Fixes)

Activate Button Disabled

Cause:

  • One or more DKIM CNAME records missing or not propagated

Fix:

  • Verify both selectors with nslookup

  • Ensure record type is CNAME, not TXT


Only One Record Added

Cause:

  • IT added only the primary selector

Fix:

  • Add both primary and alternate CNAME records


Emails Still Go to Spam

Likely missing:

  • SPF update (include:_spf.salesforce.com)

  • DMARC alignment

DKIM improves trust, but SPF completes authentication.


Rolling This into Production

Repeat the same steps in Production, using new selectors:

  • sfdc-prod

  • sfdc-prod2

Never reuse sandbox selectors in Prod.

SPF update is done once, domain-level.


Final Takeaways

  • DKIM is essential for Salesforce email deliverability

  • Always validate in a lower sandbox first

  • You never share a DKIM private key — only DNS records

  • Both selectors must resolve before activation

  • Activation is immediate once DNS is verified

Once DKIM is active, email trust improves immediately.


If you want next:

  • ✍️ Confluence-formatted version

  • ๐Ÿงพ Production rollout checklist

  • ๐Ÿ“ง SPF + DMARC follow-up post

  • ๐Ÿ”— Short LinkedIn version

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.

Friday, 6 December 2024

Getting Started with Salesforce OmniStudio: A Beginner’s Guide

Salesforce OmniStudio is a powerful suite of tools designed to simplify digital engagement, making it easier for businesses to deliver personalized, seamless customer experiences. In this post, we’ll explore the basics of OmniStudio, its key components, and how to get started.




What is Salesforce OmniStudio?

OmniStudio is a declarative development platform that provides tools for creating guided workflows, dynamic UIs, and integrating data efficiently. It helps businesses across industries like telecom, healthcare, and finance deliver tailored solutions faster.

Key Features:

  1. OmniScripts: Build interactive workflows to guide users through complex processes like claims or onboarding.
  2. FlexCards: Create reusable, customizable UI components to display data dynamically.
  3. DataRaptors: Simplify data extraction, transformation, and loading (ETL) without writing code.
  4. Integration Procedures: Handle complex data integrations with external systems through declarative server-side processing.

Getting Started

Step 1: Understand the Use Case

Before diving in, identify your business needs. For example, are you building a guided insurance claim process or displaying customer order history dynamically?

Example: An insurance company wants to streamline claims filing. OmniStudio can:

  • Use OmniScripts for step-by-step guidance.
  • Display claims data using FlexCards.
  • Retrieve customer info with DataRaptors.



Step 2: Install OmniStudio

To access OmniStudio tools, enable OmniStudio Managed Package in your Salesforce org:

  1. Go to Setup > OmniStudio.
  2. Install the managed package.
  3. Assign appropriate permissions.



Step 3: Start with OmniScripts

Create a simple OmniScript to understand how guided workflows work:

  1. Navigate to OmniStudio > OmniScripts.
  2. Create a new OmniScript and define the steps.
  3. Test your script in the Debug mode.

Pro Tip: Use conditional logic to customize user journeys dynamically.



Step 4: Design a FlexCard

FlexCards provide users with real-time, actionable information.

  1. Navigate to OmniStudio > FlexCards.
  2. Drag and drop data fields into your card layout.
  3. Add conditional styling to highlight important metrics.

Example: Highlight overdue payments in red on a customer dashboard.



Next Steps

OmniStudio is vast, and mastering it takes time. Start small, experiment with each tool, and gradually combine them to build advanced solutions.

Learn More:

  • Salesforce Trailhead: OmniStudio modules.
  • Join the Salesforce Trailblazer Community for tips and insights.

With OmniStudio, the possibilities are endless. Whether you’re automating workflows or building dynamic interfaces, it’s a game-changer for modern businesses.

Let us know your favorite OmniStudio feature in the comments!


Visual Elements:

  • Diagram: OmniStudio components.
  • Screenshots: OmniScript builder, FlexCard designer.
  • Example: Workflow or UI component in action.

Friday, 16 August 2024

Transforming Business Operations: The Power of AI and Automation in Salesforce

 In the rapidly evolving landscape of business technology, the integration of artificial intelligence (AI) with automation is no longer just a trend—it's becoming a necessity for organizations aiming to maintain a competitive edge. Salesforce, a leader in customer relationship management (CRM), is at the forefront of this transformation with its AI-driven features, particularly through Salesforce Einstein GPT. This blog explores how the integration of AI and automation within Salesforce is streamlining processes, enhancing customer experiences, and revolutionizing marketing efforts.




The Rise of AI in Salesforce

AI's role in Salesforce has grown significantly over the past few years, moving from a supplementary tool to a central component of the platform's offerings. At the heart of this AI revolution is Salesforce Einstein, an AI layer integrated into the Salesforce platform that enables predictive analytics, smart automation, and personalized customer interactions.

One of the most groundbreaking advancements is Salesforce Einstein GPT, a generative AI tool designed to create personalized content and recommendations in real-time. By leveraging large language models, Einstein GPT can assist businesses in creating tailored marketing content, automating customer service interactions, and even generating complex business insights, all with minimal human intervention.

Streamlining Business Processes with AI and Automation

Automation in Salesforce is not new, but the integration of AI has taken it to new heights. AI-driven automation tools like Einstein Automate are enabling businesses to automate repetitive tasks, streamline workflows, and reduce the manual effort required to manage CRM data. This leads to significant time savings and allows employees to focus on higher-value activities.

For example, with Einstein for Flow, users can now generate complex workflows simply by describing the desired automation in natural language. This tool then generates the flow, significantly reducing the time it takes to set up automated processes. Whether it's automating lead assignment, sending personalized follow-up emails, or managing customer support cases, AI-driven automation ensures that these processes are handled efficiently and with minimal errors.

Enhancing Customer Experiences

In today's customer-centric world, personalization is key to building strong relationships and driving customer loyalty. AI within Salesforce enables businesses to deliver hyper-personalized experiences at scale. Einstein AI analyzes vast amounts of customer data to provide insights into customer behavior, preferences, and needs. This allows businesses to tailor their interactions with customers, from personalized product recommendations to targeted marketing campaigns.

Moreover, Salesforce's AI-driven automation can anticipate customer needs and respond proactively. For instance, AI can predict when a customer is likely to churn and trigger automated workflows to engage the customer with personalized offers or support, thus increasing retention rates.

Revolutionizing Marketing with AI

Marketing is another area where AI and automation are making a profound impact. Salesforce Marketing Cloud leverages Einstein AI to optimize marketing strategies across multiple channels. Marketers can use AI to segment their audience more effectively, personalize content, and even predict the success of their campaigns before they launch.

With Einstein GPT, marketers can generate high-quality content tailored to specific customer segments in a fraction of the time it would take manually. This not only speeds up the content creation process but also ensures that the messaging resonates with the target audience, leading to higher engagement and conversion rates.

The Future of AI and Automation in Salesforce

As AI and automation technologies continue to advance, their integration within Salesforce will only deepen. The ability to leverage AI to drive business decisions, automate complex workflows, and personalize customer interactions will become a standard expectation for businesses of all sizes. For organizations looking to stay ahead of the curve, investing in Salesforce’s AI-driven tools is not just an option—it's a strategic imperative.

Conclusion

The integration of AI and automation in Salesforce is transforming the way businesses operate. By streamlining processes, enhancing customer experiences, and revolutionizing marketing efforts, Salesforce's AI-driven features are enabling businesses to operate more efficiently and effectively. As these technologies continue to evolve, the potential for innovation and growth within the Salesforce ecosystem is limitless.

For businesses looking to harness the power of AI and automation, Salesforce provides a comprehensive suite of tools that can help you stay ahead in an increasingly competitive market. The future of business operations is here, and it's powered by AI.

Unlocking Efficiency: How Google Sheets and Salesforce Integration Can Transform Your Data Management

In today's fast-paced business environment, the ability to seamlessly integrate tools and platforms is key to maintaining a competitive edge. Google Sheets and Salesforce are two powerhouse tools widely used in organizations across the globe—Google Sheets for its simplicity and collaboration capabilities, and Salesforce for its robust CRM functionalities. When these two platforms are integrated, the results can be transformative, providing businesses with enhanced data management, streamlined workflows, and improved decision-making capabilities.



Why Integrate Google Sheets with Salesforce?

Integrating Google Sheets with Salesforce allows teams to connect spreadsheet data directly to their CRM, enabling a range of possibilities that simplify data handling and boost productivity. Here are a few compelling reasons to consider this integration:

  1. Real-Time Data Sync: With integration, data entered in Google Sheets can be automatically synced with Salesforce records, ensuring that your CRM is always up-to-date without manual data entry.

  2. Improved Collaboration: Google Sheets’ collaboration features allow multiple users to work on the same document simultaneously. When integrated with Salesforce, team members can collaborate on data entry, analysis, and reporting, with changes reflected in real-time within Salesforce.

  3. Enhanced Reporting: By pulling Salesforce data into Google Sheets, you can leverage the familiar spreadsheet environment to create custom reports, apply complex formulas, and perform data analysis that might be more cumbersome within Salesforce alone.

  4. Data Management Flexibility: The integration offers flexibility for managing data across both platforms. For example, bulk updates can be performed in Google Sheets and pushed back to Salesforce, simplifying tasks like mass data clean-up or updates.

How to Connect Google Sheets with Salesforce

There are several ways to integrate Google Sheets with Salesforce, depending on your needs and technical expertise. Below are some of the most popular methods:

  1. Salesforce Data Connector for Google Sheets:

    • Installation: Google offers a native add-on called "Salesforce Data Connector for Google Sheets." You can install it from the Google Workspace Marketplace.
    • Features: This connector allows you to import Salesforce reports, create new Salesforce records, update existing records, and even delete records—all from within Google Sheets.
    • How It Works: After installation, you can use the "Add-ons" menu in Google Sheets to log in to Salesforce, pull data, or push updates. The interface is user-friendly, making it accessible even for non-technical users.
  2. Third-Party Integration Tools:

    • Tools like Zapier or Automate.io: These platforms offer more advanced integration options, enabling you to automate workflows between Google Sheets and Salesforce. For example, you can set up Zaps (automations in Zapier) that trigger when new rows are added to a Google Sheet, automatically creating or updating Salesforce records.
    • Advanced Features: These tools also support multi-step workflows, which can integrate Google Sheets, Salesforce, and other platforms in a single process. This is useful for complex automation tasks.
  3. Custom API Integration:

    • For Developers: If your organization has in-house development capabilities, you can use Salesforce's REST or SOAP APIs to build a custom integration. This method provides the most flexibility and can be tailored to meet specific business needs.
    • Use Cases: Custom integrations are ideal for scenarios where out-of-the-box solutions don’t fully meet requirements or where highly specialized data handling is necessary.

Best Practices for Using Google Sheets with Salesforce

To maximize the benefits of integrating Google Sheets with Salesforce, consider the following best practices:

  1. Data Validation: Ensure that data being pushed from Google Sheets to Salesforce is clean and validated. Use Google Sheets’ data validation features to prevent errors before they reach Salesforce.

  2. Access Control: Control who has access to the Google Sheets connected to Salesforce. Limit editing permissions to prevent unauthorized changes to critical data.

  3. Regular Audits: Periodically audit the data flows between Google Sheets and Salesforce to ensure that the integration is functioning as expected and that data integrity is maintained.

  4. Training: Provide training for your team on how to use the integration effectively. This includes understanding how to troubleshoot common issues and best practices for data management.

Conclusion

Integrating Google Sheets with Salesforce is a powerful way to enhance your organization's data management and reporting capabilities. By combining the collaborative strengths of Google Sheets with the CRM power of Salesforce, you can streamline workflows, reduce manual data entry, and improve data accuracy across your organization. Whether you use a native connector, third-party tools, or custom APIs, the integration opens up a world of possibilities for more efficient and effective business operations.

If you haven’t yet explored this integration, now is the perfect time to consider how it could transform the way your team handles data. With the right approach, Google Sheets and Salesforce together can help you unlock new levels of productivity and insight.

Monday, 13 February 2023

LWC key Features #Salesforce



Lightning Web Components (LWC) is a new programming model for building web components on the Salesforce platform. It’s a modern, lightweight, and fast alternative to Aura components and offers a number of new features and benefits to developers.

Here are some key features of LWC:

Modern Web Standards: LWC is built on modern web standards like ES6, HTML, and CSS. This makes it easy for developers who are already familiar with these technologies to get started quickly with LWC.


Reusable Components: Components can be easily reused across multiple pages and applications in Salesforce. This helps reduce duplication of code and saves time for developers.


Lightning-Fast Performance: LWC uses a shadow DOM to encapsulate component logic and styles, which helps ensure lightning-fast performance.


Easy Integration with Apex: LWC components can easily integrate with Apex code to access server-side functionality. This enables developers to create complex applications that can scale to meet business needs.


Strong Security: LWC components are secure by design, which helps prevent XSS attacks and other types of security vulnerabilities.

Let's look at a simple example of how to create an LWC component in Salesforce.

Here’s a component that displays a greeting:

php
<template> <p>Hello, {greeting}!</p> </template> <script> export default class Greeting extends LightningElement { @track greeting = 'World'; } </script>


In this example, we’re using the <template> tag to define the HTML template for our component. The <p> tag displays the greeting, which is stored in a property called greeting.

The <script> tag contains the JavaScript logic for our component. We’re using the export default statement to make our component available to other parts of our application. The LightningElement class provides the core functionality for our component, and the @track decorator is used to indicate that the greeting property should be reactive, meaning that any changes to its value will automatically be reflected in the HTML template.

And that’s it! With just a few lines of code, we’ve created a fully functional LWC component that can be used in a Salesforce application.

In conclusion, LWC is a powerful and modern way to build web components for the Salesforce platform. With its modern web standards, reusable components, lightning-fast performance, easy integration with Apex, and strong security, it’s a great choice for any Salesforce developer.


Saturday, 14 January 2023

Life Cycle Hooks in LWC #salesforce

Lifecycle Hooks A lifecycle hook is a callback method triggered at a specific phase of a component instance’s lifecycle.


There are five types of callback functions :
  1. Constructor()
  2. connectedCallback()
  3. disconnectedCallback()
  4. render()
  5. renderCallback()

constructor()
  1. Called when the component is created.
  2. This hook flows from parent to child, which means that it fires in the parent first. 
  3. You can’t access child elements because they don’t exist yet. Properties aren’t passed yet, either. Properties are assigned to the component after construction and before the connectedCallback() hook.

connectedCallback()

  1. Called when the element is inserted into a dom.
  2. This hook flows from parent to child.
  3. You can’t access child elements because they don’t exist yet.

The connectedCallback() hook can fire more than one time. For example, if you remove an element and then insert it into another position, such as when you reorder a list, the hook fires several times. If you want code to run one time, write code to prevent it from running twice.


The connectedCallback() hook is invoked with the initial properties passed to the component.


renderCallback()

  1. Called after every render of the component.
  2. This lifecycle hook is specific to Lightning Web Components, it isn’t from the HTML custom elements specification.
  3. This hook flows from child to parent.

render()
  1. Call this method to update the UI.
  2. It may be called before or after connectedCallback().
  3. It’s rare to call render() in a component. The main use case is to conditionally render a template. 


disconnectedCallback()
  1. Called when the element is removed from a document.
  2. This hook flows from parent to child.
  3. Use disconnectedCallback() to clean up work done in the connectedCallback(), like purging caches or removing event listeners.

errorCallback()

  1. Called when a descendant component throws an error.
  2. The error argument is a JavaScript native error object, and the stack argument is a string.
  3. This lifecycle hook is specific to Lightning Web Components, it isn’t from the HTML custom elements specification.


Thank you!

Sunday, 19 August 2018

Best in Market - List of Code Review tools #Salesforce

Salesforce is an awesome platform, and has an incredible community that helps their developer and admins to grow in their careers. With Salesforce’s communities we get a lot of great tools which make developer and admin life easy. One of the important practices in project implementation is code review, as it insures your team has visibility into your applications code. Here is the list of few tools which I have found to help review codes:





1 Checkmarx : 



Checkmarx provides an awesome tool to secure your apex and visualforce code as well. It's easy to integrate with your salesforce org and provides you a whole report.
Report has the points of changes and what to changes, I personlly recommend this tool for your application and code security.
https://www.checkmarx.com/

2. Codescan: 



Code Analysis Tools for Salesforce
Its an appexchange tool which is really easy to use and install in your salesforce org. It help developers to identify bugs and increase the quality of your code.
This tool provides incredible UI to analyse you orgs apex code.
https://www.codescan.io/ 



3. PMD source code analyzer :



 PMD is also of the recommended tool to use for your apex code, its easily catches the defects of your apex code and provide you how to get ride of those defects.
It searches the unused variables, empty catch blocks, unnecessary object creation. This tool really help to clean your code in apex as well as in Javascript and visualforce.
https://pmd.github.io/ 

4. Clayton : 




Clayton is a next gen tool which does everything when you need your Salesforce application to be the best. It's very easy to setup and use. 
Clayton integrates into your code repositories and enforces quality and security standards across your organisation, at all times, while your apps are built. It provides you analyses over not only apex but lightning component code as well.
https://www.getclayton.com/ 

5. Code Climate :




 It Automated code review for test coverage, maintainability and more so that you can save time, it provides you real time feedback of your code that help to maintain
 good code as you go. It provides test coverage line by line as well, integrated with your GitHub repo, run analysis locally and team management with permission visibility.

 https://codeclimate.com/