Remove or Hide Create button

Hello everyone,

I need to hide or remove Create button from contacts module so that users would be able only convert Contact from leads?

have anyone solution for this?

You can just hide it with css or make a view.list.php file and include javascript to hide it.

Hi Pukis,

To hide buttons using javascript is not a proper way any one can open create form using url directly,
you can restrict the create view of the module by extending your module controller on path custom/modules/[MODULE]/controller.php .

require_once(‘include/MVC/Controller/SugarController.php’);

class [MODULE]Controller extends SugarController
{
function action_EditView(){
if(empty($_REQUEST[‘record’])){
$this->view = ‘noaccess’;
}else{
$this->view = ‘edit’;
}
}
}

2 Likes

Hi

When I am using it seems if(empty($_REQUEST)) is never true, whether I click edit or create. What am I missing here please?

Many Thanks

Luke

Hi

I found that isempty($_REQUEST) does not work but is_null($_REQUEST[“record”]) does seem to do the trick.

Regards

Luke

I have tried to use this, but this is not working. Below is the code

<?php
require_once('include/MVC/Controller/SugarController.php');

/**
 * Created by PhpStorm.
 * User: USER
 * Date: 8/19/2016
 * Time: 9:44 AM
 */
class OpportunitiesController extends SugarController
{
    function action_save(){
        if(empty($_REQUEST["record"])){
            $this->view = 'noaccess';
        }else{
            $this->view = 'edit';
        }
    }

}

I used function action_EditView() {} also but did not worked for me

Hi,

I would say that the create button is not needed at some point. Please let us know how can we hide the create button on top. And if i would like to remove the save button conditionally, how can i do that as well.

Thank you for the community support on this matter.

Anybody has solution for this?
I need to hide create button on lead module. I dont want to use it.

The easiest way I have found is in view.list/view,detail & view.edit put print ‘#create_link, #create_image{ display:none; }’;

Thank you for fast response.

Can you explain it more. Where is the path of file. Which code should i insert under?

is it under the \custom\modules\Leads\metadata\ ?

Regards,

create a file custom/modules/Leads/views/view.list.php

if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Leads/views/view.list.php');

class CustomLeadsViewList extends LeadsViewList
{
function Display(){
		print '<style type="text/css">#create_link, #create_image{ display:none; }</style>';
		parent::Display();
	}
}

This will remove Create button from List View

Then do the same for detail & edit views

1 Like

It is working, thank you.

Last question, Can i hide or remove lead module action menu?

Create a file in custom/Extension/modules/Leads/menu.php

<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
unset($module_menu);
?>

You will need todo a repair for this to take effect

I tried but there is no effect :frowning:

My version is 7.7.8

did you run a repair?

Yes sure.

Sorry gave you the wrong path

should be custom/Extension/modules/Leads/Ext/Menus/menu.php

file name can be whatever you want

create file and do repair

1 Like

Thank you for your support.

Everything is working perfect :slight_smile: