6 Replies Latest reply on Nov 8, 2013 10:00 AM by timwhisenant

    Passing Variable data from 1 DB to another

    kojmichael

      Sample:

       

      MainFMPro12advDB

      Table: Invoices

      Set Variable [$$CID; Value;Invoices::CustomerID]

      Set Variable [$$CName; Value;Invoices::CustomerName]

       

      Need the value of Invoices::CustomerID and Invoices::CustomerName sent to External 2nd FMDB

       

      Tried using the following in the called script that exist in the 2nd DB

      Table: Events

      Set Field [Events::RegID; $$CID]

      Set Field [Events::RegName; $$CName]

       

      When I try this the data in the fields RegID and RegName are empty

      I even tried to do:

      Set Variable [$var1; Value:$$CID]

      Set Variable [$var2; Value:$$CName]

      In the script performing the write

       

      And yes there is a Commit following the set field.

        • 1. Re: Passing Variable data from 1 DB to another
          wsvp

          I believe Global Variable are File Specific.  So they are not accessible when you move to another file.  I am not 100% sure of this, as it has been a long time since I have had to deal with navigating between files.  Since FM7 it seems everyone moved to either a single file, or a single interface file with references...  All interface and scripting would be done in one file.

          • 2. Re: Passing Variable data from 1 DB to another
            erolst

            Doesn't work because the global is global in its file (across tables) only, not across the application.

             

            One solution is to use the script parameter option for the Perform Script step, like

             

            Perform Script [ yourExternalScript… ; Parameter: List ( Invoices::CustomerID ; Invoices::CustomerName ) ]

             

            and in the calling script, use

             

            Set Field [Events::RegID; GetValue ( Get ( ScriptParameter ) ; 1 ) ) ]

            Set Field [Events::RegName; GetValue ( Get ( ScriptParameter ) ; 2 ) ) ]

            • 3. Re: Passing Variable data from 1 DB to another
              kojmichael

              @Erolst:

               

              FM would like let me Build

              Set Field [Events::RegID; GetValue ( Get ( ScriptParameter ) ; 1 ) ) ]

              Set Field [Events::RegName; GetValue ( Get ( ScriptParameter ) ; 2 ) ) ]

               

              It was giving me a error msg saying that Get (Invoices::CustomerID) was

              This parm was an invalid Get function parm.

              Or am I supposed to keep it as Get (ScriptParameter)?

               

              Also If I try to use:

              GetValue ( Get ( ScriptParameter );1))

              in the calulated vaule part it tells me: 

              "An +,-,*,... is expected here. error msg"

               

              Is it my ver that is the reason that what you have and what I put in has changed?

               

              NM on the Parameter List issue I got that resolved You have to type List (TABLENAME::FIELD)

               

              Now to just get :

              Set Field [Events::RegID; GetValue ( Get ( ScriptParameter ) ; 1 ) ) ]

              Set Field [Events::RegName; GetValue ( Get ( ScriptParameter ) ; 2 ) ) ]  Working.

              • 4. Re: Passing Variable data from 1 DB to another
                erolst

                kojmichael wrote:

                 

                Or am I supposed to keep it as Get (ScriptParameter)?

                 

                Yes. Script A starts a script and passes a value to Script B in the form of the script parameter, which in script B you can retrieve with Get ( ScriptParameter ).

                 

                Since in this case it's a list of values, use GetValue() to retrieve the separate values.

                • 5. Re: Passing Variable data from 1 DB to another
                  kojmichael

                  Got it Thanks for the assist.

                  • 6. Re: Passing Variable data from 1 DB to another
                    timwhisenant

                    Hi,

                     

                    Erolist has shown you how to push the data to a script in file B.

                     

                    You can also use a global field in file A, which can be referenced from file B thus pulling the data.

                     

                    So, based upon the present need you can push the data or pull the data.

                     

                    The global field method is how this was accomplished prior to script parameters and is still a valid method for sharing across files.

                     

                     

                     

                    FYI,

                     

                    Tim