1 2 Previous Next 22 Replies Latest reply on May 16, 2011 12:59 PM by philmodjunk

    How would i write this script

    user14040

      Title

      How would i write this script

      Post

      How do i write this script?

      If NP (No Plan) is selected minus Net Price from Total Summary (only minus from selected record).

        • 1. Re: How would i write this script
          RestaurantCharlie

          it seems more like a calculation then a script. In any event, your question is to vague...

          What do you want the script to do? All records on the same table, what fields, etc...

          • 2. Re: How would i write this script
            user14040

            I have 3 tables

            Table relationship

            Mass

            Dept 

            Field Report

            Mass [red] contains all of my machines, model numbers, serial numbers, contract pricing, expiration, customer information etc.

            Dept [green] contains all my department numbers which includes NP(No Plan)

            Field Report [blue] has a combination of them both.

            In the Mass table what I want to do is if the field NP is chosen from the drop down menu in the Dept table I want the Net price field in the Mass table to indicate $0.00 because I have a Total Summary field that adds up all the machine contracts.

            Sometime staff will put NP [No Plan] but foget to zero out the Net Price of the machine which causes a false total of all the machine I have under contract.

            I hope i explained it ok.

            Thanks

            • 3. Re: How would i write this script
              philmodjunk

              You might want use a script to clear the Net Price field for all related records in the Mass table when they select NP in the Dept table. That fixes this issue and puts more accurate information in place when you review data and/or construct other reports. It will also make for faster reporting and calculations as the calculation you want must be unstored since it refers to a field from a related table.

              A calculation such as:

              If ( Dept::NPfield ≠"NP" ; NetPriceField )

              Will work as long as you select the name of the top center table occurrence (MassCurrentAgree...) in the calculation's "...from the context of:" drop down at the top of Specify Calculation.

              • 4. Re: How would i write this script
                user14040

                Writing scripts is not one of my strong points and I tried what you listed but it does not do anything this is what i wrote

                If ( Dept::Dept ≠"NP" ; MassCurrentAgreement2011::list price)  

                End If

                I added [list price] to replace [net price] to test the script to make sure it does not delete all of the amounts in [Net Price] but it did not zero [list price] when it equaled [NP] after pressing the zero button I created to excute the script.  What am i missing?

                Thanks

                • 5. Re: How would i write this script
                  user14040

                  How to get it to zero list price with this code?

                  If ( Dept::Dept ≠"NP" ; MassCurrentAgreement2011::list price)  

                  • 6. Re: How would i write this script
                    aammondd

                    You need an "Else" before your End if to set the field to 0

                     

                    It doesnt do anything if the condition is not true unless you have an else.

                     

                     

                    • 7. Re: How would i write this script
                      philmodjunk

                      What I posted, was a calculation expresssion that you would enter into a calculation field. I is not a script step. This was an added suggestion if you did not choose to use a script to catch and correct the data entry error at the moment it occurs. As written it returns null if the field is not set. If you rewrite it as:

                      If ( Dept::Dept ≠"NP" ; MassCurrentAgreement2011::list price ; 0 )  

                      It will return a value of zero instead.

                      • 8. Re: How would i write this script
                        user14040

                        OK that worked it zeros everything the has NP  seliected but now it shows a ? in the other records that is not set as NP

                        • 9. Re: How would i write this script
                          philmodjunk

                          ? is Filemaker's way of saying "I can't display the data". It can simply be a case of a field that is too narrow to display the complete value. In those cases, you can see the value if you click into the field while in browse mode. In other cases, you have a value that isn't valid such as a calculation that divides by zero.

                          You'll have to investigate further to see what the case is here for your database.

                          • 10. Re: How would i write this script
                            user14040

                            This is the script NP does equal $0.00 but anything other then NO shows as a question mark.

                            Net Price Scritp

                            • 11. Re: How would i write this script
                              user14040

                              ok i will go through my field and calcualtions thanks

                              • 12. Re: How would i write this script
                                aammondd

                                If you are using a script the If statement works differently.

                                You are trying to use the if calculation syntax.

                                Script should look something like this

                                If [Dept::Dept ne "NP"]

                                  Set Field (fieldname = MassCurrentAgreement2011::list price)

                                Else

                                Set Field (fieldname = 0)

                                End If.

                                However as Phil suggests change your field to a calculation field and just use the calculation

                                • 13. Re: How would i write this script
                                  user14040

                                  I changed Field:List price to calculation but I get a question mark on records that are not "NP"

                                  Record 1 would show NP=$0.00

                                  Record 2 would show Premium = ?

                                  The field List pice has no other calculation except for If ( Dept::Dept ≠"NP" ; MassCurrentAgreement2011::list price ; 0 ) which is list as Unstored.

                                  So I dont know why List price is showing a question mark

                                  • 14. Re: How would i write this script
                                    philmodjunk

                                    Did you try clicking into the field while in browse mode? (Let's make sure to rule out the easy fix before digging deeper here.) If you can see the expected value when you entere the field, you just need to make the field wider to show the value.

                                    In which table did you define this calculation field?

                                    What is the relationship between Dept and MassCurrentAgreement2011? Is it a valid relationship when Dept::Dept ≠ "NP"?

                                    1 2 Previous Next