10 Replies Latest reply on Dec 18, 2009 9:08 AM by RCaauwe

    Pass a number to a field in a script

    RCaauwe

      Title

      Pass a number to a field in a script

      Post

      I have a script that lists everyone who is in a certain billing cycle ( 1 through 12 ).  Instead of modifying the Find in the script everytime for each billing cycle, I would like to be able to key in the billing cycle number at runtime, and have it passed to the Find.  Is this possible?

       

        • 1. Re: Pass a number to a field in a script
          philmodjunk
            

          Click the link at the bottom of this message and you'll see a recent thread where Ninja and I helped out another person who had the same basic question. You'll find two variations of the same basic method described.

           

          Script to display records before an input date

          • 2. Re: Pass a number to a field in a script
            RCaauwe
               I don't see where the script halts and asks the operator to key in the billing cycle that is to be printed.  I only want to print 1 billing cycle when this script runs.
            • 3. Re: Pass a number to a field in a script
              philmodjunk
                

              In the example given, the user enters that data in a field and then performs the script--presumably by clicking a button.

               

              If you want to, you can use the Show Custom Dialog step and select the data field as an Input field for this dialog in order to get the desired input from the user. That approach pops up a dialog where the user can enter data. Just make that the first step of one of the two example scripts posted in the other thread.

              • 4. Re: Pass a number to a field in a script
                RCaauwe
                  

                OK, here is what I have now:  (Unfortunately it isn't working)

                 

                Go To Layout ["Billing Cycle List" (Memberinfo Table)]

                Enter Find Mode []

                Show Custom Dialog ["Billing Cycle"; "Enter Billing Cycle below:"; Memberinfo Table::Bill Cycle]

                If [Get(LastMessageChoice) = 1]

                    Set Field (Memberinfo Table = Bill Cycle

                    Perform Find [Restore]

                End If

                 

                I'm probably making some stupid mistake, or have a gross misconception, but hey, I'm here to learn.

                • 5. Re: Pass a number to a field in a script
                  StellaLuna
                    

                  Pretty good guess!  Adjust it slightly as:

                   

                  Go To Layout ["Billing Cycle List" (Memberinfo Table)]

                  Enter Find Mode [uncheck pause]

                  Show Custom Dialog [OK; Cancel ; "Billing Cycle"; "Enter Billing Cycle below:"; Memberinfo Table::Bill Cycle]

                  If [Get(LastMessageChoice) = 1]

                      Set Error Capture [ On ]

                      Perform Find [remove restore]

                          If [ not Get ( FoundCount ) ]

                          Show Custom Dialog [ OK ; "No records found" ]

                          Go To Layout [ original layout ]

                          End If

                      Else

                  ... do whatever if the user selects cancel or no records found, such as return to prior layout etc.

                      End If

                   

                  added this - Not sure if Bill Cycle is global or not - no need for a global field.  The user puts the billing cycle number directly into the billing cycle field from within find mode and custom dialog.  I see you were trying to set it again (I think) so I thought I'd mention it.

                   

                  ooops I typed it without testing and I had just woke up. See added bold portion. Sorry. :womansad:

                  • 6. Re: Pass a number to a field in a script
                    RCaauwe
                       I have 2 questions:  1. How do you "remove restore" on the Perform Find?  2. What do I enter for Criteria when I do the find, in order to get all records from the billing cycle that was entered in the Custom Dialog box?
                    • 7. Re: Pass a number to a field in a script
                      MikeyG79
                        

                      Sometimes when I do finds, I have the script:

                       

                      Enter Find Mode

                      Set the field you want to find

                      Perform find

                      enter browse mode 

                      commit record 

                      • 8. Re: Pass a number to a field in a script
                        philmodjunk
                          

                        In Stella Luna's example, the custom dialog is entering the criteria for you when you click button 1 to dismiss the dialog. If you have additional criteria that need to be specified, you can add that with subsequent script steps. Let us know what you need and we'll walk you through it.

                         

                        To clear the "restore" parameter from a Perform Find script step, select it in the script editor and then clear the "Specify find requests' check box at the bottom of the editor.

                         

                         

                        • 9. Re: Pass a number to a field in a script
                          StellaLuna
                            

                           1. How do you "remove restore" on the Perform Find?  If you select that script step, you will notice bottom right ... if there is criteria in the specify portion, it will be checkmarked 'specify find requests' so just uncheck that.  Click the specify if you want to see what WAS entered there. 

                           

                          2. What do I enter for Criteria when I do the find, in order to get all records from the billing cycle that was entered in the Custom Dialog box?  You don't need to enter the criteria again.  Let's walk through it because it isn't the easiest thing to visualize:

                           

                          You have a field called Billing Cycle which contains a number 1-12.  When you open your Show Custom Dialog steps, you will see tab at the top called Input.   Put a check next to the 'show input field 1'  and click the Specify button.  It will open.  In there, you select your Billing Cycle field.   Now when the Custom Dialog opens (while in Find mode), it will ask for the billing cycle number.  Type your number there and say OK.

                           

                          There is no need to put that number anywhere else because you will now be searching the Billing Cycle field with the number you entered.  I hope that explains it better.  If not, ask away. :^)

                          • 10. Re: Pass a number to a field in a script
                            RCaauwe
                               Thank you so much!  It all works now.