Results 1 to 9 of 9

Thread: How can I reproduce the Assigned to field functionality

  1. #1
    eli
    eli is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Default How can I reproduce the Assigned to field functionality

    I would like to add a field to the Leads module that performs exactly as the assigned to field does, with the auto lookup/complete and the relationship to be associated with the users table.

    The objective is for this field to be a Generated By: field, where the lead was brought in by a particular user that is not the user that entered the lead or the assigned user.

    I would also like to keep the data in the same table to make reporting much easier, I have found that creating custom fields in the sugar admin creates a separate table.

    I would be willing to document my processes and make them available to the forums and the wiki.

    I have found the following fields located in the modules/Leads/vardefs.php

    'assigned_user_id' =>
    array (
    'name' => 'assigned_user_id',
    'rname' => 'user_name',
    'id_name' => 'assigned_user_id',
    'vname' => 'LBL_ASSIGNED_TO',
    'type' => 'assigned_user_name',
    'table' => 'users',
    'isnull' => 'false',
    'dbType' => 'id',
    'reportable'=>true,
    'audited'=>true,
    'comment' => 'User assigned to this record',
    'duplicate_merge'=>'disabled'
    ),
    'assigned_user_name' =>
    array (
    'name' => 'assigned_user_name',
    'vname' => 'LBL_ASSIGNED_TO_NAME',
    'type' => 'varchar',
    'source' => 'non-db',
    'table' => 'users',
    'duplicate_merge'=>'disabled'
    ),

    and the following link

    'assigned_user_link' =>
    array (
    'name' => 'assigned_user_link',
    'type' => 'link',
    'relationship' => 'leads_assigned_user',
    'vname' => 'LBL_ASSIGNED_TO_USER',
    'link_type' => 'one',
    'module'=>'Users',
    'bean_name'=>'User',
    'source'=>'non-db',
    'duplicate_merge'=>'enabled',
    'rname' => 'user_name',
    'id_name' => 'assigned_user_id',
    'table' => 'users',
    ),

    and following relationship

    ,'leads_assigned_user' =>
    array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
    'rhs_module'=> 'Leads', 'rhs_table'=> 'leads', 'rhs_key' => 'assigned_user_id',
    'relationship_type'=>'one-to-many')

    From that I created my fields -

    'generatedby_user_id' =>
    array (
    'name' => 'generatedby_user_id',
    'rname' => 'user_name',
    'id_name' => 'generatedby_user_id',
    'vname' => 'LBL_GENERATED_BY',
    'type' => 'assigned_user_name',
    'table' => 'users',
    'isnull' => 'false',
    'dbType' => 'id',
    'reportable'=>true,
    'audited'=>true,
    'comment' => 'User assigned to this record',
    'duplicate_merge'=>'disabled'
    ),
    'generatedby_user_name' =>
    array (
    'name' => 'generatedby_user_name',
    'vname' => 'LBL_GENERATED_BY_NAME',
    'type' => 'varchar',
    'source' => 'non-db',
    'table' => 'users',
    'duplicate_merge'=>'disabled'
    ),

    and my link

    'generatedby_user_link' =>
    array (
    'name' => 'generatedby_user_link',
    'type' => 'link',
    'relationship' => 'leads_generatedby_user',
    'vname' => 'LBL_GENERATED_BY_USER',
    'link_type' => 'one',
    'module'=>'Users',
    'bean_name'=>'User',
    'source'=>'non-db',
    'duplicate_merge'=>'enabled',
    'rname' => 'user_name',
    'id_name' => 'generatedby_user_id',
    'table' => 'users',
    ),

    and my relationship

    ,'leads_generatedby_user' =>
    array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
    'rhs_module'=> 'Leads', 'rhs_table'=> 'leads', 'rhs_key' => 'generatedby_user_id',
    'relationship_type'=>'one-to-many')


    I also modified /modules/Leads/field_arrays.php and added ,"generatedby_user_id"
    I also modified /modules/Leads/en_us.lang.php and added 'LBL_GENERATED_BY_NAME' => 'Generated By:',

    In the admin section I now get similar fields to those of the assigned to field and I can add them to the module but when I publish it and open the module they are neither under the detail view or the edit view.

    I was able to read through the post by Jacob (http://www.sugarcrm.com/forums/showthread.php?t=7102) and it helped me understand what to look for but I am kinda stuck. Any help would be greatly appreciated.
    Last edited by eli; 2007-12-02 at 10:40 PM. Reason: Better description for title

  2. #2
    dpatech is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    NC
    Posts
    287

    Default Re: How can I reproduce the Assigned to field functionality

    I think you would be best served by making this a standard custom field in the appropriate "_cstm" table. It is a very simple join based on one key field and having it as a custom field allows you to use all of the Sugar Studio features.

    Did you actually add the field to the database yet?

    In addition to creating the custom field, you will need to edit the Detail and Edit views, either via the Studio or manually.
    - Sugar Team
    dpa Technology LLC
    e-mail: dpaDeveloper@dpatechnology.com
    web: http://www.dpatechnology.com

  3. #3
    eli
    eli is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Default Re: How can I reproduce the Assigned to field functionality

    I have had a development, I moved the fields from one location to another and they now appear on the forms.

    In addition to creating the custom field, you will need to edit the Detail and Edit views, either via the Studio or manually.
    I had added them to a slot via the studio, now upon moving them they show up.

    Did you actually add the field to the database yet?
    Yes the field exists in the leads table.

    ------

    The problem that I run into now is the label is displayed but the data in the field is not (I placed data in a few records). This occurs in both the edit and detail view screens.

    dpatech, I would be willing to use a custom field, how do you suggest I get the functionality that is provided by the assigned to field if I decide to take such a route?

    My goal is to have this field be exactly like the assigned to field, but I need it to be in addition to the assigned field.

  4. #4
    dpatech is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    NC
    Posts
    287

    Default Re: How can I reproduce the Assigned to field functionality

    My approach would have been to use the Studio to get 90% of the solution that you wanted, i.e., adding the custom field and adding to both the Edit and Detail panel. From that point I would have manually customized the Edit and Detail panel to get the last bit of customization.

    Given your current problem, make sure that you have the field name in the template html files and then, because this isn't a standard custom field, you will have to manually add the template ASSIGN statement to both the Edit and Detail php files.

    Please note that once this manual customization is done, you will not be able to use the Studio functions to modify the Edit and Detail panels since it will overwrite your customizations.
    Last edited by dpatech; 2007-12-02 at 11:53 PM.
    - Sugar Team
    dpa Technology LLC
    e-mail: dpaDeveloper@dpatechnology.com
    web: http://www.dpatechnology.com

  5. #5
    eli
    eli is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Default Re: How can I reproduce the Assigned to field functionality

    The field names have been added to the editview.html and the detailview.html.
    I have also added the assign statements as you have mentioned and it still does not save or retrieve data.
    If I place the custom field as you have suggested, wouldn't I have to go through similar steps that I already have, in order to get the username instead of the unfriendly user id.

  6. #6
    john30043 is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Atlanta, GA
    Posts
    17

    Default Re: How can I reproduce the Assigned to field functionality

    this is pretty much what I did to make the similar "account manager" field:
    1) add following attributes to the vardefs.php:
    'account_manager_id'
    'account_manager_name'
    'account_manager_link'
    relationship-> 'accounts_manager_user' //this map the account_manager_id to the user_id in the user table...
    2) add display attributes in detailviewdefs.php
    3) add edit attributes in 'editviewdefs.php
    4) add following variables to the module object.php file:
    var $account_manager_name;
    var $account_manager_id;
    var $account_manager_link;
    5) rebuild the module include the database and the relationship to reflect the changes.

    Now I have the 'select' and 'clear' button beside the 'account manager' field in the edit window. my question though, is how to make the field in detailed view a link so the user can click on the account manager and see contact information of the account managers?
    Attached Images Attached Images  
    Last edited by john30043; 2007-12-04 at 08:09 PM.
    John Zhang
    [Server: WinXP]
    [Sugar v5.0.0 GA]
    [Apache 2.2.5]
    [MySQL 5.0.45]

  7. #7
    dpatech is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    NC
    Posts
    287

    Default Re: How can I reproduce the Assigned to field functionality

    What is the "type" of the account_manager_name field in your vardefs.php? Is it "relate"?
    - Sugar Team
    dpa Technology LLC
    e-mail: dpaDeveloper@dpatechnology.com
    web: http://www.dpatechnology.com

  8. #8
    eli
    eli is offline Sugar Community Member
    Join Date
    Nov 2007
    Posts
    10

    Default Re: How can I reproduce the Assigned to field functionality

    john30043,
    Are you working in a current working module (like Leads or Accounts) or is this a module that you custom built through the module builder?

    Either way it would be greatly appreciated if you could post your code for steps 1-3 thank you.

  9. #9
    john30043 is offline Sugar Community Member
    Join Date
    Nov 2007
    Location
    Atlanta, GA
    Posts
    17

    Default Re: How can I reproduce the Assigned to field functionality

    the following example is from the custom module that I built from module builder, it should work in the same way for current working modules except the all the modifications should be overridden at the custom subdirectory...

    1) add attributes to vardefs.php:
    'account_manager_id' =>
    array (
    'name' => 'account_manager_id',
    'rname' => 'user_name',
    'id_name' => 'account_manager_id',
    'vname' => 'LBL_ACCOUNT_MANAGER',
    'type' => 'assigned_user_name',
    'table' => 'users',
    'isnull' => 'false',
    'group'=>'account_manager_name',
    'dbType' => 'id',
    'reportable'=>true,
    'comment' => 'account manager record'
    ),
    'account_manager_name' =>
    array (
    'name' => 'account_manager_name',
    'vname' => 'LBL_ACCOUNT_MANAGER_NAME',
    'type' => 'relate',
    'reportable'=>false,
    'source'=>'non-db',
    'rname'=>'user_name',
    'table' => 'users',
    'id_name' => 'account_manager_id',
    'module'=>'Users',
    'link'=>'account_manager_link',
    'duplicate_merge'=>'disabled'
    ),
    'account_manager_link' =>
    array (
    'name' => 'account_manager_link',
    'type' => 'link',
    'relationship' => 'account_manager_user',
    'vname' => 'LBL_ACCOUNT_MANAGER_USER',
    'link_type' => 'one',
    'module'=>'Users',
    'bean_name'=>'User',
    'source'=>'non-db',
    'duplicate_merge'=>'enabled',
    'rname' => 'user_name',
    'id_name' => 'account_manager_id',
    'table' => 'users',
    ),


    'relationships'=>array (
    'accounts_manager_user' =>
    array('lhs_module'=> 'Users', 'lhs_table'=> 'users', 'lhs_key' => 'id',
    'rhs_module'=> 'IC_GiftCardPartners', 'rhs_table'=> 'ic_giftcardpartners', 'rhs_key' => 'account_manager_id',
    'relationship_type'=>'one-to-many'),
    )

    2) in the detailviewdefs.php I added following to the panel section:
    1 =>
    array (
    'name' => 'account_manager_name',
    'label' => 'LBL_ACCOUNT_MANAGER',
    ), //don't forget to add LBL_ACCOUNT_MANAGER to the language file...
    3) same step above but in the editviewdefs.php
    John Zhang
    [Server: WinXP]
    [Sugar v5.0.0 GA]
    [Apache 2.2.5]
    [MySQL 5.0.45]

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 1
    Last Post: 2007-10-23, 10:05 PM
  2. Set the 'Assigned to' field to a Required Field
    By MIConsultancy in forum Help
    Replies: 1
    Last Post: 2007-07-05, 08:22 AM
  3. Focus Jumping Back To 'Assigned To' Field
    By fetsugar in forum Help
    Replies: 0
    Last Post: 2006-12-04, 09:50 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
  •