Results 1 to 10 of 10

Thread: Contacts module custom field issue

  1. #1
    honeybee1 is offline Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Default Contacts module custom field issue

    I like to add a checkbox to contacts module, which value should be checked/unchecked based on a condition. The condition is if the contact extsts in the prospects list, then the check box should get checked.
    How can this be done? Thanks in advance.

  2. #2
    jim.thornton is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    257

    Default Re: Contacts module custom field issue

    I'm not a pro by any means, but it sounds like if you do what you want, you will have to go in and add custom PHP coding into some files (I don't know which one).

    Why don't you just add a relate field. That way when you are entering in a new contact, you can start to type the name for the prospect and Sugar, using ajax, will populate the field if the name is in the propspects list. You will also have the ability to click SELECT and then search for the prospect.

    I think it would be much easier, the other way probably isn't upgrade safe either.
    ________
    Sharif
    Last edited by jim.thornton; 2011-09-08 at 04:35 AM.

  3. #3
    honeybee1 is offline Junior Member
    Join Date
    Mar 2009
    Posts
    2

    Default Re: Contacts module custom field issue

    Thank you very much for the response jim.thornton.
    I am fairly new to sugarCRM. Can you please detail a little bit & help me out?

  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: Contacts module custom field issue

    Hi honeybee

    Do you want to get this field displayed into both DetailView and EditView or only into one of these views?

    For EditView:
    You need to:
    1. create a custom controller for Contacts module (custom/modules/Contacts/controller.php) and implement the function action_editview;
    2. Create an extended vardefs for Contacts module (custom/Extension/modules/Contacts/Ext/Vardefs/vardefs,ext,php) to add the checkbox field definition into it. This field must have the attribute 'souce' set as 'non-db'. Remember to go into Admin -> Repair -> Rebuild Extension;
    3. Create a sql query which identifies is this contact exist into some specific Prospect List. If yes set the checkbox as checked;

    Done
    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
    honeybee2 is offline Member
    Join Date
    Mar 2009
    Posts
    5

    Default Re: Contacts module custom field issue

    Hi Andopes,

    Thank you so much for the response.

    I had problems with 'honeybee1', this account has been locked out. I created another account with 'honeybee2'.

    Can you pleas ehelp me out by check thid code? Not sure am I in the right direction. Many thanks for yur help.

    I added the following code:

    I added a custom check box field to contacts module with name 'my_customfield_c'. Nt sure if this is required.

    To custom/Extension/modules/Contacts/Ext/Vardefs/Vardefs.Ext.php

    <?php

    $dictionary["Contact"]["fields"]["my_customfield_c"] = array (
    'name' => 'my_customfield_c',
    'source' => 'non-db',
    'vname' => 'LBL_MY_CUSTOMFIELD_C',
    'save' => true,
    'module' => 'ProspectLists',

    );
    ?>

    custom/modules/Contacts/controller.php
    <?php
    require_once('include/MVC/Controller/SugarController.php');
    require_once('modules/Contacts/ContactsEditView.php');

    class ContactsController extends SugarController {
    function action_editview() {
    $isRecExists =new ContactsEditView();

    if ($isRecExists != null) $this->bean->my_customfield_c = 'Checked';
    }
    }
    ?>

    Wrote a query to check the record in ContactsEditView() ;

  6. #6
    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: Contacts module custom field issue

    custom/Extension/modules/Contacts/Ext/Vardefs/Vardefs.Ext.php
    <?php
    $dictionary["Contact"]["fields"]["my_customfield_c"] = array (
    'name' => 'my_customfield_c',
    'source' => 'non-db',
    'vname' => 'LBL_MY_CUSTOMFIELD_C',
    'type' => 'bool',
    );?>

    custom/modules/Contacts/controller.php
    <?php
    require_once('include/MVC/Controller/SugarController.php');
    require_once('modules/Contacts/ContactsEditView.php');

    class ContactsController extends SugarController {
    function action_editview() {
    $isRecExists =new ContactsEditView();

    if ($isRecExists != null) $this->bean->my_customfield_c = 'Checked';
    }
    }?>

    I believe this is the correct content.

    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.

  7. #7
    honeybee2 is offline Member
    Join Date
    Mar 2009
    Posts
    5

    Default Re: Contacts module custom field issue

    Hi Andpes,

    Thank you fr the rresponse. after I made the changes, and rebuild, the edit form is not coming up in the edit view.

    for simplicity sake and for testing, I am using the following code for controller.php
    I tried '1' instead of 'Checked', still the same problem. Adding the custm field with this is right thing? Filename and paths seems to be correct. No clue what might be the reason. Any ideas, please help me.

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

    class ContactsController extends SugarController {
    function action_editview() {
    $this->bean->my_customfield_c = 'Checked';

    }
    }
    ?>

  8. #8
    honeybee2 is offline Member
    Join Date
    Mar 2009
    Posts
    5

    Default Re: Contacts module custom field issue

    Nevermind. I forgot add

    $this->view = 'edit';

    Seems working fine. Thank you so much for your help.

  9. #9
    honeybee2 is offline Member
    Join Date
    Mar 2009
    Posts
    5

    Default Re: Contacts module custom field issue

    Hi andopes,

    One more quick question. How can we write custom code (like executing the query) while saving in the edit view? Is there a function like action_EditView?
    Fr ex, If I want to save data in one of the table created by me.
    Where can I find all these information?

    Thank you for your patience.
    Last edited by honeybee2; 2009-03-10 at 11:32 PM.

  10. #10
    jjwdesign's Avatar
    jjwdesign is offline Sugar Community Member
    Join Date
    Dec 2006
    Location
    Orlando, FL
    Posts
    503

    Default Re: Contacts module custom field issue

    You could write the code into a logic hook. See the logic hook section in the developer docs.
    SugarForge Projects:
    JJWDesign Google Maps
    JJWDesign Tools and Reports

    Follow my blog postings at JJW Design.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Search and Custom Field Issue
    By kwoodall in forum Help
    Replies: 8
    Last Post: 2009-02-20, 06:13 AM
  2. Replies: 1
    Last Post: 2009-01-31, 07:34 AM
  3. Replies: 0
    Last Post: 2008-02-20, 03:23 PM
  4. Checkbox custom field issue
    By andreasw in forum Help
    Replies: 7
    Last Post: 2006-07-20, 04:47 PM
  5. Custom Field Issue still lingering
    By rengstrom in forum General Discussion
    Replies: 9
    Last Post: 2005-06-07, 07:37 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
  •