6 Replies Latest reply on Sep 9, 2013 3:07 PM by shae1725

    Help with a calculation

    shae1725

      Title

      Help with a calculation

      Post

           I have turned a field (A) in a portal into a button, I need help on how or if it is possible to build calculation which will populate a field in another related tables field with field (A) contents!

           I can script it ok but im trying to learn more about calculations so I can develop less reliance on scripts!

        • 1. Re: Help with a calculation
          philmodjunk

               Your button click requires that this take place as a script.

               In order to have this happen without a script (if it is even possible to do so), would require that you not click a button to make this happen.

               You could, for example, click a single value check box to enter a value into the field and then combination of calculations and relationships that refer to the value in this checkbox formatted field might produce the result that you want.

               But you'll need to describe the exact relationship, exactly what data you want copied to the related table and why before I can tell if it is even possible to do this without a script.

          • 2. Re: Help with a calculation
            shae1725

                 I am probably doing this wrong so I will discribe what i am trying to do

                 I have a portal (a)  from a related table on my layout contianing a range of products.

                 I want to be able to just click on any of these products in portal (a), create a new record in table (b) and add the products ID

                  

            • 3. Re: Help with a calculation
              philmodjunk

                   Yes, that can be done, but not as just  a calculation. It would need a script--which you say you already know how to do?

              • 4. Re: Help with a calculation
                shae1725

                     HELP ..... Forget about me saying I could script it!!!

                     The script i built on an earlier application using a button on a portal populates a named field on layout. I need to be able to add a record and populate a table field :(

                • 5. Re: Help with a calculation
                  philmodjunk

                       I will assume these tables and relationships for my answer. You'll need to adjust your implementation of this solution to fit your actual tables, relationships and fields:

                       ProductsToPick>-----Invoices------<LineItems>-----Products

                       Invoices::__pkInvoiceID = LineItems::_fkInvoiceID
                       Products::__pkProductID = LineItems::_fkProductID
                       Invoices::anyField x ProductsToPick::anyField  (with the x operator specified, it doesn't matter what fields are selected as match fields.)

                       For an explanation of the notation that I am using, see the first post of: Common Forum Relationship and Field Notations Explained

                       Your Layout is based on Invoices and you have a portal to ProductsToPick and a Portal to LineItems. A button located in the portal row of the portal to ProductsToPick will use the following script to create a new record in LineItems that is correctly linked to the current Invoices record and to a Record in Products. Note that ProductsToPick and Products, most cases, will be two Tutorial: What are Table Occurrences? of the same table and that is what my code assumes.

                       Set Variable [$InvoiceID ; value: Invoices::__pkInvoiceID ]
                       Set Variable [$ProductID ; Value: ProductsToPick::__pkProductID ]
                       Freeze Window
                       Go to Layout ["LineItems" (LineItems) ]
                       new Record/Request
                       Set Field [LineItems::_fkProductID ; $ProductID ]
                       Set Field [LineItems::_fkInvoiceID ; $InvoiceID ]
                       Go to Layout [Original Layout]

                  • 6. Re: Help with a calculation
                    shae1725

                         That looks the buisness :) your a star