6 Replies Latest reply on Apr 1, 2016 6:34 PM by user26728

    Variable without a value declared

    user26728

      Hello. Newby question..I found this in a calculation field (there is nothing else in the calculation)... $$Current_ITEM_ID ..

      There are two fields involved here:

       

      Transactions :: ITEM ID MATCH FIELD (calculation field, the calc is  "=$$Current_ITEM_ID")

      and

      Inventory :: ITEM ID MATCH FIELD (auto-enter, serial number)

       

      the relationship is : ITEM ID MATCH FIELD = ITEM ID MATCH FIELD

       

      My question, is why enter a variable name, without a value?

      Hopefully this makes sense...  Thanks .. G

        • 1. Re: Variable without a value declared
          mikebeargie

          You need to track down the script that has the set variable script step to work out what that's actually doing.

           

          That's one of the many ways of getting a global value to populate a field (the other being "set field" instead of using a calc).

           

          So comb your scripts for:

          Set Variable [ $$Current_ITEM_ID ; _________ ]

           

          and wherever that red line is should give you details about what value gets stuck in that variable.

           

          I'm sure you know, but $$ variables can exist for the user's session outside of scripts. $ variables cease to exist once the script stack is completely executed.

          • 2. Re: Variable without a value declared
            user26728

            Thanks Mike! The value for the variable was indeed in a script...

            Now to figure out what is happening with it.

            • 3. Re: Variable without a value declared
              erolst

              Considering the nomenclature, this is from a starter solution

              user26728 wrote:

              Now to figure out what is happening with it.

              IIRC, this is used as a way to create a line item; when you enter a product/item layout, that $$ is set to the primary key, and when you create a new record in the line item table, it automatically receives that value as a foreign key via an auto-enter option.

               

              I recommend cutting down on the use of $$variables; they create interdependencies that become hard to track (unless you painstakingly document their use) – exactly what you are experiencing right now.

              • 4. Re: Variable without a value declared
                StephenWonfor

                There is also the $$Variable that can be created in a schema calculation field.  Saw this once after hours spent with the 2EmpowerDeveloperAssistant and the FMPAdvanced debugger searching hundreds of scripts for $$Trigger.

                 

                Finally found it in a calculated field.  Let([$$Trigger = Get ( CurrentDate )];"")

                 

                Cool, but Yikes!

                 

                Stephen

                 

                "Don't include a single line in your code which you could not explain to your grandmother in a matter of two minutes. And of course... assume your grandmother is not Ada Lovelace."    — Anonymous.

                • 5. Re: Variable without a value declared
                  erolst

                  StephenWonfor wrote:

                   

                  There is also the $$Variable that can be created in a schema calculation field.

                   

                  Actually, it (and also $vars) can be created wherever you have access to the Calculation Engine (i.e. “Specify Calculation”). Fun to code, less so to maintain …

                   

                  StephenWonfor wrote:

                  "Don't include a single line in your code which you could not explain to your grandmother in a matter of two minutes. And of course... assume your grandmother is not Ada Lovelace."    — Anonymous.

                   

                  "Assume that the guy taking over your code is 6"6', bad-tempered and knows your home address."

                  • 6. Re: Variable without a value declared
                    user26728

                    Yes, it's from the Inventory starter solution that comes with FMP 14