Dynamic parameter inside JSON

Hello all,

I have a flex repeater with dynamic instances. Currently, I am getting the instances from the script below, but as you can see I limited the id to “id”: self.custom.id[0].id which is not what I want to do. The problem is “id” is also dynamic itself so I get id as JSON format in a custom property.

Transform format on a named query:

	dict={ "instanceStyle": {
			  		"classes": ""
			  		},
		"instancePosition": {},
		"id": self.custom.id[0].id
			}
	list=[]
	for i in range(value):	
		list.append(dict)
	return list

This will return:

image

But I want this:
If for example my id returns:

image

I want to be able to get this as a result:

image

You need to bind the repeater’s instance prop to id, and generate the instances from that:

return [
    {
        'instanceStyle': {'classes': ""},
        'instancePosition': {},
        'id': element['id']
    } for element in value
]

Or, using your code, with value still being your query result (but binding on id, you avoid a useless query…), you’d need to use the i you get from range as an index:

	list = []
	for i in range(value):
		dict = {
			"instanceStyle": {"classes": ""},
			"instancePosition": {},
			"id": self.custom.id[i].id
		}
		list.append(dict)
	return list

1 Like

That actually worked. Thank you very much, Pascal. Appreciate your help always. :slight_smile: