{"id":11166,"date":"2025-07-01T07:14:32","date_gmt":"2025-07-01T07:14:32","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=11166"},"modified":"2025-09-04T06:12:34","modified_gmt":"2025-09-04T06:12:34","slug":"smart-ways-to-successfully-debug-salesforce-flows-with-asynchronous-apex-methods","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2025\/07\/01\/smart-ways-to-successfully-debug-salesforce-flows-with-asynchronous-apex-methods\/","title":{"rendered":"Smart Ways to Debug Salesforce Flows with Asynchronous Apex methods"},"content":{"rendered":"\n<p>Debug Salesforce Flows with Asynchronous Apex is an essential skill for Salesforce admins and developers. While debugging standard Flows is usually straightforward\u2014until asynchronous Apex enters the picture. When you <strong>debug Salesforce Flows with Asynchronous Apex<\/strong> (such as Queueable, @future, or Batch classes), execution shifts to the Apex job queue. This blog will guide you through how to <strong>debug Salesforce Flows with Asynchronous Apex<\/strong> using real-world scenarios, step-by-step instructions, and effective tools.<\/p>\n\n\n\n<p>In this blog, we\u2019ll explore:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A real-world example where a Flow triggers a Queueable Apex class.<\/li>\n\n\n\n<li>Step-by-step guidance on how to effectively debug asynchronous behavior.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\"><strong>Architecture Overview<\/strong><\/mark><\/h2>\n\n\n\n<p>This section covers the system architecture used to <strong>debug Salesforce Flows with Asynchronous Apex<\/strong> components:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A <strong>Record-Triggered Flow<\/strong> runs on the <strong>Account<\/strong> object.<\/li>\n\n\n\n<li>The Flow passes the <strong>Account Id<\/strong> to an <strong>Invocable Apex method<\/strong>.<\/li>\n\n\n\n<li>The method collects the IDs and triggers a <strong>Queueable Apex class<\/strong>.<\/li>\n\n\n\n<li>The Queueable class performs logic (e.g., data retrieval or processing) and logs the outcome.<\/li>\n<\/ul>\n\n\n\n<p>This design is useful when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You want to shift heavy logic from Flow to Apex for performance reasons.<\/li>\n\n\n\n<li>You\u2019re handling long-running operations (e.g., bulk processing, API calls).<\/li>\n\n\n\n<li>You need to trigger everything from a declarative Flow.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Code Overview<\/mark><\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Queueable Apex Class: Handles the main logic asynchronously.<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/1.-queueable-class.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/1.-queueable-class.png\" alt=\"Queueable Class\"><\/a><\/center><font size=\"2\"><center><i> Queueable Class <\/i><\/center><\/font>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Invocable Apex Class: Exposes the Queueable trigger method to Flows.<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/2.-invocable-class.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/2.-invocable-class.png\" alt=\"Invocable Class\"><\/a><\/center><font size=\"2\"><center><i>Invocable Class<\/i><\/center><\/font>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Record-Triggered Flow: Starts the process based on changes to an Account.<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/3.-flow.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/3.-flow.png\" alt=\"Record-Triggered Flow\"><\/a><\/center><font size=\"2\"><center><i> Record-Triggered Flow <\/i><\/center><\/font>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Step by Step Debugging Guide<\/mark><\/strong><\/h2>\n\n\n\n<p>To debug Salesforce Flows with Asynchronous Apex, follow these 5 practical steps:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Enable Debug Logs for the User\n<ul class=\"wp-block-list\">\n<li>Go to <strong>Setup \u2192 Debug Logs<\/strong><\/li>\n\n\n\n<li>Add the user triggering the Flow<\/li>\n\n\n\n<li>Set the following log levels:\n<ul class=\"wp-block-list\">\n<li><strong>Apex Code<\/strong>: FINE<\/li>\n\n\n\n<li><strong>System<\/strong>: DEBUG<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Trigger the Flow\n<ul class=\"wp-block-list\">\n<li>Create or update an <strong>Account record<\/strong><\/li>\n\n\n\n<li>This starts the Flow, which invokes the Apex method<\/li>\n\n\n\n<li>The method enqueues a Queueable job<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Review the Initial Flow Log\n<ul class=\"wp-block-list\">\n<li>Go back to <strong>Debug Logs<\/strong><\/li>\n\n\n\n<li>Open the first log related to the Flow execution<\/li>\n\n\n\n<li>Confirm the Flow successfully called the Invocable Apex method<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/4.-initial-executioninvocable-class.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/4.-initial-executioninvocable-class.png\" alt=\"Initial execution (Invocable Class)\"><\/a><\/center><font size=\"2\"><center><i> Initial execution (Invocable Class) <\/i><\/center><\/font>\n\n\n\n<ol class=\"wp-block-list\" start=\"4\">\n<li>Monitor the Queueable Job\n<ul class=\"wp-block-list\">\n<li>Navigate to <strong>Setup \u2192 Apex Jobs<\/strong><\/li>\n\n\n\n<li>Look for the job with type <strong>Queueable<\/strong><\/li>\n\n\n\n<li>Check its status (e.g., Completed or Failed).<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/5.-Apex-Job.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/5.-Apex-Job.png\" alt=\"Apex Job\"><\/a><\/center><font size=\"2\"><center><i> Apex Job <\/i><\/center><\/font>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Inspect the Queueable Execution Log\n<ul class=\"wp-block-list\">\n<li>Return to <strong>Debug Logs<\/strong><\/li>\n\n\n\n<li>Open the second log corresponding to the Queueable job<\/li>\n\n\n\n<li>Review <code>System.debug()<\/code> outputs to verify execution details<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/6.-Queueable-log.png\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" class=\"size-full\" style=\"border: 1px solid #A9A9A9; padding: 2px; margin: 2px; align: center;\" src=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2025\/06\/6.-Queueable-log.png\" alt=\"Queueable Log\"><\/a><\/center><font size=\"2\"><center><i> Queueable Log <\/i><\/center><\/font>\n\n\n\n<h2 class=\"wp-block-heading\"><strong><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">Conclusion<\/mark><\/strong><\/h2>\n\n\n\n<p>Debugging asynchronous Apex triggered from Flows can feel like chasing ghosts but it doesn\u2019t have to be. With proper debug log setup, Apex job tracking, and structured logs, you can confidently monitor and verify every step of the execution.<\/p>\n\n\n\n<p>By following the above blog instructions, you will be able to learn \u201c<em><strong>How to Debug Salesforce Flows with Asynchronous Apex Methods<\/strong><\/em>\u201d. If you still have queries or any related problems, don\u2019t hesitate to contact us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>. More details about the Product are available on <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/implementation-consulting-partner\/\" data-type=\"link\" data-id=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/integration\/\" target=\"_blank\" rel=\"noreferrer noopener\">our website<\/a> and <a href=\"https:\/\/appexchange.salesforce.com\/listingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce AppExchange<\/a>. <\/p>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. However, if you still have concerns and need more help, please contact us at <a href=\"mailto:salesforce@greytrix.com\" target=\"_blank\" rel=\"noreferrer noopener\">salesforce@greytrix.com<\/a>.<\/p>\n\n\n\n<p style=\"text-align: justify\"><b>About Us<\/b><\/br>\n<p><a href=\"https:\/\/www.greytrix.com\/\">Greytrix<\/a> \u2013 a globally recognized and one of the oldest Sage Development Partner and a Salesforce Product development partner offers a wide variety of integration products and services to the end users as well as to the Partners and Sage PSG across the globe. We offer Consultation, Configuration, Training and support services in out-of-the-box functionality as well as customizations to incorporate custom business rules and functionalities that require apex code incorporation into the Salesforce platform.<br><br> Greytrix has some unique solutions for Cloud CRM such as <a href=\"\">Salesforce Sage integration<\/a> for <a href=\"https:\/\/www.greytrix.com\/sage-x3-erp\/integration\/\">Sage X3<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-100-integration\/\">Sage 100<\/a> and <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/sage-300-integration\/\">Sage 300 (Sage Accpac)<\/a>. We also offer best-in-class Cloud CRM <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Salesforce customization and development services<\/a> along with services such as Salesforce <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/data-migration-support\/\">Data Migration<\/a>, <a href=\"https:\/\/www.greytrix.com\/salesforce-cloud-services\/crm-development\/\">Integrated App development<\/a>, Custom App development and Technical Support business partners and end users. Salesforce Cloud CRM integration offered by Greytrix works with Lightning web components and supports standard opportunity workflow. Greytrix GUMU&#x2122; integration for Sage ERP \u2013 Salesforce is a 5-star rated app listed on <a href=\"https:\/\/appexchange.salesforce.com\/appxListingDetail?listingId=a0N30000000psM5EAI\" target=\"_blank\" rel=\"noopener\">Salesforce AppExchange<\/a>.<br> The GUMU&#x2122; Cloud framework by Greytrix forms the backbone of cloud integrations that are managed in real-time for processing and execution of application programs at the click of a button.<br><br> For more information on our Salesforce products and services, contact us at <a href=\"mailto:salesforce@greytrix.com\">salesforce@greytrix.com<\/a>. We will be glad to assist you.<\/p>\n\n\n\n<p><strong>Related Posts<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/07\/15\/salesforce-flows-vs-apex-triggers-making-the-right-choice-for-your-business-needs\/\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce Flows vs. Apex Triggers: Making the Right Choice for Your Business Needs<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/03\/30\/how-to-call-screen-flow-from-lightning-web-component-in-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to call Screen Flow from Lightning Web Component in Salesforce<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/02\/22\/how-to-use-email-template-in-apex-code\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to Use Email Template in Apex Code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2022\/02\/18\/how-to-send-csv-attachment-in-apex-code\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to send CSV attachment in apex code<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/02\/22\/how-to-use-email-template-in-apex-code\/\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/02\/06\/how-to-invoke-lightning-auto-launched-flow-from-the-apex-class\/\">How to invoke lightning Auto launched<\/a> <a title=\"Permalink to How to Use Email Template in Apex Code\" style=\"margin: 0px; padding: 0px; border: 0px; vertical-align: baseline; outline-style: none; outline-width: initial; color: rgb(68, 68, 68); text-decoration-line: none;\" href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/02\/22\/how-to-use-email-template-in-apex-code\/\" rel=\"bookmark\"><\/a><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2024\/02\/06\/how-to-invoke-lightning-auto-launched-flow-from-the-apex-class\/\">Flow from the Apex class<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Debug Salesforce Flows with Asynchronous Apex is an essential skill for Salesforce admins and developers. While debugging standard Flows is usually straightforward\u2014until asynchronous Apex enters the picture. When you debug Salesforce Flows with Asynchronous Apex (such as Queueable, @future, or Batch classes), execution shifts to the Apex job queue. This blog will guide you through\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2025\/07\/01\/smart-ways-to-successfully-debug-salesforce-flows-with-asynchronous-apex-methods\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[2164,2161,2175,2169,2160,2174,2176,2172,2167,2165,1238,2170,2162,2173,2158,1711,2166,2163,1712,2159,2168,2171],"class_list":["post-11166","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-apex-asynchronous-processing","tag-apex-debug-logs","tag-apex-job-queue-debug-salesforce","tag-apex-logging-in-salesforce","tag-asynchronous-apex","tag-debug-flow-action-class","tag-debug-log-analysis-in-salesforce","tag-debug-queueable-from-flow","tag-debugging-queueable-jobs","tag-flow-apex-best-practices","tag-invocable-apex","tag-invocable-method-logging","tag-invoke-apex-from-flow","tag-monitor-apex-queue","tag-queueable-apex","tag-record-triggered-flow","tag-salesforce-apex-jobs","tag-salesforce-debugging-tips","tag-salesforce-flow","tag-salesforce-flow-apex-integration","tag-salesforce-flow-error-handling","tag-salesforce-queueable-chain"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/11166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/comments?post=11166"}],"version-history":[{"count":17,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/11166\/revisions"}],"predecessor-version":[{"id":11192,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/11166\/revisions\/11192"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=11166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=11166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=11166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}