Posts

Showing posts from 2020

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.

The Translation Workbench in Salesforce

Image
Use Translation Workbench to maintain translated values for metadata and data labels in your Salesforce org. Specify languages for translation and assign translators for each language. Manage translated values for any Salesforce supported language. Translators can maintain translations directly through the workbench, or you can export translation files for bulk translation imports. This feature is particularly useful for organizations operating in multilingual environments or serving diverse customer bases. The Translation Workbench is a valuable tool for creating a localized experience for users in different regions and language preferences within Salesforce. By translating objects, fields, and metadata, you can improve user adoption and provide a more inclusive experience for your users worldwide. Enable Translation Workbench Translation Considerations Steps to Enable Translation Workbench and Add Languages Salesforce Additional Features to Translate Field Labels, Values, and Many m...

Email Services in Salesforce

Image
Email Services in Salesforce allow you to automate the processing of inbound emails. You can define an email service that listens for incoming emails, processes them according to your logic, and then takes appropriate actions like creating records, updating records, or triggering workflows What Are Email Services? To use email services, from Setup, enter Email Services in the Quick Find box, then select Email Services. Here are some of the considerations An email service only processes messages it receives at one of its addresses. Salesforce limits the total number of messages that all email services combined, including On-Demand Email-to-Case, can process daily. Messages that exceed this limit are bounced, discarded, or queued for processing the next day, depending on how you configure the failure response settings for each email service. Salesforce calculates the limit by multiplying the number of user licenses by 1,000; maximum of 1,000,000. For example, if you have 10 licenses, you...

Basic overview of Apex classes, variables, constructors, and methods in Salesforce

Apex is a strongly-typed, object-oriented programming language that allows developers to write custom business logic and perform complex operations on Salesforce data. Let's go through the basic components of an Apex class, including variables, constructors, and methods. Apex Class: An Apex class is a blueprint for creating objects in Salesforce. It defines the structure and behavior of objects by encapsulating data and methods.  Here's a simple example of an Apex class: public class MyClass {     // Variables     public String name;     public Integer age;          // Constructor     public MyClass(String n, Integer a) {         name = n;         age = a;     }          // Method     public void displayInfo() {         System.debug('Name: ' + name);         System.debug('Age: ' + age);   ...

Lead mapping in Salesforce

Image
Salesforce lead conversion converts leads into Accounts, Contacts, and Opportunities when they are recognized as qualified sales prospects. Lead Conversion Field Mapping Map Custom Lead Fields for Lead Conversion Point to Note -If you have more than 500 lead fields, the lead field mapping page can become unresponsive.

Custom Settings and Custom Metadata in Salesforce

Image
Custom Settings Custom settings are like custom objects that allow app developers to create custom sets of data for an organization, profile, or user. This data is cached for easy access and can be used in formula fields, validation rules, flows, Apex, and SOAP API. It saves the expense of redundant database queries. Note - All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. However, querying custom settings data using Standard Object Query Language (SOQL) doesn't use the application cache and is similar to querying a custom object. To benefit from caching, use other methods for accessing custom settings data such as the Apex Custom Settings methods. Code Snippet - List< Application_Configuration__c > mcs = Application_Configuration__c.getall().values(); boolean execute = false; if (mcs[0].Type__c == 'Cloud') {   execute = true; } Application_Configuration__c myCS1 = Appl...