Results 1 to 4 of 4

Thread: Show field from one module in another

  1. #1
    marcpeterson is offline Junior Member
    Join Date
    Jul 2007
    Posts
    3

    Default Show field from one module in another

    I've been trying advice from the forum and wiki for two days straight without success, so hopefully someone can help me.

    I have a custom field in Accounts that I would like to appear in the detailed view of a Contact. Can anyone give me clear, step-by-step instructions on how to do so?

  2. #2
    Superman's Avatar
    Superman is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    Kazakhstan
    Posts
    852

    Default Re: Show field from one module in another

    In DetailView.php of Contacts module after you've got $focus->account_id you are able to initialize Accounts object by doing this:
    PHP Code:
    $account = new Account();
    $account->retreive($focus->account_id); 
    after that do:
    PHP Code:
    echo "<pre>";
    print_r($account);
    echo 
    "</pre>"
    look at DetailView screen of Contacts module and see what property you should use to retreive Accounts' custom field.

    Does it make sense?
    Farkhad Rakhimzhanov
    E-mail: farkhad@gmail.com
    Skype: rakikama

    SuperTimesheet and Invoicing — timesheet tool with invoicing for SugarCRM.
    Book time against Cases, Project Tasks and Projects.
    Create invoice regarding booked time, print it in PDF or HTML,
    customize template as you like.

  3. #3
    marcpeterson is offline Junior Member
    Join Date
    Jul 2007
    Posts
    3

    Default Re: Show field from one module in another

    That's good to know, but I should have been more descriptive in my objective.

    I'd like to add custom fields from Accounts into Contacts in such a way that they appear in the module editor. By doing it this way, all changes will remain after an upgrade and after a page-publish, right? Everything I've read points to changes in vardefs.php, Contact.php, and DetailView.php but none of my modifications work.

  4. #4
    Superman's Avatar
    Superman is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    Kazakhstan
    Posts
    852

    Default Re: Show field from one module in another

    In that case i could see such workaround which would be upgrade safe.

    Create custom field in Contacts module which would have preferrably same name as in Accounts.
    You will have to create logic hooks (for more info go to SugarWiki) for events in Contacts module "after_retrieve" and "before_save".
    "after_retrieve" hook should get custom field from Account module and pass it to Contacts' custom field. So, after you've created such a hook, you are able now from Studio add this custom field to any of the Contacts module screens (detail, edit; not sure about List).
    "before_save" hook is needed to write custom field value of contacts module to custom field of accounts module. So you handle custom field storing into Accounts module, and not to Contacts.

    Have you got the idea?
    Farkhad Rakhimzhanov
    E-mail: farkhad@gmail.com
    Skype: rakikama

    SuperTimesheet and Invoicing — timesheet tool with invoicing for SugarCRM.
    Book time against Cases, Project Tasks and Projects.
    Create invoice regarding booked time, print it in PDF or HTML,
    customize template as you like.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Module Builder
    By Olavo in forum Downloads
    Replies: 418
    Last Post: 2009-02-26, 06:36 AM
  2. Replies: 1
    Last Post: 2006-09-11, 03:38 PM
  3. Replies: 0
    Last Post: 2006-06-21, 07:47 PM
  4. Adding custom field when creating module.
    By Superman in forum General Discussion
    Replies: 1
    Last Post: 2005-11-16, 07:30 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
  •