{"id":233,"date":"2019-10-08T16:48:33","date_gmt":"2019-10-08T16:48:33","guid":{"rendered":"https:\/\/www.techcrm.in\/blogs\/?p=233"},"modified":"2020-09-08T14:53:09","modified_gmt":"2020-09-08T09:23:09","slug":"how-to-hide-a-button-on-detail-view-conditionally","status":"publish","type":"post","link":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/","title":{"rendered":"How to hide a button on Detail View conditionally"},"content":{"rendered":"\n<p>Suppose in Specific Module i Want to Hide Delete button conditionaly from DetailView page, So where can i put condition for show\/hide.<\/p>\n\n\n\n<p>You should be able to modify this in <strong>\/custom\/modules\/&lt;desired_module&gt;\/metadata\/detailviewdefs.php<\/strong><\/p>\n\n\n\n<p>Adding to this something like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if (your condition) {\n    unset($viewdefs&#91;'&lt;desired_module>']&#91;'DetailView']&#91;'templateMeta']&#91;'form']&#91;'buttons']&#91;2])\n    \/\/2 being the index of the DELETE button\n}<\/code><\/pre>\n\n\n\n<p>You&#8217;ll then need to run: <strong>Admin -&gt; Repair -&gt; Quick Repair and Rebuild<\/strong><\/p>\n\n\n\n<p>For\nSugarCRM Pro version<\/p>\n\n\n\n<p>You should edit the\u00a0<strong>custom\/modules\/<em>&lt;<\/em>desired_module<em>><\/em>\/metadata\/detailviewdefs.php<\/strong>\u00a0file and change the<strong>$viewdefs[$module_name][&#8216;DetailView&#8217;][&#8216;templateMeta&#8217;][&#8216;form&#8217;]<\/strong>\u00a0array according to your needs. As by default this array is empty for pretty much all modules.<\/p>\n\n\n\n<p>Example:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Place this code on the end of a file.\n\/\/ This line remove all buttons\n$viewdefs&#91;$&lt;desired_module>]&#91;'DetailView']&#91;'templateMeta']&#91;'form']&#91;'buttons'] = array();\n\/\/ This will add some buttons according to your conditions:\nif (condition for edit button = true)\n    $viewdefs&#91;$&lt;desired_module>]&#91;'DetailView']&#91;'templateMeta']&#91;'form']&#91;'buttons']&#91;] = 'EDIT';\nif (condition for duplicate button = true)\n    $viewdefs&#91;$&lt;desired_module>]&#91;'DetailView']&#91;'templateMeta']&#91;'form']&#91;'buttons']&#91;] = 'DUPLICATE';\nif (condition for delete button = true)\n    $viewdefs&#91;$&lt;desired_module>]&#91;'DetailView']&#91;'templateMeta']&#91;'form']&#91;'buttons']&#91;] = 'DELETE';<\/code><\/pre>\n\n\n\n<p>Remember to run <strong>Admin -&gt; Repair -&gt; Quick Repair<\/strong> <strong>and Rebuild<\/strong> every time you change this file.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Note :<\/strong> <\/p><cite><em>Here, &lt;desired_module&gt; means the module name you see in the URL, for example, Contacts, Leads, etc.<br>Here, &lt;any_name&gt; means the any file name&nbsp;for example, custom_fields, search_fields, etc.<br>Here, &lt;entry_point_name&gt; means any name as your requirements<\/em><\/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>Suppose in Specific Module i Want to Hide Delete button conditionaly from DetailView page, So where can i put condition for show\/hide. You should be able to modify this in \/custom\/modules\/&lt;desired_module&gt;\/metadata\/detailviewdefs.php Adding to this something like: You&#8217;ll then need to run: Admin -&gt; Repair -&gt; Quick Repair and Rebuild For SugarCRM Pro version You should [&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":[50,12,13],"class_list":["post-233","post","type-post","status-publish","format-standard","hentry","category-sugarcrm","category-suitecrm","tag-detail-view","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>How to hide a button on Detail View conditionally - 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\/how-to-hide-a-button-on-detail-view-conditionally\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to hide a button on Detail View conditionally - TechCRM\" \/>\n<meta property=\"og:description\" content=\"Suppose in Specific Module i Want to Hide Delete button conditionaly from DetailView page, So where can i put condition for show\/hide. You should be able to modify this in \/custom\/modules\/&lt;desired_module&gt;\/metadata\/detailviewdefs.php Adding to this something like: You&#8217;ll then need to run: Admin -&gt; Repair -&gt; Quick Repair and Rebuild For SugarCRM Pro version You should [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/\" \/>\n<meta property=\"og:site_name\" content=\"TechCRM\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-08T16:48:33+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-09-08T09:23:09+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=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/\",\"url\":\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/\",\"name\":\"How to hide a button on Detail View conditionally - TechCRM\",\"isPartOf\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#website\"},\"datePublished\":\"2019-10-08T16:48:33+00:00\",\"dateModified\":\"2020-09-08T09:23:09+00:00\",\"author\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/#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\":\"How to hide a button on Detail View conditionally\"}]},{\"@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":"How to hide a button on Detail View conditionally - 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\/how-to-hide-a-button-on-detail-view-conditionally\/","og_locale":"en_US","og_type":"article","og_title":"How to hide a button on Detail View conditionally - TechCRM","og_description":"Suppose in Specific Module i Want to Hide Delete button conditionaly from DetailView page, So where can i put condition for show\/hide. You should be able to modify this in \/custom\/modules\/&lt;desired_module&gt;\/metadata\/detailviewdefs.php Adding to this something like: You&#8217;ll then need to run: Admin -&gt; Repair -&gt; Quick Repair and Rebuild For SugarCRM Pro version You should [&hellip;]","og_url":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/","og_site_name":"TechCRM","article_published_time":"2019-10-08T16:48:33+00:00","article_modified_time":"2020-09-08T09:23:09+00:00","author":"Navin Rakhonde","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Navin Rakhonde","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/","url":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/","name":"How to hide a button on Detail View conditionally - TechCRM","isPartOf":{"@id":"https:\/\/www.techcrm.in\/blogs\/#website"},"datePublished":"2019-10-08T16:48:33+00:00","dateModified":"2020-09-08T09:23:09+00:00","author":{"@id":"https:\/\/www.techcrm.in\/blogs\/#\/schema\/person\/992dfe427bb53dcdfd72dd80e3ef9dbc"},"breadcrumb":{"@id":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.techcrm.in\/blogs\/how-to-hide-a-button-on-detail-view-conditionally\/#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":"How to hide a button on Detail View conditionally"}]},{"@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\/233","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=233"}],"version-history":[{"count":3,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/233\/revisions"}],"predecessor-version":[{"id":357,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/posts\/233\/revisions\/357"}],"wp:attachment":[{"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/media?parent=233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/categories?post=233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.techcrm.in\/blogs\/wp-json\/wp\/v2\/tags?post=233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}