Posts

Salesforce Sandboxes

Image
Sandboxes create copies of your Salesforce org in separate environments. Use them for development, testing, and training, without compromising the data and applications in your production org.  Sandboxes: Staging Environments for Customizing and Testing Sandboxes are isolated from your production org, so operations that you perform in your sandboxes don’t affect your production org. Sandbox Types Developer Sandbox – A Developer sandbox is intended for development and testing in an isolated environment. A Developer Sandbox includes a copy of your production org’s configuration (metadata). Developer Pro Sandbox – A Developer Pro sandbox is intended for development and testing in an isolated environment and can host larger data sets than a Developer sandbox. A Developer Pro sandbox includes a copy of your production org’s configuration (metadata). Use a Developer Pro sandbox to handle more development and quality assurance tasks and for integration testing or user training. Partial ...

Sitemap in Salesforce (Experience Cloud)

Image
A sitemap typically refers to a navigational structure or hierarchy that defines the layout and organization of pages within a Community (Experience Cloud). It provides a roadmap for users to navigate through the various pages and components of the application, ensuring a cohesive and intuitive user experience.  Make it easy for guest users to find new products in web searches. After you perform an incremental update to your sitemap, third-party search index crawlers can find newly added, publicly available products. New products are picked up in manual and scheduled incremental updates to your sitemap. Where : This feature is available in Lightning Experience, in Enterprise, Performance, Unlimited, and Developer editions. How : To manually update your store sitemap, make your store available to the public in Experience Builder | Settings | General, and select Public can access the site. Then open the SEO tab, and click Generate Sitemap. SEO ' sitemap.xml ' feature is not autom...

Retrieve Guest User IP Address with VF Page

Image
The two standard objects:  AuthSession ,  LoginGeo don’t store the login information of a Guest User. Using a VF Page  <apex:page showHeader="false" sidebar="false" controller="userIPAddressController"  action="{!getUserIPAddress}">  <script>     setTimeout(function(){         var message = '{!ip}';         parent.postMessage(message, window.top.location.origin);               }, 3000);  </script>  <apex:form >      {!ip}  </apex:form> </apex:page> Controller public class userIPAddressController{     public string ip {get;set;}     public pageReference getUserIPAddress() {                  // True-Client-IP has the value when the request is coming via the caching integration.         ip = ApexPages.currentPage().getHeaders()...

Retrieve IP Address of a Community User

Image
For a variety of purposes, including displaying items, sending texts, and other security-related tasks, tracing IP addresses is necessary. Logged in User IP Address Getting IP Address for logged in user is relatively simple as Salesforce stores this information in two standard objects:  AuthSession ,  LoginGeo . List<AuthSession> auth = [SELECT Id , IsCurrent, SessionType, CreatedDate, LoginGeoId, NumSecondsValid FROM AuthSession WHERE UsersId =: Userinfo.getUserID()]; if(auth.isEmpty() == false && auth[0].IsCurrent ){ system.debug('yes, it is current user session'); }else{ system.debug('No, it is not current user session'); } List<LoginGeo> lg = [SELECT Id,City, Country, PostalCode, Subdivision, Latitude, Longitude,LoginTime FROM LoginGeo WHERE Id =: auth[0].LoginGeoId]; Alternatively, you can use  Auth.SessionManagement  Class as well as below: Auth.SessionManagement.getCurrentSession().get('LoginGeoId'); getCurrentSession() re...

Salesforce Locker Service

Salesforce Locker Service is a security architecture provided by Salesforce for Lightning components. It aims to improve the security of the Lightning Component Framework by enforcing stricter JavaScript security policies and DOM access restrictions. Locker Service enhances the security and stability of Lightning components Enabling Locker Service Provides the following features Namespace Isolation : Locker Service isolates Lightning components in their own namespace, preventing them from accessing or modifying components in other namespaces. This isolation helps prevent conflicts and ensures that components behave predictably. Secure DOM Access : Locker Service provides a secure wrapper around the Document Object Model (DOM), preventing Lightning components from accessing or modifying elements outside of their own DOM hierarchy. This helps mitigate security vulnerabilities such as cross-site scripting (XSS) attacks. Strict JavaScript Context: Locker Service enforces strict JavaScript...

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 ...