Flex repeater on query binding not working properly

Hello

I’m going crazy on a flex repeater populated with query binding

this is the query:

select
	l.sap_code,
	w.nome,
	w.description,
	l.validated_on "valid" ,
	w.qty ,
	w.pos
from
	wl_warehouse_log l
inner join wm_warehouse_masterdata w on
	w.sap_code = l.sap_code
where
	l.created_on::date = :data

this is the repeater

as you can see the column valid is reflected in the repeater and moreover is also used as a condition in another field which is working properly

When the flex repeater is filled the column valid is correctly populated "(column VALIDATO) but in the instances there is no trace of “valid”. See below

so as soon as I run a script on the flex repeater the attribute valid is not found

I’m running a change script on the flex repeater which is the following one:

insta = self.props.instances
cond = True
for ix in insta:
	if ix.valid:
		cond = False
	else:
		cond = True
self.view.custom.valid = cond

This is the error

Error running property change script on FlexRepeater.props.instances: Traceback (most recent call last): File "<function:valueChanged>", line 5, in valueChanged AttributeError: 'com.inductiveautomation.perspective.gateway.script' object has no attribute 'valid'

Can someone please tell me where I’m wrong?

Thanks

Your instances don't have a valid property.

EDIT:
Because
l.validated_on "valid" ,
is not valid SQL syntax. Try:
l.validated_on as "valid" ,

Adding that as soon as I change the query in the binding ,for example adding new column .. the column are correctly shown until I run the page in demo mode

Hello Paul

tried but nope

I’ve also added column row_id which is also not appearing

query result in editor

Show a screenshot of your binding configuration on the flex repeater.

Solved … I deleted the flex repeater and did a new one ….

Some weird behaviour

Thanks

Are you sure that's what you want to do ?
This code snippet will only reflect the valid field of the LAST ix in insta.
Which could be written like this:

self.view.custom.valid = not self.props.instances[-1].valid
1 Like

Assuming your goal was to set self.view.custom.valid to True only if all of the instances are invalid, you can use the all() built-in function.

self.view.custom.valid = all(not ix.valid for ix in self.props.instances)

Or, if your goal was different (thanks Gemini):

  • Check if ALL instances are valid:

    self.view.custom.valid = all(ix.valid for ix in self.props.instances)
    
  • Check if ANY instance is valid:

    self.view.custom.valid = any(ix.valid for ix in self.props.instances)
    
  • Check if ANY instance is invalid:

    self.view.custom.valid = any(not ix.valid for ix in self.props.instances)
    
1 Like