1 Reply Latest reply on Aug 6, 2015 11:58 AM by philmodjunk

    Need Help With Filemaker Script

    DavidAllada

      Title

      Need Help With Filemaker Script

      Post

      Hello, I am currently working on a script to update patient records. The way it is set up is that in Layout 1, there are patient records. In Layout 2 (Changes), there are about 50 patient records that have updated information. For example, "Amy" in Layout 1 has an account number of 10. In Layout 2, there are 4 Fields. "If data 1" contains the name of a field in Layout 1, such as account number, to match information up to make sure the record that needs to be changed matches the one in the server. "Equals data 1" would then be the account number of the patient record that needs to be updated. If the two match up, it would change the data. "Field to change" would specify what field in Layout 1 needs to be changed (ie. account number), and "Change to" would specify what to change that field. So if we ran the script, it would find all of the changes that I put in Layout 2, with "If data 1" "Equals data 1" "Field to change" "Change to" and it would go through all the patient records and update them accordingly. I have tried a couple of solutions. My first thought was to have a nested loop. It successfully pulls the data and matches a single file, but there are many problems. It should work, but simply does not. I would love some suggestions. I included a picture of the script below.

      Untitled.png

        • 1. Re: Need Help With Filemaker Script
          philmodjunk

          That does not seem to make sense and leads to many questions.

          Why are the changes not just made directly to the table? Why are these changes logged first and then the change is made via this script? What problem does this solve?

          The script makes no effort to control what found set is present on the "WeeklyBTCustomReport" layout. Thus records could be in the table but not in the current found set and then they would be ignored by this script. And when this script is run again, the changes would be performed a second time if they are still in the current found set for this layout.

          So it seems you need either a Go To Related Records, scripted Find or perhaps a show all records to make sure that all records are processed and I'd think that you then want to at least set a value in the field to "mark" it as processed so that your script can avoid making the same change all over again.

          And I can't get my head around the purpose behind your If steps that check "If Field ..." values  against "Equals Data 1" and "Equals Data 2". Especially since the set field by name steps are identical in both cases.

          And please note that

          GetField could be used in place of Evaluate to indirectly reference your fields.

          If you rename the "WeeklyBTCustomReport" table occurrence, this script will fail to work due to the quoted text used inside the Evaluate. IF you set a variable to Get ( LayoutTableName ) and used it in place of the quoted text, you could modify this method so that renaming a table occurrence can't break it.