Posts

Location-Based SOQL Queries in Salesforce

In Salesforce, location-based SOQL queries allow you to retrieve records based on their geographic location. This feature is particularly useful for applications that require proximity-based searches or location-aware functionality. Location-based SOQL queries leverage the Salesforce Object Query Language (SOQL) along with the geolocation fields available in custom objects or standard objects like Account, Contact, and Lead. Location-Based SOQL Query Considerations Location-based queries are supported in SOQL in Apex and in the SOAP and REST APIs. Keep in mind these considerations. DISTANCE and GEOLOCATION are supported in WHERE and ORDER BY clauses in SOQL, but not in GROUP BY. DISTANCE is supported in SELECT clauses. DISTANCE supports only the logical operators > and <, returning values within (<) or beyond (>) a specified radius. When using the GEOLOCATION function in SOQL queries, the geolocation field must precede the latitude and longitude coordinates. For example, D...

Custom Favicon on your Experience Cloud Site or Force.com Site

Image
About Favicons: The icon displayed on the browser's address bar/ tab or when the page is bookmarked is called the favicon. Resources to be used as a favicon (favorite icon) has to be 16x16 in size and of .ico format.  There are multiple ways of specifying a favicon for a website and the standards are listed here: 1. Use of a rel attribute value defined in a profile 2. Putting the favicon at a predefined URI on the root path. Favicon requests are sent by the browser and how it resolves to any of the methods above is specified here: QUOTE : "If links for both PNG and ICO favicons are present, PNG-favicon-compatible browsers select which format and size to use as follows. Firefox and Safari will use the favicon that comes last. Chrome for Mac will use whichever favicon is ICO formatted, otherwise the 32×32 favicon. Chrome for Windows will use the favicon that comes first if it is 16×16, otherwise the ICO. If none of the aforementioned options are available, both Chromes will use ...

User and System Mode in Salesforce

User Mode: When an Apex class executes in user mode, it runs with the permissions and privileges of the current user who initiated the operation, also known as the executing user. In user mode, Apex code adheres to the organization's sharing rules, field-level security (FLS), and other user-specific permissions and settings. The visibility and access to records and data are determined by the security settings and permissions assigned to the executing user, including their role, profile, permission sets, and sharing settings. User mode is typical for most Apex transactions, such as trigger execution, Visualforce controller methods, and custom Apex code invoked by users through the Salesforce UI or API. System Mode: When an Apex class executes in system mode, it runs with elevated permissions and bypasses the organization's sharing rules, FLS, and other user-specific permissions. In system mode, Apex code can perform operations that are not available to the executing user, such a...

Conditionally render fields on Visualforce page based on picklist values

 An example of how to render a Visualforce page based on criteria. <apex:pageBlock id="xxxpb1"> <apex:pageBlockSection>                      <apex:actionRegion >                  <apex:inputField id="xxxif1" value="{!Object.picklistfieldapiname1}" required="true" >      <apex:actionSupport event="onchange" rerender="xxxpb1" />   </apex:inputField> </apex:actionRegion>                   </apex:pageBlockSection>                 <apex:pageBlockSection id="xxxpbs1" rendered="true">  <apex:inputField id="xxxif2" value="{!Object.Fieldtobedisplayed1}" rendered="{!IF(Object.picklistfieldapiname1 ='picklist value 1' || lead.Buyer_Type__c ='picklist value 2' ,true,false)}"/> </apex:pageBlockSection> <apex:pageBlockSec...

Salesforce Security Best Practises

Recommended Security Best Practices Implementing security best practices in Salesforce is crucial to protect sensitive data, maintain compliance with regulations, and safeguard your organization's reputation. Salesforce Security Multi-factor authentication (MFA) MFA is a secure method of authentication where users must provide multiple pieces of evidence to log in. It can include a combination of username/password, security keys, or authentication apps. These apps generate unique codes for added security. Mobile devices can also use biometric authentication like fingerprint scans or facial recognition. Implement precise access control using profiles and permission sets Using profiles and permission sets in Salesforce is essential for implementing security controls to ensure that users have appropriate access to data and functionality within the system. Profiles: Control access to objects by assigning appropriate object-level permissions to profiles. You can specify whether users ca...

Audience Targeting in Experience Cloud (Aura Site)

Image
Audience targeting in Experience Cloud (formerly known as Community Cloud) allows you to personalize the content and user experience for different groups of users based on their characteristics, behaviors, or attributes. This functionality enables you to create tailored experiences for specific audiences, improving engagement, satisfaction, and conversion rates. Audiences are sets of criteria used to define community member segments. Use them to keep your community members engaged by offering them personalized, relevant content in a customized community. Say that a company offers a product that is different in different regions. Rather than creating different communities, the community manager could simply create different experiences in the same community. Using Experience Builder, the community manager can apply sets of criteria to pages, components, branding sets, CMS collections, navigation menus, or tile menus. What members see varies depending on their location. The criteria incl...

Obtain the name of the SObject from a given record ID

In Apex, you can obtain the name of the SObject from a given record ID using the getSObjectType () method provided by the Id class. Example Id recordId = '001XXXXXXXXXXXX'; // Replace this with the actual record ID // Get the SObject type from the record ID Schema.SObjectType sObjectType = recordId.getSObjectType(); // Get the name of the SObject String sObjectName = sObjectType.getDescribe().getName(); System.debug('SObject Name: ' + sObjectName); In this example: recordId.getSObjectType() returns the Schema.SObjectType of the object associated with the record ID. sObjectType.getDescribe().getName() retrieves the name of the SObject. This approach allows you to dynamically determine the SObject name from a record ID in your Apex code.