Results 1 to 3 of 3

Thread: Calculated Fields and Constants

  1. #1
    cygnusceo is offline Senior Member
    Join Date
    Dec 2008
    Posts
    28

    Default Calculated Fields and Constants

    I was looking for some ideas on the best way to drop a calculated field into my Module.

    2 challenges is the formula requires a Constant Value and and Entered Value.

    Example:
    Rate = $50.00
    Number of Hours = 10

    I have the Number of Hours in the Module Fields.

    Not really sure Where to Put the Rate Field (Probably as another Module that I will relate to) as I need to control that and not allow my employees to modify it.

    So now I have a Module Called Project Rates and I have a field in the module named Rate, and it is set to $50.

    I have related the Rate Module to my Job Module.

    Now I need to display the Rate Modules {Rate} x Job Module {NumberOfHours}.


    Any Ideas?

    Tia

    Jeff

  2. #2
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Calculated Fields and Constants

    Hi,

    firstly your rate value can go into the config table in sugar.
    have a look at the saveSetting and retrieveSettings methods in Administration
    (modules/Administration/Administration.php - around lines 147 and 83 respectively

    Then for you calculated field the easiest is to actually add an extra field for the calculated value and simply recalculate it in a before_save logic hook every time a record is saved.
    Last edited by mvngti; 2008-12-29 at 01:26 PM. Reason: typo
    --


    Marnus van Niekerk

    There are only 10 types of people in the world
    those who can read binary and those who don't

    Modules:
    CE Teams - Upgrade safe teams module for Community Edition
    FieldACL - Field Level Access Control for Community Edition
    EditLogicHooks - Create and edit Logic Hooks from the Admin GUI
    FlexibleChartDashlet - Display any data in a Dashlet Chart
    DocumentThumbnails - Thumbnails for Documents module

    Many questions can be answered by reading the Developers Manual

  3. #3
    cygnusceo is offline Senior Member
    Join Date
    Dec 2008
    Posts
    28

    Default Re: Calculated Fields and Constants

    Thanks for the Advice.

    Unfortunately that will not work in my situation as I have multiple Rates depending on type of Project.

    As for the Calculated Field I will give that a shot.

    Thanks

    Jeff
    Last edited by cygnusceo; 2008-12-29 at 04:20 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Calculated fields in 5.0
    By salimmohd82 in forum Developer Help
    Replies: 9
    Last Post: 2012-01-24, 09:35 PM
  2. Calculated Sum of 2 fields
    By kinshibuya in forum Help
    Replies: 14
    Last Post: 2008-11-04, 08:32 PM
  3. ireport - calculated fields
    By mikesolomon in forum Help
    Replies: 0
    Last Post: 2008-04-24, 01:58 PM
  4. Creating Fields - calculated fields and 'related' field
    By gipps in forum General Discussion
    Replies: 0
    Last Post: 2007-07-21, 11:17 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
  •