Results 1 to 5 of 5

Thread: Adding a new user drop down in studio

  1. #1
    REByers is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    North West England
    Posts
    182

    Question Adding a new user drop down in studio

    I am using Sugar 5.0.0f, and want to add a new field inthe opportunities module to track a salesperson.

    I cannot see how to create a field that looks up the user list, from within Studio. Is this possible? Tried using relate, but it won't show connections to the user list anywhere. Also I cannot clone the assigned to field as this does not appear in the fields list.

    What I then want to do is to trigger a workflow when a field changes to a certain value to write in the assigned to name into this new field at that point.

    Can anyone help?

  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: Adding a new user drop down in studio

    Hi, REByers

    You have to create a text custom field into Opportunities module.
    After that you have to create the file modules/Opportunities/controller.php and create 2 functions just like these one:

    PHP Code:
        function action_editview(){
            global 
    $app_list_strings$iash_optional_inventory_checked$iash_standard_inventory_checked$iash_warrantied_checked;
            
    $this->view 'edit';
            
    $GLOBALS['view'] = $this->view;

            
    $array = array();
            
    $result $this->bean->db->query("SELECT a.id, a.name FROM accounts a INNER JOIN accounts_cstm ac ON a.id = ac.id_c WHERE a.deleted = 0 AND ac.organisation_type_id_c = '3'");
        
            while(
    $row $this->bean->db->fetchByAssoc($result)) {
                
    $array[$row['id']] = $row['name'];
            }

            
    $publisher_id explode("^,^", @$this->bean->fetched_row['publisher_id']);
            
            
    $this->bean->publisher_id get_select_options_with_id($array$publisher_id);

        }

        function 
    action_detailview(){
            global 
    $app_list_strings$iash_optional_inventory_checked$iash_standard_inventory_checked$iash_warrantied_checked;
            
    $this->view 'detail';
            
    $GLOBALS['view'] = $this->view;

            
    $ids str_replace("^,^""','", @$this->bean->fetched_row['publisher_id']);
            
    $result $this->bean->db->query("SELECT a.name FROM accounts a INNER JOIN accounts_cstm ac ON a.id = ac.id_c WHERE a.deleted = 0 AND ac.organisation_type_id_c = '3' AND a.id IN ('{$ids}')");
        
            
    $this->bean->publisher_id '';
            
            while(
    $row $this->bean->db->fetchByAssoc($result)) {
                
    $this->bean->publisher_id.= "<LI>{$row['name']}";
            }
        } 
    This is an example of populating a multienum field.

    In the file detailviewdefs.php you add this customCode for the field:
    PHP Code:
                'customCode' => '{$fields.publisher_id.value}'

    And in the file editviewdefs.php you add this customCode:
    PHP Code:
            'customCode' => '<select id="publisher_id[]" title="" style="width: 150px;" size="6" multiple="true" name="publisher_id[]">{$fields.publisher_id.value}</select>'
    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
    webnetin is offline Sugar Community Member
    Join Date
    Dec 2005
    Posts
    68

    Question Re: Adding a new user drop down in studio

    Hello Andre,

    Thanks for the code.

    I tried same way in Accounts. Unfortunately, the moment i create file controller.php at <<sugar_root>>/modules/Accounts/ and save the file, it gives Error 500 on loading the Account modules list view. All other modules works fine at this stage, but clicking on Accounts gives the error.

    I am using Sugar 5.0.0f on Windows,IIS, MSSQL, PHP

    Thanks in advance.

    regards
    webNETin

  4. #4
    saradhinc is offline Sugar Community Member
    Join Date
    May 2008
    Posts
    13

    Default Re: Adding a new user drop down in studio

    I am also unable to generate the field with the code Andre has posted above. But I think the controller.php is not complete.. like the php tag, class declaration, etc are missing.. you may want to try by putting those in the controller.php. Sample code is given below:

    <?php

    class OpportunitiesController extends SugarController{
    function OpportunitiesController(){
    parent::SugarController();
    }

    /* Andre's code */
    ..
    ..


    }
    ?>
    After doing these changes, and modifying the queries, I was able to see the screen with an empty dropdown field.

    I am actually looking for generating a custom field similar to 'Assigned to' user field. I am using Sugar 5.0.0c CE. I couldn't find any solution for this version of Sugar in forums till now..

    Sugar Gurus:
    Any pointers in this regard would be of great help. Thanks!!!

  5. #5
    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: Adding a new user drop down in studio

    Hi all

    saradhinc, the code is not complete at all. I posted the piece of code related to the tricks to get it working. You really need to complete the code accordingly to your needs.

    webnetin, do you have access to the error log of IIS? It should contain some important error which can guide you to the light.

    Did you modify the query in the controller functions accordingly to your needs?? This example I post AS IT IS only works for some specific situation. The query and the fields MUST BE modified based on your real system.

    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.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. User Menus editable via Studio (V5)?
    By tokyotumbleweed in forum Help
    Replies: 0
    Last Post: 2008-03-12, 03:18 AM
  2. Manually drop scheme (5.0 upgrade) ?
    By niallhannon in forum Installation and Upgrade Help
    Replies: 1
    Last Post: 2008-01-07, 05:41 PM
  3. Filter User Drop Down
    By michaelest in forum Help
    Replies: 1
    Last Post: 2007-06-21, 07:52 PM
  4. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  5. Cannot Login
    By Dillon in forum Help
    Replies: 16
    Last Post: 2004-10-13, 02:52 AM

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
  •