Results 1 to 4 of 4

Thread: Cumulative fields (like post address)

  1. #1
    Monkeyman is offline Senior Member
    Join Date
    May 2009
    Posts
    55

    Default Cumulative fields (like post address)

    How can I create cumulative fields like default post address field?
    I mean, when I create 3 fields and their values display with given order in the 4th field.

    For example, there are 3 fields:

    F1: Dude,
    F2: is my car?
    F3: where

    And 4th field displays it in order F1+F3+F2 which gives us:

    F4: Dude where is my car?

  2. #2
    FishGuts is offline Senior Member
    Join Date
    Apr 2009
    Posts
    26

    Default Re: Cumulative fields (like post address)

    Hi,

    Maybe you could try creating a logic hook. That's what I did the other day, and it worked! I had the same issue - I needed to set the value of a field by concatenating the values of two other fields. So here's what I did:

    1. Created the file custom/modules/ModuleName/SetField.php, containing the code:

    PHP Code:
    <?php
    require_once('data/SugarBean.php');
    require_once(
    'include/utils.php');
    class 
    SetField {
        function 
    setField(&$bean$event$arguments) {
            
    $new_value $bean->field1 '  ' $bean->field2;
            
    $bean->field3 $new_value;
        }
    }
    ?>
    2. Created the file custom/modules/ModuleName/logic_hooks.php, containing the code:

    PHP Code:
    <?php
    $hook_version 
    1;
    $hook_array = Array();
    $hook_array['before_save'] = Array();
    $hook_array['before_save'][] = Array(1'setField''custom/modules/ModuleName/SetField.php','SetField''setField');
    ?>
    This solution doesn't set 'field3' while you're typing field1 and field2; it waits until you click Save. It's a 'before_save' logic hook. The Sugar Developer Guide describes all the other types of logic hooks available.

    I hope this all helps.

    AG

  3. #3
    Monkeyman is offline Senior Member
    Join Date
    May 2009
    Posts
    55

    Default Re: Cumulative fields (like post address)

    That's great! Thatnk you very much!
    Worked perfect for me.

  4. #4
    Monkeyman is offline Senior Member
    Join Date
    May 2009
    Posts
    55

    Default Re: Cumulative fields (like post address)

    Found a small problem with that. If you have a dropdown menu, then chosen value is being added, not label as needed.

    For example, I have a dropdown country list translated to German. If I choose "Russland" in list, it'll add "RUSSIA" in cumulative field since it's a value.

    How can I make it add labels, not values?

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Post Upgrade - Custom Dropdown Fields damaged
    By fibbert in forum Installation and Upgrade Help
    Replies: 0
    Last Post: 2008-01-17, 02:48 AM
  2. Dropdown for country value in address fields
    By gladiorlic in forum Help
    Replies: 0
    Last Post: 2007-01-26, 12:29 PM
  3. Merged Fields - like First name & Address
    By russellp in forum Help
    Replies: 0
    Last Post: 2006-10-02, 09:23 AM
  4. Address Fields
    By rateck in forum Feature Requests
    Replies: 0
    Last Post: 2004-09-09, 08:07 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
  •