Report viewer refresh

Hello erveryone,

I have a report with two custom properties.

The user selects one or more rows from a table and clicks a button to print the relative labels.

The problem is that a multiple selection does not update the report parameters and I basically get the same label printed n times.

I have debugged the code and I can see that in the for loop the data I expect is infact correct

I have tried to add an invokelater function to pause the code for the report to update but it’s not working.

What am I missing ??

Thanks in advance,

t = event.source.parent.getComponent('Table')
t1 = t.getTable()

# righe selezionate
sr = t1.getSelectedRows()
# totale righe selezionate
src = t1.getSelectedRowCount()

def	refresh():
	if nome_stampante != '':
		reportViewer = event.source.parent.getComponent('Report Viewer')
		reportViewer.print(nome_stampante, False)


for x in sr:
	
	order_id = t1.getValueAt(x, 0)
	codice = t1.getValueAt(x, 2)		

	event.source.parent.getComponent('Report Viewer').CODICE = codice
	event.source.parent.getComponent('Report Viewer').ORDER_ID = order_id

	#system.gui.messageBox(str(codice) + ' ' + str(order_id),'')
	
	system.util.invokeLater(refresh,2000)		

	#exit()
	
		

You can't do this will a simple loop in a script. system.util.invokeLater() does not wait in the caller--you get a bunch of refresh() calls piled up together in the event queue. All of your assignments to codice and order_id have executed before the first invoked refresh() runs.

What could work would be a single invokeLater to print the first label, and that refresh doing the next invokeLater for another label. You will need to learn to pass arguments to refresh via partial() or default args in order to track the place in the list.