1 2 3 Previous Next 33 Replies Latest reply on Jan 24, 2012 4:15 PM by philmodjunk

    Problem with script button! Help!

    PedroMarroquin

      Title

      Problem with script button! Help!

      Post

      I got one table of invoices and that table is used in 3 different layout: Private, Water Co. and Electricity Co. One of the guys of the forums Phil told me to set a script button where I go insert this script to the button that takes me to each layout with the right names of the layout. This was to separate the Private Records from the Water Co. Records and the Electricity Records... and i set it but it doesn't work! When I'm doing a New Private Invoice it appears the invoices form Water Co and Electric Co. 

       

      this is the script:

       

       put "Private" in the options script parameter box of the perform script of the button setup.

      Set it to run this script:

      Go To layout [PrivateInvoices]
      Enter Find Mode [] //clear pause check box
      Set field [Invoices::InvoiceType ; Get ( ScriptParameter ) ]
      Set Error Capture [on]
      Perform Find[]
      Go to record/Request/Page [last]

       

      what sould i do?!

        • 1. Re: Problem with script button! Help!
          philmodjunk

          Best guess is that your find isn't finding the records you would expect to find.

          Try removing the Set error capture step as a test and run the script. What do you see? Any error messages? If no error messages, put it back and make additional tests.

          Add a show custom dialog with get (ScriptParameter) in it to see what value was passed in your parameter.

          Perform your own manual find with this data entered into the invoice type field. What records do you find?

          • 2. Re: Problem with script button! Help!
            PedroMarroquin

            Phil i think i know what's the problem, I have the invoicetype field but not in the layout I mean i thought that the script automatically recorded if teh record is Private, Electric o Water... I don't want the suer to set what type of invoice is, what can i do to be like a calculation or a script?

            • 3. Re: Problem with script button! Help!
              philmodjunk

              Do you mean that InvoiceType does not have data in it to identify the type of invoice? This info should be auto-entered by the system each time a record is created. You can define an auto-enter calculation that checks the current layout in order to enter the correct type.

              Is this what you mean?

              • 4. Re: Problem with script button! Help!
                PedroMarroquin

                Yes that is correct! I does not have the invoictype field in the layout i wanted to make an autoenter calculation yes! Would yo help me?

                • 5. Re: Problem with script button! Help!
                  philmodjunk

                  To add an auto-enter calculation to a data field, open Manage | Database | Fields, find the field's definition and double click it. Then select the calculation option from the auto-enter tab...

                  I'll give you several examples to pick from.

                  1) If your layout names are exactly the same as your invoice types you can use this auto enter calculation:

                  Get ( LayoutName )

                  2) If the names are not quite the same, you can use a case function such as:

                  Let ( L = Get ( LayoutName ) ;
                          Case ( L = "LayoutName1" ; "InvoiceType1" ;
                                      L = "LayoutName2" ; "InvoiceType2" ;
                                     L = "LayoutName3" ; "InvoiceType3";
                                     "Unknown Type" ) )

                  You'd edit the above expression to use the actual layout names and invoice types you need for your database.

                  3) use the scripts that navigate the user to each invoice layout to update a global variable with this info:

                  Set Variable [$$InvoiceType ; value: Get ( ScriptParameter ) ]

                  Then your auto enter calculation could be just:

                  $$InvoiceType

                  • 6. Re: Problem with script button! Help!
                    PedroMarroquin

                    so Phil the layout names are not quite the same so I'll use the 2 calculation: 

                     

                    Let ( L = Get ( LayoutName ) ;
                            Case ( L = "Common_Private" ; "Private" ;
                                        L = "Govt_WaterCo" ; "WaterCo" ;
                                       L = "Govt_ElectCo" ; "ElectCo";
                                       "Unknown Type" ) )
                     
                    like that? but I dind't understood the 3 point you said to use the scripts that I use to navigate to each invoice layout to update a global variable with the info you gave.. the thing is that the button that I use to navigate to each different layout already have a script the one you gave me...:
                     

                     put "Private" in the options script parameter box of the perform script of the button setup.

                    Set it to run this script:

                    Go To layout [PrivateInvoices]
                    Enter Find Mode [] //clear pause check box
                    Set field [Invoices::InvoiceType ; Get ( ScriptParameter ) ]
                    Set Error Capture [on]
                    Perform Find[]
                    Go to record/Request/Page [last]

                      shall I add that line you said?

                    • 7. Re: Problem with script button! Help!
                      philmodjunk

                      You don't need to do both, just one or the other. If the calculation using a Case function makes sense to you, just use it and don't worry about any global variables.

                      Use the global variable if you decide you want to use that method in place of the Case Function in your auto-enter calculation.

                      Set Variable [$$InvoiceType ; get ( ScriptParameter ) ]
                      Go To layout [PrivateInvoices]
                      Enter Find Mode [] //clear pause check box
                      Set field [Invoices::InvoiceType ; Get ( ScriptParameter ) ]
                      Set Error Capture [on]
                      Perform Find[]
                      Go to record/Request/Page [last]

                      • 8. Re: Problem with script button! Help!
                        PedroMarroquin

                        So I think the auto enter calc make more sense to me than the script so if I don't need both, In the button setup that takes me to every layout I remove the script you gave me and in theory the auto-enter would work automatically separating each record into each layout right?

                        • 9. Re: Problem with script button! Help!
                          philmodjunk

                          NO.

                          Keep the script, keep the auto-enter calculation. Just don't use the script to set a global variable.

                          The script pulls up the records that are appropriate for the specified layout. The auto-enter calculation labels each new invoice record with a "type" value consistent with the current layout.

                          • 10. Re: Problem with script button! Help!
                            PedroMarroquin

                            Phil I set the auto -enter but it still mix records... I think the problem must be in the script

                             put "Private" in the options script parameter box of the perform script of the button setup.

                            Set it to run this script:

                            Go To layout [PrivateInvoices]
                            Enter Find Mode [] //clear pause check box
                            Set field [Invoices::InvoiceType ; Get ( ScriptParameter ) ]
                            Set Error Capture [on]
                            Perform Find[]
                            Go to record/Request/Page [last]

                             

                            I think the problem in the options cript parameter box, I need to put the mae of the layout that's going to right?

                            • 11. Re: Problem with script button! Help!
                              philmodjunk

                              You need to put whatever text you use to identify the type of invoice so that the find can only find those records.

                              Let's simplify things. Don't use any script parameter at all.

                              Create one script for each layout for use with your buttons.

                              Take this script:

                              Go To layout [PrivateInvoices]
                              Enter Find Mode [] //clear pause check box
                              Set field [Invoices::InvoiceType ; "private" ]
                              Set Error Capture [on]
                              Perform Find[]
                              Go to record/Request/Page [last]

                              You can use the duplicate button in manage scripts to make two copies of this script. Then edit the two lines shown in bold to specify a different layout and a different invoice type to get three different scripts, one for each layout.

                              • 12. Re: Problem with script button! Help!
                                PedroMarroquin

                                I set it up Phil and it doesn't work... What should I do? 

                                • 13. Re: Problem with script button! Help!
                                  PedroMarroquin

                                  In the auto-enter calc:

                                   

                                  Let ( L = Get ( LayoutName ) ;

                                          Case ( L = "Common_Private" ; "Private" ;
                                                      L = "Govt_WaterCo" ; "WaterCo" ;
                                                     L = "Govt_ElectCo" ; "ElectCo";
                                                     "Unknown Type" ) )
                                   
                                  the Get (LayoutName) is correct?
                                  • 14. Re: Problem with script button! Help!
                                    PedroMarroquin

                                     wait I think there's a problem with the script, every time I go to each different invoice layout whether Private or WaterCo or Elect Co, the records appear unsorted... it appears in the rolodex 0/7 (Unsorted) I have the go to Show all records in order to see any records... isn't it missing a csript line?

                                    1 2 3 Previous Next