Posts

Making an HTTP callout after rolling back DML Operations

You can now make an HTTP callout after rolling back DML operations by releasing savepoints with Database.releaseSavepoint. The introduction of the Database.releaseSavepoint method in Salesforce Apex is a significant development because traditionally, once you rolled back a transaction to a savepoint, you couldn't make any future DML operations or callouts in that transaction. This limitation poses a challenge in complex transactional scenarios where you may need to perform a callout after a conditional rollback. Here's an example of how Database.releaseSavepoint can be used: Savepoint sp = Database.setSavepoint(); try  {  // Perform DML operations  Account a = new Account(Name='Test');  insert a; // ... some logic that may fail } catch (Exception ex) {  // Exception handling if needed  Database.rollback(sp);  Database.releaseSavepoint(sp); // Also releases any savepoints created after 'sp' // Since savepoint is released, you can now make a callout Ht...

Randomly Generated Universally Unique Identifier (UUID)

Salesforce is a platform that keeps improving by introducing new features, and one such feature is the ability to generate UUIDs in Apex, which was introduced in the Spring 24 Release. With this new functionality, developers can create unique identifiers for records and objects within their Salesforce organization without needing external libraries or custom code. This feature allows developers to save time and effort while ensuring the uniqueness of identifiers UUID Class and Usage The UUID Class offers various methods to perform operations like generating a version 4 universally unique identifier (UUID), comparing UUIDs, and converting UUID instances to a string. The generation of UUID is done using a cryptographically strong pseudo-random number generator, and the UUID is represented as 32 hexadecimal values. Here's a brief overview of each method: equals(obj): Compares a UUID instance with the specified object. fromString(str): String representation of a UUID to a UUID instance...

Joined the Salesforce B2B Commerce Cloud Partner Advisory Board.

Image
I am happy to join the Salesforce B2B Commerce Cloud Partner Advisory Board. As a member of this board, I will have the opportunity to discuss B2B Commerce Cloud product features, industry vision, and the future of the partner program with Salesforce executives. This advisory board will provide a forum for partners to share information and insights with Salesforce regarding trends and uncover opportunities in the Commerce Cloud market. This board's contributions will help keep the programs and products we offer to our customers relevant and align with Salesforce's core values of trust, customer success, innovation, equality, and sustainability. Salesforce B2B Commerce Cloud Partner Advisory Board. Had a great time at the New York Salesforce Commerce Partner Advisory Board meeting. I enjoyed one-on-one meetings with the Salesforce team, sharing field experience and feedback, and being at the top of my mind. Grateful for the opportunity to collaborate with industry leaders and ex...

Use of Null Coalescing Operator

Image
Null Coalescing Operator The new null coalescing operator (??) simplifies code with verbose null checks.  For example - Old Ways -  Example 1 -  Integer anInteger; // Assume this is passed as parameter and can be NULL  Integer notNullReturnValue; if (anInteger != null){   notNullReturnValue = anInteger; } else {   notNullReturnValue = 100; } Example 2 -  Integer notNullReturnValue = (anInteger != null) ? anInteger : 100; New Way (Null Coalescing Operator) - Integer anInteger; // Assume this is passed as parameter and can be NULL  Integer notNullReturnValue = anInteger ?? 100; Note : nullish coalescing operator (??) is also part of modern JavaScript APIs. You can also use them in your Lightning Web Components (LWCs) to simplify null checks. When using the null coalescing operator, always remember operator precedence. In some cases, using parentheses is necessary to obtain the desired results. For example, the expression top ?? 100 - bottom ?? 0 e...

Salesforce Lightning Design Systems

Salesforce Lightning Design Systems Lightning Design System  Salesforce Lightning Design System (SLDS) is a set of tools and guidelines provided by Salesforce for building user interfaces consistent with the Salesforce Lightning Experience. Benefits include efficiency, scalability, interoperability with the larger Salesforce ecosystem, and consistent design. Let’s just make sure we follow Salesforce Lightning Design Guidelines, Principles, and Best Practice  Here are a few links - Salesforce Figma UI Kit (Unleash the power of the SLDS UI Kit in Figma.) - Salesforce (@salesforce) on Figma Community   Lightning Web Components (View web component JavaScript, HTML, and CSS code, then preview the output.) - Components - Salesforce Lightning Component Library   Design System Starter Kit (Run prototypes of all sizes in the browser using SLDS.) - GitHub - salesforce-ux/design-system-starter-kit: Rapid prototyping environment using the Salesforce Lightning Design System...

Nebula Logger for Salesforce

Nebula Logger for Salesforce is a logging and monitoring solution specifically designed for Salesforce applications. It provides developers and administrators with enhanced visibility into the behavior, performance, and usage of Salesforce components and processes.  Nebula Logger is built natively on Salesforce, using Apex, lightning components, and various types of objects. There are no required external dependencies Unleash the Power of Advanced Logging with Nebula Logger | Dreamforce 2023 Why Nebula Logger Unleash the power of Advanced Logging Nebula Logger is an open-source framework developed by Jonathan Gillespie. It allows for considerably more robust debugging & error logging. It offers a neat solution to gather all the scattered data into one organised space. Helps link batch job logs together, aura and LWC logs together, and retain your debug logs for longer. Out-of-the-Box Salesforce Debugger Limitations Only Apex can directly add debug statements - in Flow and ...

Find Case ThreadId using Apex and Formulas

Ensure that an email sent to your customer support email is attached to an existing case using Thread ID. Formula - "ref:_" & LEFT($Organization.Id,5) & RIGHT($Organization.Id,5) & "._" & LEFT(Id,5) & SUBSTITUTE(Left(RIGHT(Id,10), 5), "0", "") & RIGHT(Id,5) & ":ref" Apex -  ref:_'+ UserInfo.getOrganizationId().left(5) + UserInfo.getOrganizationId().mid(11,4) + '._'+ caseId.left(5)+ caseId.mid(10,5) + ':ref ]'; The actual extraction of the thread ID is looking for anything in between "ref:" and ":ref" Example of a thread id: ref:_00D30oKPx._50030bwIii:ref Note: If multiple thread IDs are included in the header or the body of the email sent, the email will attach to the Case that is represented by the first thread ID in the string: Example  [ ref:_00D30oKPx._50030bwIii:ref ] [ ref:_00D30oKPx._50030bMuaN:ref ]  the email will attach to the case represented by ref:_00D30oKP...