I have a Perspective view where the user can select from CheckBox instances in a flex repeater. After selecting from the list a button will submit the list of names that were selected. The code is below:
# step through the rows
for instance in Instances:
logger.info("Instance " + str(instance.text))
if instance.selected:
Names.append(str(instance.text))
logger.info("Name " + str(instance.text))
Are you iterating over the instances prop in the flex repeater? Then your syntax would need to be
if instance['selected']:
The perspective object gets a wrapper that makes it act sort of like a python dictionary, so you have to use python's syntax for accessing keys in a dict. (ie, dict['key']).
Double check the capitalization of your key/attribute(selected vs Selected), and check that selected actually exists in each instance. If you don't add that key when generating the instances to begin with, it will not be present.
As a one-liner:
names = [instance['text'] for instance in instances if instance['selected']]
I don't believe I am doing anything different in adding the last instance to the flex repeater than I am doing to the preceding instances. They should all have ".selected".
Observations after a quick scan:
Your third screengrab (caption your images and give them numbers - it makes it much easier to talk about them) shows that each instances member has a text property but no selected property. That would explain the 'there is no "selected" attribute' error message.
Also, you've cropped your first image too much on the right so we can't see if you've set the PARAMS as Input/Output type (set by cycling through the arrow options on the right edge of the Perspective Property Editor).
That does not explain why the script sees ".selected" for all instances except the last one. I don't believe it is required to create parameters in the instances when the object in the flex repeater already has them. The "text" parameters shown in the instances are there because they are being set by binding to a script that pulls the values from a database.