10 Replies Latest reply on Aug 30, 2012 7:37 PM by JFWX5

    Passing a global to a external file

    JFWX5

      Hi,

       

       

      I'm trying to get a global field out of my Main file and post it into an external file. These are two separate unrelated tables and if possible wish to keep them that way.

       

       

      How can this be done in FM12 and if so how?

       

       

       

      Thanks

        • 1. Re: Passing a global to a external file
          erolst

          Have a script call a script in the external file, and pass the value of your global field as script parameter.

           

          You need to add the external file to External Data Sources, but you don't have to define any relationships.

          • 2. Re: Passing a global to a external file
            JFWX5

            Hi Erolst,

             

            I'm not that familiar with script parameters.

             

            I'm looking to pass Main File:UniiqueID to Other File:UniqueID

             

            How would this be done?

             

             

             

            Thanks,

             

             

            John

            • 3. Re: Passing a global to a external file
              beverly

              1. script in "other":

                   get global

                   ==========

                   IF  not IsEmpty ( Get ( ScriptParameter ) )

                        set field OTHER::UniqueID; Get ( ScriptParameter )

                   /IF

               

              2. script in "main":

                   push global

                   ===========

                   Perform Script: "other"; "get global"; Parameter: "MAIN::UniqueID"

               

              3. that's it!

               

              Step through it and you'll see.

               

              Beverly

              • 4. Re: Passing a global to a external file
                JFWX5

                Hi Beverly,

                 

                 

                This is great and so simple, I learned something tonight!

                 

                 

                Big Thank you to you and Erolst.

                • 5. Re: Passing a global to a external file
                  beverly

                  J, the script parameter (and result you can pass with Exit Script) are just the bees knees when trying to push between files and scripts.

                   

                  You can pass just about anything. Try a return-delimited list or comma-delimited list and parse (pull apart) in the other script to get multiple values passed at once....

                   

                  Beverly

                  • 6. Re: Passing a global to a external file
                    JFWX5

                    Hi Beverly & All,

                     

                     

                    I've now implemented this with great sucess.  I now need to create a portal in the MAIN File that displays all the related records from the OTHER File.  And when I click on the portal I need a new window containing just that record from the OTHER File.

                     

                    How do I go about this?

                     

                     

                    Thanks,

                     

                     

                    John

                    • 7. Re: Passing a global to a external file
                      erolst

                      JFWX5 wrote:

                       

                      Hi Beverly & All,

                       

                      Well, it was just Beverly and me. Anyway …

                       

                      To implement this feature, you need to add Other as an External Data Source to Main, then add a TO (table occurrence) of Other to the Relationship Graph of Main, and define a relationship between this new TO and a TO of Main. This allows you to display a portal to show records from the Other TO on a Main layout (more precisely, a layout based on the Main TO used in the relationship …).

                       

                      Now write a script in Main along the lines of

                       

                      Go to Related Record [ from Other TO, Open in new window, use external layout etc.)

                      Select Window ( name of Other file window ) // otherwise the current window retains the focus

                      // optional: Perform Script ( script in Other to do preparatory stuff )

                       

                      and set up a field in the portal as button to perform this script (or for several fields, group them, then define the group as button; makes the click a nicer user experience).

                       

                      Be aware that by adding external TOs, you can treat the related tables (TOs, more precisely) from Other just like the "native" TOs in Main. This means you could use Other as data repository and build the associated interfaces in Main.

                      • 8. Re: Passing a global to a external file
                        JFWX5

                        Erolst,

                         

                         

                        I got this part all set with one execption.  The Portal displays one more row than there is data.  Is there a

                         

                        way to not have the extra row displayed?

                         

                         

                        Thanks,

                         

                         

                        John

                        • 9. Re: Passing a global to a external file
                          erolst

                          In the Relationship Graph, open the new relationship and uncheck the “Allow creation of records in this table …” option for the external TO.

                          • 10. Re: Passing a global to a external file
                            JFWX5

                            Erolst,

                             

                             

                            Great, this wraps up the logic, scripting & testing portion of this module in my solution.  All I have left to do

                             

                            is clean up the layouts and make it pretty.

                             

                            Thanks Again,

                             

                            John