Before showing the sheet, please call FileDialog.SetSheetScriptTrigger to set script trigger and use FileDialog.SetUseSheet function to enable sheets. Be aware that the script must be different. The first script shows the sheet and exits. Later another script runs and processes results as the process is asynchronously.
New plugin with updated example database is comming soon.