How to create a sub queries working three collections ? How to add reference fields whenever form submisson ?

i have three collections ,and then i am creating a reference fields in showcast collection. taken from these two reference fileds are one in castroles collection and another one is peoples collection.

You can use insertReference () method for form submissions.

To query referenced items, please see the instructions here .

thank you
but its not working i alredy tried