5 Replies Latest reply: Feb 2, 2013 2:32 PM by Howard (... in Training) RSS

    Calculatef field on form

    patfmnd
      Hi,
      I have a table of historic data that includes a field which is a decimal value. Going forward, I want to calculate that field in the data entry form (columnA/columnB) and have that value fill the column.
      I have seen several examples of javascript for doing a calculated field in a form. My question is, how do you set the Page Item properties for the calculated field -- particularly the Source attributes if I want the calculated value to go into a table column field? Do I need separate forms for update vs. data entry since the update form will be just retrieving values vs. the data entry form which will need to do the calculation prior to data entry.

      Finally, is there any other property of the page item or page processing I need to 'adjust' due to this calculated value. I am on Apex 4.2.1

      Thanks,
      Pat
        • 1. Re: Calculatef field on form
          Howard (... in Training)
          Pat,

          Okay. You speak of an historical data table and a data entry form. Are you filling the form and then writing the record(s) to the table? Are these all inserts to the table. Any updates to or deletes from the table?

          Or, do you just need the calculated value to display on the form and nothing is written back to the table?

          Howard
          • 2. Re: Calculatef field on form
            patfmnd
            Howard,
            Thanks for the reply. Yes, I want to write the record back to the table. And yes, I may also be doing updates and deletes of records as well. I wanted the calculated field to be written to the table in the field columnC that will hold the result of the calculation on the form (which result from columnA/columnB).

            Pat
            • 3. Re: Calculatef field on form
              patfmnd
              An update--
              I was able to create Javascript based on Denes Kubicek's early posting on this and his nice site where he let's you see his code!!! ( I wish other Apex ACE's would do that!!) So I can calculate the ratio of columnA/columnB and it shows up in columnC. I can also get the calculated value into the table.

              Now my problem is this -- the calculated field works fine and I am also able to get the updated data into the table, however, when I bring up the form to do further updates on another record, it is apparently bringing up the 'cached' value of the session and I have to go back to the field where the javascript is called to get the correct calculated value. How do I get the Form to show the current value and only calculate or re-calculate a value when there is a change in the related fields-- in other words, columnA or columnB changes and so re-calculate, otherwise, just show existing values?

              Thanks for any advice,

              Pat
              • 4. Re: Calculatef field on form
                Howard (... in Training)
                I guess it depends when/whether you want the field recalculated.

                How about a dynamic action (DA) that recalculates that field whenever you load that form and another one (or two) for whenever you change either of the values it depends on?

                Howard
                • 5. Re: Calculatef field on form
                  patfmnd
                  Can you give me some idea how I would go about doing that with dynamic actions?

                  Thanks,
                  Pat