Results 1 to 6 of 6

Thread: populate multiple fields with an onchange event

  1. #1
    danrweki is offline Senior Member
    Join Date
    Jun 2008
    Location
    East Africa (Uganda)
    Posts
    111

    Default populate multiple fields with an onchange event

    Hallo Developers

    i have a problem, i created a packages module and with that you can be able to attach a package to an account. At the same time i have some sort of billing module, and when i attach an account to a bill i want the fields in the bill module to populate the data of the package the account has been attached to. how possible is that, if it is where do i start.

    Can someone please assist me
    Last edited by danrweki; 2008-08-06 at 10:55 AM.

  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: populate multiple fields with an onchange event

    Hi, danrweki

    Can you explain the workflow you want to implement? For example:
    Create a Package
    Create a Bill
    Create an Account
    Assign an Account to Bill
    and so on.

    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
    danrweki is offline Senior Member
    Join Date
    Jun 2008
    Location
    East Africa (Uganda)
    Posts
    111

    Default Re: populate multiple fields with an onchange event

    Ok here it is

    1. Packages are already created an are not attached to a bill or an account

    2. Create an account. In the form you have a relate field that relates and existing package to the account.
    now the account form also has filds that are the same as the package fileds so that when you select the package to attach it populates those fields with the existing package definition

    3. Then you create a bill, the bill form also has fields that are the same as packages so that when i attach the account to the bill the package properties of that account populate in the fields of the bill module

    say for example

    Package module has the following fields
    package name,
    service type
    tarrifplan

    Account module has

    account name
    account type
    package(relatefield)
    service type(auto populated respective to the package chosen)
    tarrifplan(auto populated respective to the package chosen)

    Billing module has
    bill number
    accountname
    servicetype((auto populated respective to the account chosen)
    tarrifplan(auto populated respective to the package chosen)


    i hope this gives an idea

  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: populate multiple fields with an onchange event

    Ok, danrweki

    I got it now.

    What do you have to do:

    Take a look at the script include/SugarFields/Fields/Relate/SugarFieldRelate.php between lines 93 and 95

    PHP Code:
            $field_to_name = array();
            
    $field_to_name['id'] = $vardef['id_name'];
            
    $field_to_name['name'] = $vardef['name']; 
    This piece of code tells sugar to automatically populate these field when the record is selected from popup.
    Did you get it?

    What do you have to do?
    Duplicate this directory include/SugarFields/Fields/Relate with the name:
    include/SugarFields/Fields/AccountRelate
    include/SugarFields/Fields/BillRelate

    Make the necessary changes into the new classes (file name, class name, constructor, path to templates) and add in these lines the fields you want to acquire from other module when selecting a new record.

    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.

  5. #5
    danrweki is offline Senior Member
    Join Date
    Jun 2008
    Location
    East Africa (Uganda)
    Posts
    111

    Default Re: populate multiple fields with an onchange event

    Thanx my man, i think this is a good start, i will get cracking on this, am sure i will get somewher..if i get problems i will getback to you....


  6. #6
    danrweki is offline Senior Member
    Join Date
    Jun 2008
    Location
    East Africa (Uganda)
    Posts
    111

    Default Re: populate multiple fields with an onchange event

    i have duplicated as you have said, but am not even sure that sugar knows the file exists because nothing is happening to the package relate field in the acoounts edit view,

    how do i tell sugar that this new duplicated file exists and that it is for packages, for example in the file am duplicating i see a line like this

    //Special Case for accounts; use the displayParams array and retrieve
    //the key and copy indexes. 'key' is the suffix of the field we are searching
    //the Account's address with. 'copy' is the suffix we are copying the addresses
    //form fields into.
    if(isset($vardef['module']) && preg_match('/Accounts/si',$vardef['module'])

    in my new file i put, /wp_packages/si

    then

    $field_to_name['fixed_line_voice'] = $vardef['fixed_line_voice'];
    $field_to_name['ipcentrex'] = $vardef['ipcentrex'];

    These iare the fields i want populated when a package is chosen on the account creation screen

    What then, thank you

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Dangers with Multiple Select Fields Part 1 - Editing
    By neilt in forum Feature Requests
    Replies: 1
    Last Post: 2011-09-27, 09:58 PM
  2. Replies: 0
    Last Post: 2007-06-16, 02:20 PM
  3. Replies: 0
    Last Post: 2007-04-03, 06:40 AM
  4. Replies: 1
    Last Post: 2006-11-24, 12:08 AM
  5. Custom Fields
    By scourtney2000 in forum General Discussion
    Replies: 0
    Last Post: 2006-02-09, 04:00 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
  •