Tuesday, 11 December 2012

Restricting editing a record conditionally

If you wish to restrict users to edit a record after for example, the Sales Stage is marked as "Closed Lost" or something similar kind, you have reached to a right place.

As mentioned above, today's task is to stop users to editing any detail of an opportunity after the Sales Stage is "Closed Lost".

Here we go!


In this blog post, we are using SugarCRM's OOB module Opportunities, if you wish to implement same functionality to your custom module, just make sure you are accessing right directory.


Step 1: Copy modules/Opportunities/controller.php if exists, and paste it to custom/modules/Opportunities or else create a file under custom/modules/Opportunities/controller.php

Step 2: Write following code in there and voila!

<?php

class OpportunitiesController extends SugarController {

    function action_editview() {
        if ($this->bean->sales_stage == "Closed Lost") {
            $this->view = 'noaccess';
        }
        else
            $this->view = 'edit';
    }

}

Hope you find it helpful.

Feel free to leave your comments.

Sunday, 29 April 2012

Remove Check box and Edit link from List View

Many times users find it necessary to remove the check box and/or edit links from the list view of any module.

SugarCRM doesn't provide a setting to achieve this from admin panel.

There are few simple steps to follow and you are sorted.

First thing, you should have access to file base, if you have it, go ahead, world is all yours.



Throughout the blog, we will use custom module "UT_Blogs" if the blog post is not about specific OOB(out of box) modules.



Step 1: Check if you have a file named view.list.php under custom/modules/<desired_module>/views folder.





  • If you have, skip to Step 2.
  • If you do not have, like me, follow..











Check if you have a file named view.list.php under modules/<desired_module>/views folder.



  • If you have, copy that file and paste under custom/modules/<desired_module>/views folder and skip to Step 2.
  • If you do not have it, create a file named view.list.php under custom/modules/<desired_module>/views folder and write following code.





<?php 
require_once('include/MVC/View/views/view.list.php'); 
class <desired_module>ViewList extends ViewList 
{  
     function display()
     {
         parent::display(); 
     }
}

P.S. Here, <desired_module> means the module name you see in the url, for example, Contacts, Leads, UT_Blogs, etc.


Here is a special mention about custom module: if you have a custom module, we prefer to create/change the file under modules/<my_custom_module>/views


Step 2: Now add following lines in function display().

$this->lv->multiSelect = false; //This removes Check Box       
$this->lv->quickViewLinks = false; //This removes Edit Link
P.S. If your copied file does not have function display, you will have to add that from code above.

Step 3: This should be it, just refresh the list view and you should be able to see the effect instantly, no Quick Repair and Rebuild required.


Before
After

Hope you find this blog post helpful.

Feel free to add comments and queries, that helps us to improve the quality of posts.

You can contact us at contact@urdhva-tech.com

Thank you.

Urdhva Tech Pvt. Ltd. Powered by Blogger.

Urdhva Tech

My photo
SugarCRM Consultants Contact us at contact@urdhva-tech.com Skype : urdhvatech

Search This Blog

Stay connected Socially

     

Total Pageviews

Popular Posts