8 Replies Latest reply on Jul 21, 2013 8:22 AM by philmodjunk

    Set variable problems



      Set variable problems


           How to set the following variables?

           Set variable[$Original value; (before field being modified)]

           Set variable[$New value; (after field being modified)]


           And also, if it is a new record, there will be no original value. How to make an IF clause like following?

           If (no original value / new record) 

        • 2. Re: Set variable problems

               "How to set the following variables?"

          1) Set Variable [ $Original value; value: Get ( ScriptParameter ) ]

          2) Set variable [ $New value; YourTable::YourField ] // if the script is fired by a field's trigger, you could use Get( ActiveFieldContent )

          • 3. Re: Set variable problems

                 I still can't figure out how to set the original value to a variable

            • 4. Re: Set variable problems

                   Use this script:

                   Set Variable [$$originalValue ; value: Get ( ScriptParameter ) ]

                   to save the original value. Need two $ to make it a global variable that will retain this value after the script terminates. Use onObjectEnter to perform this script and pass the field being entered as the script parameter. You'll find a box for this when you select a script for your script trigger.

                   2) in Raybaudi's suggested script can be performed by the ONOBjectSave trigger.

              • 5. Re: Set variable problems
                Anything to pay attention to if the field is a popup list? Still not working on $$original do u mean $$original can be used in other script too?  even without mentioning it in that script?
                • 6. Re: Set variable problems

                       "Still not working" doesn't tell us what you get when you try to use it. I suggest posting the actual script(s)  that isn't/aren't working for you.

                       If you name a variable with two $$ it becomes a global variable accessible from any script/layout in the file. The value in it is retained until you close the file. Thus, one script--such as the one set to be performed via OnObjectEnter can set the variable to a value and then a second script, performed via OnObjectSave can access the value placed in that variable by the first script.

                       To post a script to the forum:

                  1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                  3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here. (with this approach, you can get multiple script steps on the same line, please edit the pasted text by inserting some returns to separate those steps.)
                  5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                  7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                  • 7. Re: Set variable problems
                    I try my best to put my script here as I am using chinese interface. in the database I have a table as such: people 1 | people 2 | relation John.    |  Peter |       supervisor peter.   | John.  |       subordinate so the situation is to make sure if one changes Peter to Alex, the two records are updated   my script is like this. as u suggested: Set Variable [$$originalValue ; value: Get ( ScriptParameter ) ]: set to onobjectenter of a popup field on the same field onobjectmodify I have a script like this: find[$$original in a table] but the find command returns no result but there is record containing $$original. it seems the original cant be capture by Set Variable [$$originalValue ; value: Get ( ScriptParameter ) ]
                    • 8. Re: Set variable problems

                           I see no script in you latest post.

                           Are you setting the script parameter in the optional Script parameter box in the dialog where you select the script for your OnOBjectEnter script trigger?