6 Replies Latest reply on Mar 28, 2013 8:23 AM by BryanN

    Script to run Report in New Window

    BryanN

      Title

      Script to run Report in New Window

      Post

           I'm a bit stuck here.  The goal here is:

             
      1.           User clicks the print button, it opens a new window where they can choose for what month to show in the report
      2.      
      3.           Once month is chosen, user clicks "OK", bringing up a second new window (closing the first) displaying the report
      4.      
      5.           The report, fetches only jobs that are planned on the month that matches what the user selected (and a few other criteria that are in the background that aid in the accuracy of the find
      6.      
      7.           User can print, save, etc, and close window when done.

            

           For the month being chosen, I couldn't figure out any way to store the user's selection other than in a global field in the table that the report is based on.  The data comes out fine but I'm having issues being able to find the correct data.  When doing a find, the global field is grayed out and can't be selected for search criteria.  What I'm trying to accomplish is:

           Find jobs that: PriorityMonth = global field AND JobStatus ≠ Closed

           If I do a manual find in the report's layout (making muliple requests), one including jobs that match "March" for example and omitting jobs that have a status of "Closed" it puts out the right data.  Any ideas on how I can have it compare to the global field in order to return only those results?

             

        • 1. Re: Script to run Report in New Window
          philmodjunk

               See this thread for multiple examples of scripted finds that use data entered in global fields to produce the needed find criteria: Scripted Find Examples

          • 2. Re: Script to run Report in New Window
            BryanN

                 Thanks for the post. Definitely has me in the right direction.  Here is a question for ya.  My database is running in the separation model (working out great by the way thanks!).  I have 2 tables in my UI file (global and startup) and the rest of my tables (including a global and startup table) are in the data file.  Which table should I be storing these global fields in?  Also, along with that, do my startup or global tables in either file need to be relationally connected to my other tables in order to be able to use their values (I don't see a way to do this but I'd rather just ask than assume).

                  

                 Thanks!

            • 3. Re: Script to run Report in New Window
              philmodjunk

                   I can't think of any reason for keeping the tables in the UI file, but then I don't know how you are using your startup table.

                   For your global fields table, as long as you have a table occurrence to it in the UI file, the global fields will be accessible from any script, layout, record in your UI file without need of a relationship. For any nonglobal field, the table it is defined need only be linked to other tables in relationships if access via a relationship is needed. If you only access the fields in your startup table from a layout based on an occurrence of that table, then no relationships are needed.

                   The only data I might store in the UI file are fields that store release info on the UI file such as the date and version number. A script can check similar fields in a table in the data file and throw an error if they don't match, telling the user that they are using an out of date copy of the UI file--this can be helpful if client machines use a local UI file instead of one hosted from the server.

              • 4. Re: Script to run Report in New Window
                BryanN

                     The startup tables are on both the UI and data file and are simply used to base the startup layouts on so there is minimal resource impact from just signing in.  I put a globals table in the UI file in case I ever decided to input user preferences, but I wasn't sure if I should store search globals as well.

                      

                     So what you are saying is that as long as it's checked as a global, any layout based on any table (as long as there is an occurance) should be able to edit the global field?

                • 5. Re: Script to run Report in New Window
                  philmodjunk

                       Your user preferences data can be stored in the data file. I don't see an advantage to putting it in the UI file.

                       

                            So what you are saying is that as long as it's checked as a global, any layout based on any table (as long as there is an occurance) should be able to edit the global field?

                       Yes. The only reason not to put a global field into a dedicated globals table is when the global field will be used as a match field in a relationship.

                  • 6. Re: Script to run Report in New Window
                    BryanN

                         Excellent.  Thanks!