Get parameters of a specific sibling

Hi, I want to use the parameters of a sibling. The problem that I run into is that I have multiple siblings and I donā€™t now how to select the right one.

I used this line in the Controller to get all the siblings:
siblings = API().get_entity(entity_id).siblings()

In the Parametrization, I used this SiblingEntityOptionField:
used_sibling = SiblingEntityOptionField(ā€œSelect siblingā€, flex=100, entity_type_names=["ā€¦"])

And from here on I donā€™t know how to use ā€˜used_siblingā€™ to get the parameters of the sibling that I want. ā€˜used_siblingā€™ is a number (entity_id) and siblings is a EntityList. Can anyone tell me how to select the sibling with the right entity_id?

If you are using the SiblingEntityOptionField, you donā€™t need the siblings API call anymore, but can just use:

Parametrization

used_sibling = SiblingEntityOptionField(ā€œSelect siblingā€, flex=100, entity_type_names=["ā€¦"])

Controller

...

def my_method(params, **kwargs):
    sibling_id = params['used_sibling']
    sibling_entity = API().get_entity(sibling_id)

With VIKTOR >= v12.8.0 the API call can be fully removed, as the param returned is an Entity object already:

Controller

...

def my_method(params, **kwargs):
    sibling_entity = params['used_sibling']
1 Like

Thanks for helping and your quick response!