{"id":6109,"date":"2021-03-17T08:51:32","date_gmt":"2021-03-17T08:51:32","guid":{"rendered":"https:\/\/www.greytrix.com\/blogs\/salesforce\/?p=6109"},"modified":"2021-03-17T08:51:34","modified_gmt":"2021-03-17T08:51:34","slug":"how-to-debug-in-lightning-using-developer-console-api","status":"publish","type":"post","link":"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/03\/17\/how-to-debug-in-lightning-using-developer-console-api\/","title":{"rendered":"How to debug in lightning using developer console API"},"content":{"rendered":"\n<p>A major part of any Salesforce developer\u2019s job is debugging. Because Salesforce has a multitenant architecture, debugging on the platform is a bit different than it might be in other development environments. Commonly we use <strong><em>console.log()<\/em><\/strong> method to log on the console screen, but console provides wide range of methods which we helps to debugging efficiently. So in this blog we will see how to debug in lightning developer console using various methods.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Assert ()<\/strong>: Assert needs no introduction. It accepts two arguments and if the first argument is false, it will display the message you put as the second argument.<\/li><\/ul>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<pre class=\"wp-block-code\"><code>var flag = false;\nconsole.assert(flag, \"Something is wrong\");<\/code><\/pre>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<p>Result: &#8220;Something is wrong&#8221; will be displayed on the console screen.<\/p>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<ul class=\"wp-block-list\"><li><strong>Clear (): <\/strong>Clears the console screen.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>console.clear();<\/code><\/pre>\n<\/div><\/div>\n<\/div><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Error ()<\/strong>: Logs error on the screen. It shows the message in the form of error.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>console.error(\"Something wrong has happened\");<\/code><\/pre>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/03\/1.Console-Error.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\/2021\/03\/1.Console-Error.png\" alt=\"Console Error\"><\/a><\/center>\n<font size=\"2\"><center><i>Console Error<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Info (): <\/strong>It outputs an informational message to the console.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>console.info(\"Step 1 is missed\");<\/code><\/pre>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/03\/2.Console-Info.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\/2021\/03\/2.Console-Info.png\" alt=\"Console Info\"><\/a><\/center>\n<font size=\"2\"><center><i>Console Info<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Warn ()<\/strong>: Just like the info method, it shows a warning message on console.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>console.warn(\"Warning message\");<\/code><\/pre>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/03\/3.Console-warning.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\/2021\/03\/3.Console-warning.png\" alt=\"Console warning\"><\/a><\/center>\n<font size=\"2\"><center><i>Console warning<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Table ():<\/strong> It shows data in the console in a tabular format. It is useful when data is in arrays or objects.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>var arr = &#91;&#91;\"Name\", \"Michael\"], &#91;\"Designation\", \"SFDC Developer\"], &#91;\"City\", \"Mumbai\"]];\r\nconsole.table(arr);<\/code><\/pre>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/03\/4.Console-table.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\/2021\/03\/4.Console-table.png\" alt=\"Console table\"><\/a><\/center>\n<font size=\"2\"><center><i>Console table<\/i><\/center><\/font>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>group () and groupEnd ():<\/strong> These two methods help in displaying messages in group. The current group ends when groupEnd () is called.<\/li><\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>console.log(\"message without group\");\nconsole.group(\"Section1\");\nconsole.log(\"This message is in group Section1\");\nconsole.log (\"This message is also in group Section1\");\nconsole.groupEnd();\nconsole.log (\"Now again this message is without group\");<\/code><\/pre>\n\n\n\n<center><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-content\/uploads\/2021\/03\/5.Console-Group.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\/2021\/03\/5.Console-Group.png\" alt=\"Console Group\"><\/a><\/center>\n<font size=\"2\"><center><i>Console Group<\/i><\/center><\/font>\n\n\n\n<p>We hope you may find this blog resourceful and helpful. If you still have concerns and need more help, please contact us at <a href=\"mailto:salesforce@greytrix.com\">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\"><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/01\/22\/salesforce-how-to-get-row-index-of-lightning-table-rows\/\" target=\"_blank\" rel=\"noreferrer noopener\">Salesforce \u2013 How to get row index of lightning table rows<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/02\/12\/using-aura-method-to-pass-value-from-child-component-to-parent-component-with-example\/\" target=\"_blank\" rel=\"noreferrer noopener\">Using Aura method to pass value from Child component to Parent component (with example)<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/01\/20\/how-to-add-lightning-web-components-as-custom-tabs-in-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to add Lightning Web Components as Custom Tabs in Salesforce<\/a><\/li><li><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/01\/20\/how-to-set-cookies-in-http-callout-apex-salesforce\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to set cookies in HTTP Callout (APEX Salesforce)<\/a><\/li><\/ul>\n","protected":false},"excerpt":{"rendered":"<p>A major part of any Salesforce developer\u2019s job is debugging. Because Salesforce has a multitenant architecture, debugging on the platform is a bit different than it might be in other development environments. Commonly we use console.log() method to log on the console screen, but console provides wide range of methods which we helps to debugging\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.greytrix.com\/blogs\/salesforce\/2021\/03\/17\/how-to-debug-in-lightning-using-developer-console-api\/\">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":[1110,1109,87,1055,391],"class_list":["post-6109","post","type-post","status-publish","format-standard","hentry","category-salesforce-srv","tag-console","tag-debug","tag-debugger","tag-lightning-aura-component","tag-salesforce-debug"],"_links":{"self":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6109","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=6109"}],"version-history":[{"count":2,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6109\/revisions"}],"predecessor-version":[{"id":6122,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/posts\/6109\/revisions\/6122"}],"wp:attachment":[{"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/media?parent=6109"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/categories?post=6109"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greytrix.com\/blogs\/salesforce\/wp-json\/wp\/v2\/tags?post=6109"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}