Results 1 to 6 of 6

Thread: Relate field

  1. #1
    saj123 Guest

    Default Relate field

    Hi..

    I want to list all the users according to a certain conditions .. When we create that field as a Relate to "users" .. All the users will be listing ...

    So how to filter that conditions to be shown ?

  2. #2
    saj123 Guest

    Default Re: Relate field

    Hi..

    I want the users to be seen according to the role., for eg, i want to see all users based on sales role in the relate field of a custom module.. how to do that ? any idea ?

  3. #3
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    5,205

    Default Re: Relate field

    Try copying /modules/Users/metadata/popudefs.php to /custom/modules/Users/metadata/ and within the copy, build in the logic that checks the role the current user is in. Note that there is "whereStatement" entry within the array defined in that file. So, the idea would be to use your role checking logic to determine the appropriate User list so as to limit the users that are displayed.

    Note, however, that the list won't be limited if someone types into the relate field, versus clicking the button to display the popup. At least that's how it behaved last time I did this, a few versions back.
    Regards,

    Angel Magaņa
    Technical Solutions Architect
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

  4. #4
    saj123 Guest

    Default Re: Relate field

    Hi....

    Thanks for your response.. but i still have a trouble in it.. i didnt the copying the file /modules/Users/metadata/popudefs.php to /custom/modules/Users/metadata/ ..
    And i did like

    PHP Code:
    $roles SecurityGroup::getAllSecurityGroups(); 
        foreach(
    $roles as $roleName)
            { 
            echo 
    print_r($roleNametrue); 
            if(
    in_array('TeleCaller ',$roleName) )    
            {
    $popupMeta = array(
        
    'moduleMain' => 'User',
        
    'varName' => 'USER',
        
    'orderBy' => 'user_name',
        
    'whereClauses' => array(
            
    'first_name' => 'users.first_name',
            
    'last_name' => 'users.last_name',
            
    'user_name' => 'users.user_name',
            
    'is_group' => 'users.is_group',
        ),
        
    'whereStatement'=> " users.status = 'Active' and users.portal_only= '0'",
        
    'searchInputs' => array(
            
    'first_name',
            
    'last_name',
            
    'user_name',
            
    'is_group',
        ),
    );

            }

    Please tel me what to be done to display the users which are belonged to that role..

  5. #5
    saj123 Guest

    Default Re: Relate field

    Hi..

    I got the values in $id.. but i dont know how to send that id to the 'whereStatement' ???
    PHP Code:

    $roles 
    SecurityGroup::getAllSecurityGroups(); 
        foreach(
    $roles as $roleName)
            { 
            echo 
    print_r($roleNametrue); 
            if(
    in_array('TeleCaller',$roleName) )    
            {
            
    $res =  $GLOBALS['db']->query("SELECT user_id FROM `securitygroups_users` WHERE `securitygroup_id` LIKE '29b5e310-4e68-f808-47ee-51402fb857d4';");
            while ( 
    $id $GLOBALS["db"]->fetchByAssoc($res) )
            {
            
    $id[] = $id;
            echo 
    print_r($idtrue);
                
            
    $popupMeta = array(
            
    'moduleMain' => 'User',
            
    'varName' => 'USER',
            
    'orderBy' => 'user_name',
            
    'whereClauses' => array(
                
    'first_name' => 'users.first_name',
                
    'last_name' => 'users.last_name',
                
    'user_name' => 'users.user_name',
                
    'is_group' => 'users.is_group',
            
            
        ),
        
    'whereStatement'=> " users.status = 'Active', users.id = '$id' and users.portal_only= '0'",
        
    'searchInputs' => array(
            
    'first_name',
            
    'last_name',
            
    'user_name',
            
    'is_group',
        ),
    );
    }
            }


  6. #6
    saj123 Guest

    Default Re: Relate field

    Hi..

    Please help me for this problem..

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 2012-08-16, 09:01 AM
  2. Auto-Populate Relate field from another relate field
    By anthony.watson in forum Developer Help
    Replies: 3
    Last Post: 2011-08-24, 04:48 PM
  3. Replies: 0
    Last Post: 2011-08-04, 07:50 PM
  4. Restrict relate field based on another relate field
    By jkuehlthau in forum Developer Help
    Replies: 2
    Last Post: 2011-06-30, 03:27 PM
  5. Replies: 0
    Last Post: 2010-01-14, 02:56 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
  •