I need to have reporting plugin wait for tables to update

I have some FPMI code that runs several SQL proceedures and builds/populates an SQL table. It then opens a new window with the report for that table so the user can print it. The problem is that when the reporting window opens, there is no data in it. The report shows up, but there are no fields filled in. There is an option on the first window to reprint the report. If I close the reporting window and choose reprint, the reporting window pops up again and this time it is populated. I don’t know if there is a way to be sure the table write is completed before running the report, or if I can set a delay for 5 seconds while the table is populated?

The code looks something like this:

BBTID = fpmi.db.runScalarQuery("exec dbo.usp_BBTCreateNewRecord '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'" % (dt,dd,mm,yy,brand,tank,dest,cond))

table = event.source.parent.getComponent("ctrFermenters").getComponent("tblSelFerm")
order = table.getRowsInViewOrder()
for row in order:
    fpmi.db.runUpdateQuery("exec usp_BBTLinkFermentersTemp '%s', '%s'" % (BBTID,table.data.getValueAt(row,0)))

fpmi.db.runUpdateQuery("exec usp_FiltrationLogFermCO2 '%s'" % (BBTID))

if brand == "SFB":
    fpmi.nav.openWindow("Filtration Log2")
elif cond == 1:
    fpmi.nav.openWindow("Filtration Log1")
else:
    fpmi.nav.openWindow("Filtration Log2")

There are two versions of the report, but Filtration Log1 and Filtration Log2 are populated from the same table.

You can have the report query poll the database every 5 seconds, or you can add a delay opening the window like this:

[code]def openWindow():
import fpmi
fpmi.gui.openWindow(“MyReport”)

fpmi.system.invokeLater(openWindow, 5000)[/code]

Hope this helps,

Perfect!!

Carl, I was wondering, will this Invoke Later idea work on a project where the datasets are being populated by customized components of the window that is being opened?

You know that slight trouble I have when opening a popup menu with all those drop downs. Well we still occasionally have it so if this invoke later will cure the problem then great.

Have a great day.

[quote=“Carl.Gould”]You can have the report query poll the database every 5 seconds, or you can add a delay opening the window like this:

[code]def openWindow():
import fpmi
fpmi.gui.openWindow(“MyReport”)

fpmi.system.invokeLater(openWindow, 5000)[/code]

Hope this helps,[/quote]

Martin - no, I don’t think invokeLater will help in your case, because you aren’t modifying the database right before you open the window. Your problem is some other sort of timing issue. I still haven’t been able to reproduce it here, but I haven’t forgotten about it…