Category: Salesforce

  • The “Evolution or Extinction?”

    My Salesforce Toolkit: A 2018 vs. 2026 Reality Check

    Waking up today after a coma since 2018 makes your Salesforce blog a historical artifact. I looked back at my old posts. I realized my “modern” toolkit from back then belongs in a museum. Here is how the world changed while we were busy debugging.

    1. The “Flow-pocalypse”

    Back in 2018, we used Process Builder. It looked like a friendly flowchart but secretly loved hitting CPU limits. Today, Salesforce sent Process Builder and Workflow Rules to a farm upstate. Flow is the undisputed heavyweight champion now. It handles tasks that once required 200 lines of Apex. Become a “Flownatic” now, or the platform will leave you behind.

    2. Aura vs. LWC: The Breakup

    Remember Aura? The framework made you feel like you were writing code in a dark room wearing oven mitts. Lightning Web Components (LWC) finally showed up and brought modern JavaScript with it. We went from asking “Why is this so slow?” to realizing it works like the rest of the internet.

    3. Change Sets: The Final Boss

    In 2018, “Deployment” meant clicking through a 500-item list. We prayed to the gods that we didn’t forget a single Permission Set. Today, you must use SFDX, VS Code, and DevOps Center. Anything else is essentially tech-support penance. We traded “Refresh and Pray” for “Commit and Deploy,” and my blood pressure is much lower.

    4. From “What’s an API?” to “Everything is an API”

    We used to treat integrations like scary special projects. Now, MuleSoft is baked in, and Data Cloud ingests every data byte. The “siloed” Salesforce org is a myth. You are no longer just a Salesforce dev. You are a data plumber wrangling a firehose.

    5. AI (The Buzzword that Ate the World)

    In 2018, “Einstein” was mostly cute icons and some predictive lead scoring we occasionally trusted. Now, you need Agentforce or an AI assistant writing your unit tests. Otherwise, are you even working? We moved from “The computer might help” to “The computer will write the boilerplate first.”

    The Verdict:

    The 2018 toolkit was a Swiss Army knife with rusted blades. The 2026 version is a lightsaber. It is way more powerful. Just try not to cut your own arm off.

  • How to start debugging an issue in Salesforce

    Step 1: Check logs

     Debug logsAudit Trails
    RecordsRecords automated actions and results generated by end user or codeTracks configuration changes by Salesforce user in the Org
    ExampleApex trigger actions, workflow, validation rulesCreate/updates happened on workflows, validation rule, sharing rules, classes etc

    Debug Logs: Will provide you information what actions are getting performed and in which order

    Audit Trails: Helpful to find out it some newly made org changes has broken the functionality

    Step 2: System Debugs

    Debug log recording in Setup is turned on for your User via: Setup > Monitoring > Debug Logs. See here for more information.

    I would place temporary debug statements such as

    System.Debug('>>>> the value of x is ' + x);

    within my code to make sure that the code is executing the way I think its working. Individual SObjects, Maps of SObjects and Lists of SObjects can all be appended and that shows you all populated SObject fields.

    The >>>> is a unique string that usually doesn’t appear anywhere else in the log files. This allows me to quickly find my debug output. (Logs are truncated after 2M bytes of output – there are workarounds for this.)

    Step 3: Use the Developer Console

    The Developer Console is a great tool for debugging. You do the following things (and more) with the developer console

    • View Logs – This is another way of viewing debug outputs.
    • Execute SOQL –  This can be used to verify that the SOQL in your code is returning the correct information
    • Execute Anonymous – Apex code can be run directly from the dev console

    Log Lines

    Log lines are included in units of code and indicate which code or rules are being executed. Log lines can also be messages written to the debug log. For example:

    Log lines are made up of a set of fields, delimited by a pipe (|).

    The format is:

    · timestamp: Consists of the time when the event occurred and a value between parentheses. The time is in the user’s time zone and in the format HH:mm:ss.SSS. The value in parentheses represents the time elapsed in nanoseconds since the start of the request. The elapsed time value is excluded from logs reviewed in the Developer Console when you use the Execution Log view. However, you can see the elapsed time when you use the Raw Log view. To open the Raw

    Log view, from the Developer Console’s Logs tab, right-click the name of a log and select Open Raw Log.

    · event identifier: Specifies the event that triggered the debug log entry (such as SAVEPOINT_RESET or VALIDATION_RULE). Also includes any additional information logged with that event, such as the method name or the line and character number where the code was executed.

    Events:
    
    · EXECUTION_STARTED
    
    · EXECUTION_FINISHED
    
    · CODE_UNIT_STARTED
    
    · CODE_UNIT_FINISHED
    
    · METHOD_ENTRY
    
    · METHOD_EXIT
    
    · CONSTRUCTOR_ENTRY
    
    · CONSTRUCTOR_EXIT
    
    · SOQL_EXECUTE_BEGIN
    
    · SOQL_EXECUTE_END
    
    · SOSL_EXECUTE_BEGIN
    
    · SOSL_EXECUTE_END
    
    · CALLOUT_REQUEST
    
    · CALLOUT_RESPONSE
    
    · FATAL_ERROR

    Step 4: Explain like I’m five

    Simplest meaning of it is “Explain a complicated subject in a way five years old can understand.” Try to explain your code stepwise to yourself or someone else(Dry Run). A lot of the time you figure out the problem when you are explaining the code to someone else. (If exceptions are involved, take a look at your code at the line numbers reported and consider what could have generated the exception.)

    Step 5: Create a Unit Test

    A unit test is a great way to figure out what is going on with a piece of code. It allows you to:

    • Execute your code in an environment with no other data
    • Create test data that you can use over and over again.
    • Use asserts to check your code
    e.g. System.assert(contacts.size() > 0);
         System.assertEquals(expectedX, actualX);

    Step 6: Take a break

    Sometimes taking a break helps to refresh your mind. It allows you to see the problem from a different angle. This has really helped in most of the time. If you don’t think you have enough time to take very short breaks, you’re probably spending a lot of time on unproductive tasks. It’s important to take a step back and ask “Am I doing working in correct direction?”

    Step 7: Ask for help

    If you have done all the steps above and reached this point then you most likely need help. This is where a colleague or stack exchange come in. When asking a question, clearly state your problem. Provide enough information to make it understandable to others. If you provide a code sample, ensure it is well formatted.

  • Eclipse/Class save error – This Apex class has batch or future jobs pending or in progress

    I was constantly getting an error “This Apex class has batch or future jobs pending or in progress” whenever I was saving Apex class written for batch Apex. This was happening in the developer org where we develop a test managed package for the AppExchange product. There was no way I can throw out this org and start with a new one.

    For debugging started with following steps:

    1. Check Schedule Jobs – No schedule jobs (If any are running and related to your class somehow you can just delete the schedule job)
    2. Check Apex jobs – No Apex is job is running or in Queued state. (If are running you could just click “Abort”)
    3. Google – Found some known issue and checked workarounds which were of nouse.

    As nothing worked logged a case through Salesforce Partner portal as job needed to be deleted from the backend. But case got categorized as a developer support case. Not having the premium support it Case got closed 😐

     

    Then started research –

    • Tried deleting all running schedule jobs through Apex in case any is stuck in the background and not visible on UI.

    https://gist.github.com/prasannadeshpande/4fea1278051f169e4bf8f5b1a437a24d

    No Luck!! 🙁

    • Making query on the AsyncApexJob object – SELECT Id, Status, JobItemsProcessed, TotalJobItems, ParentJobId, NumberOfErrors FROM AsyncApexJob Where Status = 'Queued' et voila!! returns the job stuck in Queued status which was not visible through UI. I thought my job is over I will just copy Id from the query result and execute “System.abortJob(jobid);” But that didn’t work. It needs a ParentJobId which was missing from this entry. – No Luck 🙁
    • Then came across a tiny line in the Salesforce Article. If you want to abort a job using Job Id use API version 32.0 or earlier. Login to workbench using v32.0 and from “Execute anonymous” execute System.abortjob(). This time it worked… Finally!!! 🙂