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.

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