Skip to main content


How to use Event Logs to debug excessive API requests into your Salesforce instance?

Have you ever received an API usage notification email indicating that you've surpassed 75 percent of the available API call threshold? Or perhaps you've faced a situation where the API limits were entirely exceeded, causing the API to cease functioning, and you were unsure about how to proceed with an investigation? Mulesoft logs didn’t help Something similar happened on my previous project. I promptly contacted our Mulesoft team, who were responsible for integrations, and assigned them the task of examining the logs and dashboards to identify the source of this additional load. After several hours of investigation, I hadn't received any conclusive findings. The response was, "There is no unusual traffic. We don't observe any extra requests being generated by Mulesoft." While the absence of abnormal activities tends to be a good thing, in that case problem was still there, but very well hidden. Event Monitoring Luckily, Salesforce offers a built-in sum
Recent posts

How to Remove a Directory from All Git Commits and Branches

If you work in consultancy, you might encounter a situation where you need to hand over a project repository to a competitor. However, the repository contains some proprietary code that shouldn't have been included in the first place. Is it possible to completely remove a directory from the git history? Let's explore how we can achieve this. Prerequisites The first and most important note is that I was unable to achieve this on Windows . Instead, I had to create a virtual machine with Linux (Ubuntu 22.04) . Git and python3 were preinstalled. Unfortunately, git alone won't suffice. You need to install 'git-filter-repo' , a handy tool for rewriting git history. You can get it from GitHub ( ) or use pip to install it. I went with pip for simplicity. First, install pip : apt install python3-pip Then install git-filter-repo : python3 -m pip install --user git-filter-repo Check if the installation was completed succe

Dynamic Forms on Salesforce Standard Objects

In the latest release Salesforce finally let us to migrate fields and sections from page layout to any place on the record page as individual components. This of course means, that you can set visibility of those fields and sections individually. Unfortunately it all works on Custom Objects only… Or not? Though Dynamic Forms really work just on Custom Objects, I will show you easy workaround for Standard Objects . In the tutorial we will display Shipping Address on Account in the right region aside from the rest of the record. To accomplish this we will use Lightning App Builder to create new Record Page for Contact object and quick action to create custom section layout . For this interesting idea I would like to thank my colleague Emma Peeters , who introduced the workaround on my recent project. Update Account page layout First we will remove the Shipping Address Section from Page Layout on Account Object . Go to Object Manager → Account → Page Layouts → Account L

How to access Record Types in Apex: Apex Record Type Provider

I’ve had a pleasure to watch many Salesforce technical architects trying to find a perfect way, how to work with Record Types in Apex . One created class Global_Constants to store all Record Type Ids and DeveloperNames in static properties, the other queried RecordType table and put the result in the map. I was never impressed so I‘ve come up with Record Type Provider , that allows you to access RecordTypeId like this: RecordTypeProvider.[ObjectName].[RecordTypeName].Id . It’s not perfect, but it definitely has its pros. What doesn’t work First, I would like to stop by the usual solutions and explain, why they do not work (well). Querying the RecordType table is extremely fast – you get all the Record Type descriptions in few miliseconds, but on the other hand you lose what every Salesforce developer must treasure the most – SOQL query . You may think, that you have only limited amount of classes and this one tiny query will never mean anything, but over time logic in your o

How to test Schedulable Batchable

Have you ever thought, how to test scheduled batch ? If your answer is no, because Test.startTest() and Test.stopTest() would do the job for you, you are not entirely right and you may find this article interesting. Clean the mess! For start let's define some "more-or-less" real life scenario for those, who want to follow in their orgs. We have a custom object Log ( API Name: Log__c , Name Type: Auto Number ), that we use to log exceptions, integrations and some other events worth saving. Custom object has several fields containing information like error message and stack trace, but it is not really important for our purpose. Unfortunately our predecessors (or anyone else we can easily blame) didn’t do their work properly creating immense number of bugs in the system and our object is overloaded with logged exceptions and takes too much of the storage. Fixing all the bugs in the system will take months, so we need to take care of the storage first. Our 2 000 hard-wo

Field Level Security in Apex: WITH SECURITY_ENFORCED vs. Security.stripInaccessible

Every time your users access Lightning (web) component or Visualforce page the background Apex code is being run in user context. What does it mean? If there's with sharing keyword on your class definition or you are inheriting with sharing from another class, sharing rules are enforced. In other words SOQL query will return only records, that are visible for current user. And that's great, this is one security concern less. However object level security and field level security permissions are not respected , therefore results of database queries will contain fields, that current user doesn't have access to. There are 3 different ways, how to ensure your user will not see, what he's not supposed to see. WITH SECURITY_ENFORCED clause on SOQL queries Security class and its method stripInaccessible DescribeFieldResult class and its method isAccessible Let's inspect them one by one. Let's get our playground ready First, we need to get our laboratory rea

Apex switch statement under the microscope

It is almost 18 months since Salesforce finally introduced one of the most eagerly anticipated features for Apex - switch statement . Does it even make sense to comment it today? I can only guess it was because of general familiarity with the switch statement , good documentation or simply happiness over surprising birth of a son you stopped dreaming about years ago, but no one has ever questioned it ! Why do we love switch statements ? We've had switch statements in other programming languages since the dawn of time and if not, it was definitely long before I was born. Therefore reasons to use switch statements over if and if else statements are also clear and kind of indisputable. It is preferable to use switch , if you can agree with following statements in your programming language and of course specific situation you are in: Code is easier to read and therefore it is easier to understand and maintain Code is easier to debug Code is faster to execute

About author

My photo
Jan Binder
Experienced Salesforce Technical Architect and Team Lead with a proven track record of delivering successful enterprise projects for major global companies across diverse industries, including automotive, oil & gas, and construction.