9 Replies Latest reply on Apr 14, 2014 2:12 PM by lijnbach

    Run script outside the lay out

    lijnbach

      Title

      Run script outside the lay out

      Post

           I have a lay out, and on this lay out there is a field "Contract Code". After this Contract Code, I need a unique number, based on the existing number of records with the same value "Contract Code".

           There is no problem with the script, I can find the number of records with "Contract Code", and get this number (+1) on a global field.

           But, I want to run this script without effecting the lay out I am working on. I only want to perform a find to find the number of records with the same "Contract Code". I don't want to perform this find on my lay out. I think it is not to difficult, but I can't find the right way to this. (It can be a translation problem).

           Can someone help me out? 

           Hans Lijnbach.

            

        • 1. Re: Run script outside the lay out
          RickWhitelaw

               A layout is based on a Table Occurence and "contains" records from that Table Occurence. So when you perform a find, the layout provides the context. A find won't affect your layout per se. Maybe I'm missing something important.

          • 2. Re: Run script outside the lay out
            lijnbach

                 O.K. Rick,

                 That is the point. I don't want the lay out to provide the content. I only want to know how many records there are (with the same "Contract Code"), to use this number (of records with the same value) to get a value for use in the Contract Number.

                 Hans.

            • 3. Re: Run script outside the lay out
              philmodjunk

                   All scripts run within the context of a specific layout. But a script can freeze the window, change layouts, do what is needed and then return to the original layout. If the layout that the script changes to in order to perform your find, is either based on a different Tutorial: What are Table Occurrences? or opened in a different window, that find will have no effect on the found set in your original layout.

                   But a relationship can also return the maximum value for a set of related records and thus your script need not actually perform any find at all.

              • 4. Re: Run script outside the lay out
                lijnbach

                     O.K. Phil,

                     This makes sense. I will have to find out what the best way is to find the number of records, or a second table occurrence or related records. It seems a relationship is the most effective way. I already put the "Contract Code" temporary in a global field, so I could use this global field for the relation and count he number of related records.

                     Thanks again Phil.

                     Hans Lijnbach.

                • 5. Re: Run script outside the lay out
                  lijnbach

                       The "Freeze Window" is interesting to Phil (for other purposes). And in English I immediately understand what it is doing. Now I will try to find the Dutch expression for "Freeze" and "Unfreeze". 

                       Hans

                  • 6. Re: Run script outside the lay out
                    philmodjunk

                         There is no "unfreeze" window script step, just freeze window. It simply keeps the window from updating due to the change in layout or found set until the script either performs a step that forces an update such as refresh window or the script finishes execution.

                    • 7. Re: Run script outside the lay out
                      lijnbach

                           O.K. I understand that Phil.

                           Just a question, I have been looking for the Dutch expression for getting the number of related records in a table occurrence. Can you give me the English expression? (Maybe it makes it easier to find the Dutch one).

                           Thanks.

                           Hans. 

                      • 8. Re: Run script outside the lay out
                        philmodjunk

                             There is more than one way to do that.

                             If you have:

                             ParentTable-----<ChildTable

                             And, for a given record in ParentTable, you want the count of all records in ChildTable linked to it,

                             Count ( ChildTable::NeverEmptyField )

                             will return the count of records related to the current ParentTable record.

                             But ChildTable::SummaryField can return the same value if it is set to "count" a never empty field.

                             And ExecuteSQL can also return this same count.

                        • 9. Re: Run script outside the lay out
                          lijnbach

                               Thanks Phil,

                               This is clear. Where I went wrong: I was looking for a "Get" function (to get the number of related records), but I can simply use the count function.

                               Thanks again for your help Phil.

                               Hans