{"id":126,"date":"2019-08-25T07:21:22","date_gmt":"2019-08-25T07:21:22","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=126"},"modified":"2020-09-08T14:55:47","modified_gmt":"2020-09-08T09:25:47","slug":"creating-new-dashlets-based-on-default","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/","title":{"rendered":"Creating new Dashlets based on default"},"content":{"rendered":"\n<p>Here are the steps to create new dashlet based on SugarCRM&#8217;s OOB dashlet.<\/p>\n\n\n\n<p>In this blog, we are extending My Open Tasks dashlet to show Tasks until NOW. <\/p>\n\n\n\n<p>Steps are as below,<\/p>\n\n\n\n<p><strong>Step 1<\/strong>: Copy modules\/Tasks\/Dashlets\/MyTasksDashlet to custom\/modules\/Tasks\/Dashlets folder. Rename MyTasksDashlet folder to MyTasksUntilNowDashlet. <\/p>\n\n\n\n<p><strong>Step 2<\/strong>: Go to custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/ <\/p>\n\n\n\n<p>Rename MyTasksDashlet.data.php to MyTasksUntilNowDashlet.data.php<br>Rename MyTasksDashlet.meta.php to MyTasksUntilNowDashlet.meta.php<br>Rename MyTasksDashlet.php to MyTasksUntilNowDashlet.php <\/p>\n\n\n\n<p><strong>Step 3<\/strong>: Open custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.data.php <\/p>\n\n\n\n<p>Find and replace MyTasksDashlet to MyTasksUntilNowDashlet <\/p>\n\n\n\n<p><strong>Step 4<\/strong>:&nbsp; Open custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.meta.php<\/p>\n\n\n\n<p>Find and replace MyTasksDashlet to MyTasksUntilNowDashlet<\/p>\n\n\n\n<p>Change LBL_LIST_MY_TASKS to LBL_LIST_MY_TASKS_UNTIL_NOW <\/p>\n\n\n\n<p><strong>Step 5<\/strong>: Open custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.php<\/p>\n\n\n\n<p>Find and replace MyTasksDashlet to MyTasksUntilNowDashlet <\/p>\n\n\n\n<p><strong>Step 6<\/strong>: Lets guide Sugar to take new path<br>Change\u00a0<br>require(&#8216;modules\/Tasks\/Dashlets\/MyTasksDashlet\/MyTasksDashlet.data.php&#8217;);<br>to<br>require(&#8216;custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.data.php&#8217;); <\/p>\n\n\n\n<p><strong>Step 7<\/strong>: Lets now add custom functionality.<\/p>\n\n\n\n<p>Add following function in the class <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function process($lvsParams = array()) {\n        global $timedate, $current_user;\n        $format = $timedate->get_date_time_format($current_user);\n        $dbformat = date('Y-m-d H:i:s', strtotime(date($format)));\n\/\/ MYSQL database\n        $lvsParams['custom_where'] = ' AND DATE_FORMAT(tasks.date_start, \"%Y-%m-%d %H:%i:%s\") &lt;= \"'.  $dbformat.'\" ';\n        \/\/ MSSQL \n\/\/ $lvsParams['custom_where'] = \" AND REPLACE(CONVERT(varchar, tasks.date_start,111),'\/','-') = '\".$dbformat.\"')\";\n        parent::process($lvsParams);\n     } <\/code><\/pre>\n\n\n\n<p><strong>Step 8<\/strong>:<br>Lets now change label of the Dashlet to know which is new dashlet we just created.<br>Create\/Open custom\/modules\/Tasks\/language\/en_us.lang.php and add following line <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php \n$mod_strings['LBL_LIST_MY_TASKS_UNTIL_NOW'] = 'My Open Tasks until now';<\/code><\/pre>\n\n\n\n<p>Change the name which suits you more. <\/p>\n\n\n\n<p><strong>Step 9<\/strong>: Go to Admin &gt; Repair &gt; Quick Repair and Rebuild. Go to Home &gt; Add dashlet and you should see the new dashlet there.<\/p>\n\n\n\n<p>Hope it works as easy as it was while writing. <\/p>\n\n\n\n<p> Just to make life easier pasting the final look of the main class file.<br>I.e. custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.php <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;?php\n\nif (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');\n\nrequire_once('include\/Dashlets\/DashletGeneric.php');\n\nclass MyTasksUntilNowDashlet extends DashletGeneric {\n\n    function MyTasksUntilNowDashlet($id, $def = null) {\n        require('custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/MyTasksUntilNowDashlet.data.php');\n\n        parent::DashletGeneric($id, $def);\n\n        if (empty($def['title']))\n            $this->title = translate('LBL_LIST_MY_TASKS', 'Tasks');\n\n        $this->searchFields = $dashletData['MyTasksUntilNowDashlet']['searchFields'];\n        $this->columns = $dashletData['MyTasksUntilNowDashlet']['columns'];\n        $this->seedBean = new Task();\n    }\n\n    function process($lvsParams = array()) {\n        global $timedate, $current_user;\n        $format = $timedate->get_date_time_format($current_user);\n        $dbformat = date('Y-m-d H:i:s', strtotime(date($format)));\n        \n\/\/ MYSQL database\n        $lvsParams['custom_where'] = ' AND DATE_FORMAT(tasks.date_start, \"%Y-%m-%d %H:%i:%s\") &lt;= \"'.  $dbformat.'\" ';\n        \/\/ MSSQL \n\/\/ $lvsParams['custom_where'] = \" AND REPLACE(CONVERT(varchar, tasks.date_start,111),'\/','-') = '\".$dbformat.\"')\";\n        parent::process($lvsParams);\n    }\n\n}<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note :<\/strong><\/p><cite> P.S. Comment out MySQL Query and uncomment MSSql query if you are using MSSQL database. <\/cite><\/blockquote>\n\n\n\n<p>Hope you find this blog post helpful.<\/p>\n\n\n\n<p>Feel free to add comments and queries, that helps us to improve the quality of posts.<\/p>\n\n\n\n<p>You can contact us at&nbsp;<a rel=\"noreferrer noopener\" href=\"mailto:contact@urdhva-tech.com\" target=\"_blank\">info@techcrm.in<\/a><\/p>\n\n\n\n<p>Thank you.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here are the steps to create new dashlet based on SugarCRM&#8217;s OOB dashlet. In this blog, we are extending My Open Tasks dashlet to show Tasks until NOW. Steps are as below, Step 1: Copy modules\/Tasks\/Dashlets\/MyTasksDashlet to custom\/modules\/Tasks\/Dashlets folder. Rename MyTasksDashlet folder to MyTasksUntilNowDashlet. Step 2: Go to custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/ Rename MyTasksDashlet.data.php to MyTasksUntilNowDashlet.data.phpRename MyTasksDashlet.meta.php to [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,9],"tags":[24,12,13],"class_list":["post-126","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-dashlets","tag-sugarcrm","tag-suitecrm"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Creating new Dashlets based on default - TechCRM<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Creating new Dashlets based on default - TechCRM\" \/>\n<meta property=\"og:description\" content=\"Here are the steps to create new dashlet based on SugarCRM&#8217;s OOB dashlet. In this blog, we are extending My Open Tasks dashlet to show Tasks until NOW. Steps are as below, Step 1: Copy modules\/Tasks\/Dashlets\/MyTasksDashlet to custom\/modules\/Tasks\/Dashlets folder. Rename MyTasksDashlet folder to MyTasksUntilNowDashlet. Step 2: Go to custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/ Rename MyTasksDashlet.data.php to MyTasksUntilNowDashlet.data.phpRename MyTasksDashlet.meta.php to [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-25T07:21:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:25:47+00:00\" \/>\n<meta name=\"author\" content=\"Navin Rakhonde\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Navin Rakhonde\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/\",\"name\":\"Creating new Dashlets based on default - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2019-08-25T07:21:22+00:00\",\"dateModified\":\"2020-09-08T09:25:47+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"SugarCRM\",\"item\":\"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Creating new Dashlets based on default\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/\",\"name\":\"TechCRM\",\"description\":\"Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\",\"name\":\"Navin Rakhonde\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g\",\"caption\":\"Navin Rakhonde\"},\"sameAs\":[\"https:\/\/www.techcrm.in\/\"],\"url\":\"https:\/\/www.techcrm.in\/blogs\/author\/navin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Creating new Dashlets based on default - TechCRM","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/","og_locale":"en_US","og_type":"article","og_title":"Creating new Dashlets based on default - TechCRM","og_description":"Here are the steps to create new dashlet based on SugarCRM&#8217;s OOB dashlet. In this blog, we are extending My Open Tasks dashlet to show Tasks until NOW. Steps are as below, Step 1: Copy modules\/Tasks\/Dashlets\/MyTasksDashlet to custom\/modules\/Tasks\/Dashlets folder. Rename MyTasksDashlet folder to MyTasksUntilNowDashlet. Step 2: Go to custom\/modules\/Tasks\/Dashlets\/MyTasksUntilNowDashlet\/ Rename MyTasksDashlet.data.php to MyTasksUntilNowDashlet.data.phpRename MyTasksDashlet.meta.php to [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/","og_site_name":"TechCRM","article_published_time":"2019-08-25T07:21:22+00:00","article_modified_time":"2020-09-08T09:25:47+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/","url":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/","name":"Creating new Dashlets based on default - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2019-08-25T07:21:22+00:00","dateModified":"2020-09-08T09:25:47+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/creating-new-dashlets-based-on-default\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.techcrm.in\/blogs\/"},{"@type":"ListItem","position":2,"name":"SugarCRM","item":"https:\/\/www.techcrm.in\/blogs\/category\/sugarcrm\/"},{"@type":"ListItem","position":3,"name":"Creating new Dashlets based on default"}]},{"@type":"WebSite","@id":"https:\/\/www.techcrm.in\/blogs\/#website","url":"https:\/\/www.techcrm.in\/blogs\/","name":"TechCRM","description":"Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.techcrm.in\/blogs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc","name":"Navin Rakhonde","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8fd1b948255055b85e5d41dabfc6e704f806d180a1e21cb8fb378e2f5c022?s=96&d=mm&r=g","caption":"Navin Rakhonde"},"sameAs":["https:\/\/www.techcrm.in\/"],"url":"https:\/\/www.techcrm.in\/blogs\/author\/navin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/comments?post=126"}],"version-history":[{"count":1,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/126\/revisions"}],"predecessor-version":[{"id":127,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/126\/revisions\/127"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}