I knocked this out in no time at all and it seems to work fine - HELP! I have a long history of missing the most obvious problems so I am assuming that there is something wrong with this code like maybe it will somehow corrupt the database or begin to return bad data during a critical phase of the job. This part of the project makes me much more wary than the MS Excel parsing or the XML parsing because the database is at the heart of the system. Am I missing something here?
The first four lines are test data, the actual data will be supplied by another script after it parses it from a PDF form. When all of the correct data is supplied lResult returns a TRUE value which is correct. If I change the lDBUser or the lDBPassword to an incorrect value lResult returns a FALSE value. Maybe I just got lucky and it all works correctly…maybe.
set lDBCompany to "Eric Paulsen"
set lDBUser to "Eric Paulsen"
set lDBPassword to "password"
set lDBPath to "Macintosh HD:Applications:Design-Mo-Tron:Components:DMT Database"
tell application "FileMaker Pro"
activate
open file lDBPath
tell application "System Events"
keystroke "h" using {command down} -- Hide application
end tell
show (every record whose cell "Company Name" is lDBCompany) -- Find record pertaining to customer
tell layout "Main"
if ((cell "Owner Name" = lDBUser) and (cell "Owner Password" = lDBPassword)) then -- If primary user exists in record
set lResult to true
else if (((cell "AU Name" exists) and (cell "AU Name" = lDBUser)) and ((cell "AU Password" exists) and (cell "AU Password" = lDBPassword))) then -- If authorized user exists in record
set lResult to true
else
set lResult to false
end if
end tell
show every record -- Reset Filemaker Pros filters to show all
quit -- Quit database
return lResult
end tell