9 Replies Latest reply on Jan 26, 2016 7:16 AM by BruceRobertson

    how do i get script to work across two tables?

    easyway

      How can I get a script to work across two tables? I have a contracts table, a client table and an inventory table. On creating a new contract I need a script to go to the inventory table, find available inventory, select the next three available items, and insert them into my new contract. (I would subsequently need the script to mark as sold the items placed into the contract, bit I can deal with that later). I  can´t get the script to pause on opening the inventory table. It flashes up momentarily then returns to the contracts table. Any idea what I´m doing wrong?

      Any suggestion welcomed.

        • 1. Re: how do i get script to work across two tables?
          siplus

          A script can bring you to a layout belonging to a specific table via the "Go To Layout" instruction.

          • 2. Re: how do i get script to work across two tables?
            wimdecorte

            easyway wrote:

            I  can´t get the script to pause on opening the inventory table. It flashes up momentarily then returns to the contracts table.

             

            Why would you pause there?  Are you waiting for the user to do something?

             

            Can you post your script?

            • 3. Re: how do i get script to work across two tables?
              easyway

              I have now managed to get the script to open and remain on the second table, however when I then add to the script "Enter Find Mode" it jumps back to the original table. Here is the script so far:

              Go to Field (Contracts::Class Share)

              Select All

              Copy()

              Open File ("Inventory 2")

              Got to Field (Inventory 2::Class Share)

               

              This takes me to the new file opened, but not to the designated field for some reason. However when I add "Enter Find Mode" it jumps back to the original table.

              Any ideas?

              • 4. Re: how do i get script to work across two tables?
                easyway

                I have now managed to get the script to open and remain on the second table, however when I then add to the script "Enter Find Mode" it jumps back to the original table. Here is the script so far:

                Go to Field (Contracts::Class Share)

                Select All

                Copy()

                Open File ("Inventory 2")

                Got to Field (Inventory 2::Class Share)

                 

                This takes me to the new file opened, but not to the designated field for some reason. However when I add "Enter Find Mode" it jumps back to the original table.

                Any ideas?

                • 5. Re: how do i get script to work across two tables?
                  wimdecorte

                  Because your script is in the original file and acts on things in that file.  If you want to pass control on to the second file and do things there you should call a subscript in that file...

                  • 6. Re: how do i get script to work across two tables?
                    easyway

                    Thanks for that. I can't see how I can achieve want I want with a subscript. What I am trying to do is:

                    on creating a new record in "Contract" table and filling in "Class" field, I want to find records in the "Inventory 2 File" that match with the "Class" in the "Contract" table. So what I am trying to do is copy the contents of "Class" field in "Contracts" table into the "Class" field in "Inventory 2" table when in "Find Mode".

                    If I set up a script in the second table and enter "find Mode", how can I copy the contents of a field in first table into a field in this second table?

                    • 7. Re: how do i get script to work across two tables?
                      beverly

                      sometimes I will manually perform the steps you just described. Then I make notes of what I did.

                       

                      1. go to Contract

                      2. create a new record

                           enter value Class field

                           commit the record

                      3. get the value of Class field and put into a $$Variable and/or Script parameter

                      4. go to Inventory 2 file

                           go to correct layout

                      5. find match to the $$variable in the ?? field (in Inventory 2)

                           enter find mode

                           set field ( class ; $$Variable)

                           perform find

                      6. ...

                       

                      If you need to pass the value when you call a script in another file, you can use Script Parameter set to the value of the Class field. Then in the other script, set a variable to Get ( ScriptParameter ).

                       

                      Beverly

                      • 8. Re: how do i get script to work across two tables?
                        siplus

                        You should notice that scripts can have parameters passed to them, so you can call a script and give him the contents of the Class field. The script will read that value with Get(ScriptParameter) and can go to a Inventory layout, enter find mode, set a specific field to the parameter and perform the find.

                         

                        This being said, I still did not get what you are trying to achieve (select next 3 avail items ? what do you mean by that ?) and I'm sure that there are many ways to optimize reaching your goal, if you manage to define it better. Maybe by uploading your file and letting us take a look.

                        • 9. Re: how do i get script to work across two tables?
                          BruceRobertson

                          Note also that you do not need to have two files. A single file can have multiple tables.

                          However, given that you DO have two files, note also that you can create a table occurrence in one file that points to the table in the external file; and you can create a layout in the first file based on this table occurrence; and you can navigate to THIS layout and add, delete, edit records all within this file.