2 Replies Latest reply on Feb 25, 2015 12:28 AM by ChrisC_3

    SetField Script step question



      SetField Script step question


      I wrote a fairly basic script to move data from one field to another.

      Go to layout
      Show all records
      Find Recordset I want to modify
      Go to first record
      Set Field A to Field B
      Set Field B to ""
      Next Record (Exit after last)
      End Loop

      The problem is that after running the script both Field A and Field B ware wiped with the data was nowhere to be found.

      Now, I know I can use a variable to store the field value before running the SetField script step, and fortunately I do have a backup of my data so it can be restored.

      The question is "why" the script failed. It produced no errors and I double checked to make sure I didn't make any silly mistakes like wiping field B before setting field A. My best guess would be that setting Field A to Field B in this manner might set a pointer to the data rather than copying over the value or that filemaker ran the SetField steps in a different order than I specified in the script, but both these options seem rather unlikely.

        • 1. Re: SetField Script step question

          You'll need to share the actual script so that we can see the details instead of just an outline.

          My guess is that Field A and Field B are not defined in the same table. Either that or if they are from the same table, you did not use the same table occurrence name to refer to each field. But I can only guess from the info so far provided.

          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 New 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.
          • 2. Re: SetField Script step question

            Thanks for your reply.

            After getting some sleep and doing another test I realised that I must have triggered the script twice instead of just once as it had no failsafe to stop empty cells from being copied over. As the script now runs fine with no modifications made, its the best explanation for what must have happened. That's what I get for overt thinking things :)