I only have a quick look at the script and my beginners’ comment as follows:
(1) remind you that DT only look up records in “databases” that are opened. So u need to make sure that all databases remain opened when u run the script or the script will only search in the currently opened database.
(2) logic: if file/s are index into different databases and your script is telling the viewer window to display the file/group in current window. And if you have more than one records in theResults (or same finder’s file in different databases), the script won’t know which one or where to open? You will need to look into the variable theResults to see what items have you retrieved by using the lookup command (I rarely used it) to get a better feel. Use “script debugger” with a free trial period for 15 days (I think) for debugging. The app can run script step-by-step and show the values/records/items in each var in the process in a user-friendly manner.
(3) if you have tagged ur item/s in DT, parent 1 of theResults can be a tag or a group (AFAIMA, there is no fixed rule to determine which one is parent 1, probably based on the time of the creation of each replicant?). That’s why I open a document window for theResults. You may need some code to find all parents of theResults and find the first Parents n that is a group. (This I am not 100% sure)