Calling collection from a function

Hello to everyone!

Could someone help with the following problem: need to call a collection which name is given as a parameter?

Seems like PublicAPI has the corresponding method - applyCollection(keys, primaryPage, params).

However, I tried to call it in different ways(passed pxInsHandle, pzInsKey etc.) and faced with the

Failed to find a 'RULE-DECLARE-COLLECTION' with the name '' that applies to 'ClassName'; no rules with this name were found in the rulebase.

I suppose that there is required property that should be passed to the applyCollection method but couldnt get what exactly needed.

Thanks in advance!

Gleb Chernov

It was solved by setting the pyPurpose property. Therefore, keys structure looks like that:
keys.pxObjClass (“Rule-Declare-Collection”)
keys.pyClassName (Applies To Class)

keys.pyPurpose (collection name)