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!