Results 1 to 10 of 10

Thread: Custom ListView only working for admin user

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Custom ListView only working for admin user

    HI,

    I have a custom list view for Accounts that I use to filter Global team records out of list view. This is the code I have but it is only working for the admin user. When any other user log into the CRM no Accounts appear. Can someone tell me what is wrong

    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    require_once(
    'include/MVC/View/views/view.list.php');

    class 
    AccountsViewList extends ViewList{
         function 
    AccountsViewList()
         {
             
    parent::ViewList();
         }
         
         
    /*
          * Override listViewProcess with addition to where clause to exclude project templates
          */
        
    function listViewProcess()
        {
            
    $this->processSearchForm();
                    

            
    // RETRIEVE ACCOUNTS WHERE THE TEAM IS NOT GLOBAL
            
    if ($this->where != "")
                
    $this->where .= ' and team_id != 1 ';
            else
                
    $this->where .= 'team_id != 1';

            
            
    $this->lv->searchColumns $this->searchForm->searchColumns;
            
            if(!
    $this->headers)
                return;
                
            if(empty(
    $_REQUEST['search_form_only']) || $_REQUEST['search_form_only'] == false)
            {
                
    $this->lv->setup($this->seed'include/ListView/ListViewGeneric.tpl'$this->where$this->params);
                
    $savedSearchName = empty($_REQUEST['saved_search_select_name']) ? '' : (' - ' $_REQUEST['saved_search_select_name']);
                echo 
    get_form_header($GLOBALS['mod_strings']['LBL_LIST_FORM_TITLE'] . $savedSearchName''false);
                echo 
    $this->lv->display();
            }
        }

    }

    ?>
    Rdgs
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  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,491

    Default Re: Custom ListView only working for admin user

    Probably it is generating a sql query error.

    Edit the file include/ListView/ListViewData.php and add this line:

    PHP Code:
    echo "<LI>$main_query</LI>"
    just after the line

    PHP Code:
    $main_query $ret_array['select'] . $params['custom_select'] . $ret_array['from'] . $params['custom_from'] . $ret_array['where'] . $params['custom_where'] . $ret_array['order_by'] . $params['custom_order_by']; 
    Try again, you will see the sql query on screen.
    Execute it at your phpMyAdmin, let us know both sql query and error provided by phpMyAdmin

    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.

  3. #3
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Re: Custom ListView only working for admin user

    Hi thanks for the info.

    the error I get in the query is

    CODE]Column 'team_id' in where clause is ambiguous[/CODE]

    For the admin user I am getting a different query then for a normal user.

    This is the part of the query for a normal user

    Code:
    FROM accounts 
    INNER JOIN team_memberships team_memberships ON accounts.team_id = team_memberships.team_id 
    AND team_memberships.user_id = 'a19ff192-49a6-102c-8082-001d0911a977' 
    AND team_memberships.deleted=0 
    LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c 
    LEFT JOIN teams jt0 ON jt0.id= accounts.team_id 
    AND jt0.deleted=0 
    AND jt0.deleted=0 
    WHERE (team_id !=1) AND accounts.deleted=0 ORDER BY team_name DESC
    This is the same part that is created by admin

    Code:
    FROM accounts 
    LEFT JOIN accounts_cstm ON accounts.id = accounts_cstm.id_c 
    LEFT JOIN teams jt0 ON jt0.id= accounts.team_id 
    AND jt0.deleted=0 
    AND jt0.deleted=0 
    WHERE (team_id != 1) 
    AND accounts.deleted=0 
    ORDER BY team_name DESC
    How do I fix whatever is going wrong here?

    *******************************
    UPDATE
    ******************************
    Where I have team_id I need that to be accounts.team_id so I gues I have to change it in my list.view.php
    ********************************
    Last edited by chrislynch8; 2010-03-09 at 11:48 AM.
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  4. #4
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Re: Custom ListView only working for admin user

    Hi,

    Thanks for teh help André - that is working perfectly now.

    I know this is the wrong thread but I am still having trouble with the DevToolKit as per my posts in the Help forums yesterday.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  5. #5
    kuske's Avatar
    kuske is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Germany
    Posts
    2,678

    Default Re: Custom ListView only working for admin user

    If I would like to filter by the team_id of accounts I would write

    PHP Code:
            // RETRIEVE ACCOUNTS WHERE THE TEAM IS NOT GLOBAL 
            
    if ($this->where != ""
                
    $this->where .= ' and accounts.team_id != 1 '
            else 
                
    $this->where .= 'accounts.team_id != 1'


    Harald Kuske
    Senior Sales Engineer Central Europe

    SUGARCRM Deutschland GmbH
    Erika-Mann-Str. 53, 80636 Munich, Germany
    Email: hkuske@sugarcrm.com
    Home: http://www.sugarcrm.com

    PLEASE SWITCH TO
    https://community.sugarcrm.com/, the FORUMS will be closed !


  6. #6
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Re: Custom ListView only working for admin user

    Quote Originally Posted by kuske View Post
    If I would like to filter by the team_id of accounts I would write

    PHP Code:
            // RETRIEVE ACCOUNTS WHERE THE TEAM IS NOT GLOBAL 
            
    if ($this->where != ""
                
    $this->where .= ' and accounts.team_id != 1 '
            else 
                
    $this->where .= 'accounts.team_id != 1'


    Thats perfect, had it done by time I say this post.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  7. #7
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Re: Custom ListView only working for admin user

    Quick question relating to this.

    THe above change works great in the ListView, but how do I acheive the same thing in the listview that appears for accounts in the Popup box when selecting an Account for a Meeting. I need a custom view.popup.php but what does it have to contain to work.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  8. #8
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    764

    Default Re: Custom ListView only working for admin user

    Anyone know what I can put in to add extra Where Clauses to the ListView that appears in the popup windows

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  9. #9
    naveen2k7 is offline Senior Member
    Join Date
    Apr 2010
    Location
    Chennai, India
    Posts
    110

    Default Re: Custom ListView only working for admin user

    Hi,

    Iam using sugarcrm CE 5.5, Iam working on same custom list view. so i have added the code as per your post.
    PHP Code:
    function listViewProcess(){
            
    $this->processSearchForm();
            
        
                global 
    $current_user// grab the $current_user object
            
                
    $acl_role_obj = new ACLRole();
            
                
    $user_roles $acl_role_obj->getUserRoles($current_user->id);
                    
            if(
    in_array("SUPERVISOR",$user_roles)){
            
            if (
    $this->where != "")
            {
                
    $this->where .= ' and leads.validdata != "1"';
                
                }
            else {
            
                
    $this->where .= 'leads.validdata != "0"'
                }
                
                 } 

    and its working fine in list view.

    Now i want to add the same for dashlet listview for the leads module. Can u help me out for which file i have to modify??

    Thanks in Advance,
    Naveen

  10. #10
    cheq326 is offline Sugar Community Member
    Join Date
    Mar 2011
    Posts
    34

    Default Re: Custom ListView only working for admin user

    anyone has a solution for this?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Dashboard only working for user 'admin'
    By nfuids in forum Help
    Replies: 1
    Last Post: 2008-11-27, 02:14 AM
  2. Replies: 0
    Last Post: 2008-11-20, 02:10 PM
  3. Replies: 4
    Last Post: 2008-07-03, 08:42 AM
  4. Replies: 0
    Last Post: 2008-06-29, 11:27 PM
  5. Replies: 0
    Last Post: 2005-08-10, 04:47 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
  •