AnsweredAssumed Answered

trying to obtain last/most recent related record with a script

Question asked by CecileCoulon on Jul 8, 2014
Latest reply on Jul 14, 2014 by philmodjunk

Title

trying to obtain last/most recent related record with a script

Post

     Hello everyone

     Filemaker noob and equine veterinarian here, trying to make a spiffy patient management database.  Have made enormous progress shifting everything I used to have in Bento to Filemaker.  But stuck on something (which Bento was never capable of doing anyway).  Please advise...

     I have a table, containing data for individual Patients, and those patients have (among many other things) a related table of Services that were performed for them.  I would like to pull the following into a field on the Patient record: "the last time they received a certain service (if ever)", for instance a rabies vaccination.  Eventually I will use this data to generate reminders to follow up on preventative care.

     So I wrote the following script, which almost works:

     Go to Related Record [From table: "JoinServices"; Using layout "Add Services" (JoinServices)]

     Enter Find Mode [Restore]

     Go to Record/Request/Page [Last]

     Enter Browse Mode []

     Set Variable [$Date; Value:JoinServices::Procedure Date]

     Go to Layout ["Patients" (Patients)]

     Set Field [Patients::Rabies; $Date]

     Currently the Find does return only those items which match my Find criteria (those which match my patient and are rabies vaccinations) but then the rest of the script returns the date of the first instance of rabies vaccination, not the last or most recent.  How can I fix that?

     Any direction appreciated, even if it means an entirely different/more efficient script. Thank you in advance!

      

Outcomes