Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Restrict editing of records

  1. #1
    seanmh is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    16

    Default Restrict editing of records

    I'm trying to lock users out of editing specific opportunities if certain conditions are met. I've tried the security suite without success as it prevents the users from creating new accounts. Anyone know where I can start to find information on how to do this?

  2. #2
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Restrict editing of records

    Hi seanmh

    Let us know all conditions which are going to restrict editing Opportunities.
    I'm sure we can help you, but the implementation / customization depends on specific conditions.

    Best regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  3. #3
    seanmh is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    16

    Default Re: Restrict editing of records

    I want to lock it based on a users role, a built-in field, and a custom field. Do you need more specifics?

    Thanks!

  4. #4
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Restrict editing of records

    Hi seanmh

    It is getting clearer but additional details would be helpful.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  5. #5
    meeric is offline Sugar Community Member
    Join Date
    Jul 2008
    Posts
    124

    Default Re: Restrict editing of records

    Hi

    You can use hooks if you know code PHP script

    regards

  6. #6
    seanmh is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    16

    Default Re: Restrict editing of records

    Quote Originally Posted by andopes
    Hi seanmh

    It is getting clearer but additional details would be helpful.

    Cheers
    If the opportunity sales stage is "Closed Won" and there's an 'ops approval date' (custom field) I want to lock that user that is of the role "Sales" out from editing the opportunity.

    I am familiar with PHP but I'm not sure how to access certain variables within Sugar. Like the users role.

    I hope this helps. Let me know.

    Thanks!

  7. #7
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Restrict editing of records

    Hi seanmh

    Create the file custom/modules/Opportunities/controller.php with this content:

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

    class 
    OpportunitiesController extends SugarController {
        function 
    action_editview() {
            global 
    $current_user;
        
            if(
    $this->bean->sales_stage == 'Closed Won' && $this->bean->ops_approval_date != '' && ! $current_user->check_role_membership('Sales')) {
                
    $this->view 'noaccess';
            } else {
                
    $this->view 'edit';
            }

            
    $GLOBALS['view'] = $this->view;
        }
    }
    ?>
    Probably you need to fix the name of the custom field

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  8. #8
    seanmh is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    16

    Default Re: Restrict editing of records

    Wow! I wasn't expecting you to give me code. Thank you! It doesn't seem to work, here's what I have:

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

    class 
    OpportunitiesController extends SugarController {
        function 
    action_editview() {
            global 
    $current_user;

            if(
    $this->bean->sales_stage == 'Closed Won' && $this->bean->ops_approval_date_c != '' && ! $current_user->check_role_membership('Sales People')) {
                
    $this->view 'noaccess';
            } else {
                
    $this->view 'edit';
            }

            
    $GLOBALS['view'] = $this->view;
        }
    }
    ?>
    I'm assuming that the custom field has to be the full name from the database? Should the edit button disappear or should they just not be able to go in to the record? After I made the changes I rebuilt the relationships and did a quick repair. The user of the role 'Sales People' still can see the edit button and edit the opportunity. Any input is appreciated.

    Thanks again!

    --EDIT--

    I spoke too soon. I modified it a bit and got it work. I really appreciate your help. Thank you.
    Last edited by seanmh; 2008-10-22 at 04:10 PM.

  9. #9
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Restrict editing of records

    Hi seanmh

    You need to create a view.detail.php to remove the button Edit from layout if the user can not edit this record.

    Cheers
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

  10. #10
    seanmh is offline Sugar Community Member
    Join Date
    Sep 2007
    Posts
    16

    Default Re: Restrict editing of records

    I'm not familiar with this file. I see that one exists but I'm not sure what I'd need to change to remove the edit button for the same rules above.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 2008-06-30, 02:38 PM
  2. Replies: 0
    Last Post: 2008-02-06, 08:17 PM
  3. Replies: 1
    Last Post: 2008-01-11, 06:34 PM
  4. Contact Export misses some records
    By saradoo in forum Help
    Replies: 2
    Last Post: 2007-08-06, 06:12 PM
  5. Replies: 0
    Last Post: 2005-11-14, 02:51 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •