Skip to main content

Posts

URL Redirect in Experience Site | SF Fact #07

  Salesforce Sites URL Redirects To ensure search engines and users can find pages after moving or reorganizing them on your Salesforce Site, set up site URL redirects. This helps communicate the new page locations effectively. Keep the following points in mind when implementing these redirects: You cannot redirect error pages or CSS files (files ending in .css). You can create up to 6,000 redirect rules across all sites. Query parameters in site URL redirects must match exactly. URLs containing the lastMod parameter cannot be redirected. URL rewriting on your site will be applied after any site page redirects. To redirect the home page of an Experience Cloud site to its corresponding Site.com home page, set the Source URL to / , which indicates the home page of the Experience Cloud site. Set the Target URL to s , which indicates the home page of the Site.com site. Steps: 1) Go To Setup, in quick find box search 'All Site'. Please find the screenshot below. 2) Select the site, ...

Capture Real time data using CDC(Change Data Capture) in Salesforce | SF Fact #05

Change Data Capture (CDC) enables receiving near-real-time updates for Salesforce records and synchronizing them with an external data store. CDC publishes change events that reflect modifications to Salesforce records, including new records, updates, deletions, and undeletions. These events can be subscribed to in a Lightning Web Component (LWC) using the Emp API. To meet the business requirement of creating a task whenever a user manually changes an opportunity's status to "Closed Won," use CDC events and a generic LWC on the opportunity record page. This solution avoids the need for Apex triggers or record-triggered flows. How to enable CDC? Go to setup Search Change Data Capture Add Entities The  lightning/empApi  module provides access to methods for subscribing to a streaming channel and listening to event messages. All streaming channels are supported, including channels for platform events, PushTopic events, generic events, and Change Data Capture events. This co...

SF Fact #03 | Undelete Failed, Entity is not in recycle bin

  Similar to ENTITY_IS_DELETED error, if we attempt to undelete a record from recycle bin by mistake which has already been hard deleted, the following error is encountered: UNDELETE_FAILED. When a record is deleted, it moves to the Recycle Bin. This is known as "soft deletion," allowing the record to be easily restored through the user interface. However, under certain conditions, a deleted record will no longer appear in the Recycle Bin: Master-Detail Relationship (Child Deleted First): If a record is a child or detail in a master-detail relationship and it is deleted before its parent record, then after the parent is deleted, the child record transitions to a "hard deleted" status. In this state, the child record cannot be recovered through the Recycle Bin and must be recreated if needed. Master-Detail Relationship (Parent Deleted): If a record is a child or detail in a master-detail relationship and the parent record is deleted, the child record is also soft del...

SF Fact #02 | Database.querywithBinds() usage

  Dynamic SOQL refers to constructing a SOQL query string at runtime using Apex code. This approach allows for more flexible applications. For example, you can create a search based on user input or update records with different field names. Creating Dynamic SOQL Queries To create a dynamic SOQL query at runtime, use the Database.query or Database.queryWithBinds methods in the following ways: Single Record Query : sObject s = Database.query(string); Multiple Records Query : List<sObject> sobjList = Database.query(string); Query with Bind Variables : List<sObject> sobjList = Database.queryWithBinds(string, bindVariablesMap, accessLevel); These methods can be used wherever inline SOQL queries are used, such as in assignment statements and for loops, and are processed similarly to static SOQL queries. API Version 55.0 and Later: User Mode for Database Operations With API version 55.0 and later, the accessLevel parameter allows running the query in user or system mode:...

SF Facts #01 | system.typeexception: unsupported sobject type and/or version

  Error Encountered While Accessing Custom Metadata Records Using Built-in Methods: Error Message: system.TypeException: Unsupported sObject type and/or version Cause: This error occurs because the metadata type methods were introduced in API version 51. If your Apex class is using an API version lower than 51, it will not support these methods. Solution: To resolve this issue, update the API version of your Apex class to version 51 or higher. By updating the API version, you ensure that your Apex class can utilize the built-in methods for accessing custom metadata records without encountering the unsupported sObject type and/or ersion  error. Feel free to share your view and comments.

How to get related records without using Apex?

getRelatedListRecords You can utilize this wire adapter to access RelatedList records. Related lists present information and links to records linked with a particular record. For instance, an account might have related lists for contacts, cases, notes, or files. Demo Code: import  {  LightningElement , wire, api }  from   'lwc' ; import  { getRelatedListRecords }  from   'lightning/uiRelatedListApi' ; export   default   class   Acc   extends   LightningElement  {     error;   records;       @ wire(getRelatedListRecords, {     parentRecordId:  '0015g00000DMcjgAAD' ,     relatedListId:  'Contacts' ,     fields: [ 'Contact.Name' , 'Contact.Id' ],     sortBy: [ 'Contact.Name' ]   })   listInfo({ error, data })...

Determine the execution context in apex

      The Quiddity Enum stands out as a highly valuable but often overlooked feature, offering one of the most effective means to grasp the context of Apex execution. Leveraging Quiddity allows us to discern whether an Apex method is invoked from Lightning Web Components (LWC), Aura, or an Anonymous context. Explore the comprehensive documentation linked below to discover the full range of contexts supported by Quiddity. Below is the Example of Quiddity. public List<Account> getAccountsWithQuiddityGuard () {       List<Account> accounts = new List<Account>();               public static List<Quiddity> allowedQuiddities = new List<Quiddity>{              Quiddity.QUEUEABLE,              Quiddity.BATCH_APEX,      ...