Results 1 to 9 of 9

Thread: Calculated Fields

  1. #1
    alexbloom is offline Junior Member
    Join Date
    Feb 2009
    Posts
    1

    Default Calculated Fields

    I am trying to create a calculated field either in a report or in the opportunity module. Currently I would like to just multiply the probability by the amount.

    I have seen many programmatic methods, and custom hooks etc. Unfortunately I do not have the ability to modify the .php etc. at this time.

    Is there anyway to set a datatype to "calculated" within the module builder for simple mathematical calculations? I have searched fairly extensively and can not seem to find anything. If not, are there any future plans for 5.5?

    Thank you,

    Alex
    Version 5.2.0e (Build 5626)

  2. #2
    ishaan is offline Senior Member
    Join Date
    Apr 2009
    Location
    Mumbai,India
    Posts
    100

    Default Re: Calculated Fields

    Hi Alex ,

    I dont know about the future plans but rite now you can write a logic hook for it that can be implemented on after/before save event.
    For dynamically multiplying fields you will have to write a javascript code.

    If u need assistance in writing such code , feel free to ask me

    Cheers,
    Ishaan

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

    Default Re: Calculated Fields

    Quote Originally Posted by ishaan View Post
    For dynamically multiplying fields you will have to write a javascript code.
    Could you be more specific on that? I too need to create a calculating fields and can do some JS scripting, but I have no idea where to put it.

    I have very simple form with 3 fields: Item Type, Quantity and Sum. When I choose type and enter quantity, total amount in Sum field should appear. It's a super simple JS script.

    Should I just put in header a link to script.js file with corresponding function? Is it enough?

  4. #4
    ishaan is offline Senior Member
    Join Date
    Apr 2009
    Location
    Mumbai,India
    Posts
    100

    Default Re: Calculated Fields

    Hi,

    Here u go.....

    go to custom/modules/<your module>/metadata/editviewdefs.php

    add
    Code:
    'includes' => 
          array (
            0 => 
            array (
              'file' => 'custom/modules/<your module>/yourjavascriptfunction.js',
            ),
          ),
    into the 'templateMeta'

    put your javascript file in custom/modules/<your module> directory.


    add the following custom code to both the fields which u want to multiply

    Code:
    'customCode' => '<input id="field_1" type="text" tabindex="0" title="" value="{$fields.field_1.value}" size="30" name="field_1" onchange="yourJavascriptFunction();"/>',

    may this help u


    Cheers,
    Ishaan

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

    Default Re: Calculated Fields

    Quote Originally Posted by ishaan View Post
    Hi,
    Here u go.....
    Quite clear, except that I don't have "my module" :-)

    I am going to create a simple layout for Opportunity or Sales page. So I should put JS in Opportunity or Sales folder and do the stuff above for corresponding modules, right?

  6. #6
    ishaan is offline Senior Member
    Join Date
    Apr 2009
    Location
    Mumbai,India
    Posts
    100

    Default Re: Calculated Fields

    rite ......

    Cheers,
    Ishaan

  7. #7
    grecstar is offline Member
    Join Date
    Jun 2009
    Posts
    13

    Default Re: Calculated Fields

    ishaan,
    I need to do this too. What would the javascript file look like?
    Thanks

  8. #8
    ishaan is offline Senior Member
    Join Date
    Apr 2009
    Location
    Mumbai,India
    Posts
    100

    Default Re: Calculated Fields

    Quote Originally Posted by grecstar View Post
    ishaan,
    I need to do this too. What would the javascript file look like?
    Thanks

    Hi grecstar,

    The javascript file should be like

    Code:
    function yourjavascriptfunction(){
    document.EditView.amt1_c.value         // this way you can access the fields 
    }

    Hope this is clear now.

    Any queries you can also reach me at ishaan.guliani@gmail.com

    Cheers,
    Ishaan

  9. #9
    Secret_Agent_99's Avatar
    Secret_Agent_99 is offline Senior Member
    Join Date
    Jan 2010
    Location
    Island of Unknown Orgin
    Posts
    27

    Question Re: Calculated Fields

    Quote Originally Posted by ishaan View Post
    Hi grecstar,

    The javascript file should be like

    Code:
    function yourjavascriptfunction(){
    document.EditView.amt1_c.value         // this way you can access the fields 
    }
    Hi,
    I don't see how that javascript file can be added to the edit view in sugar.
    Is that the actual code to make it function to sum up the fields together.

    Thanks
    Agent 99
    Secret Service

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, 08:35 PM
  2. Calculated Fields and Constants
    By cygnusceo in forum Developer Tutorials
    Replies: 2
    Last Post: 2008-12-29, 03:15 PM
  3. Calculated Sum of 2 fields
    By kinshibuya in forum Help
    Replies: 14
    Last Post: 2008-11-04, 07:32 PM
  4. Creating Fields - calculated fields and 'related' field
    By gipps in forum General Discussion
    Replies: 0
    Last Post: 2007-07-21, 10: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
  •