Remove Create Action button.

At times you will have a requirement to remove Create or any other action from menu of a particular module.

My module requires only to list the data and not allow creation or import of data.This can be simply achieved simply by changing some files of the modules.You just need to have access to the files of the module.

To remove the create and import action from the menu do the following :

Open Menu.php of the module and just comment or remove the actions you dont want.

before-menu
Before
after-menu
After

Here you may see that the add and import actions have been removed from the menu and the only available option is list action.

Though the user can access the EditView by passing required parameters in the URL.

Eg : localhost/sugarcrm/index.php?module={module}&action=EditView.

If you want to disable or disallow such an access follow below steps.

  1. Create view.edit.php at custom/module/{module}/views/view.edit.php
  2. Write the following code therein.
 <?php
  require_once('include/MVC/View/views/view.edit.php');
  class User__User_ActivityViewEdit extends ViewEdit{
    function display(){
        if(!$this->bean->fetched_row){
              sugar_die('You cannot create new records here, sorry'); 
       }
        parent::display();
    }
}
?> 

Now if the user still tries to access the edit view below screen will be displayed.

editview disabled
EditView Disabled

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Advertisements

2 thoughts on “Remove Create Action button.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s