# Calling collection from a function

**URL:** <https://forums.pega.com/t/calling-collection-from-a-function/1230>\
**Category:** General\
**Tags:** 8-3-1, case-management\
**Created:** [March 15, 2021, 3:11pm UTC](https://forums.pega.com/t/calling-collection-from-a-function/1230 "2021-03-15T15:11:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GlebC108](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@GlebC108](https://forums.pega.com/u/GlebC108)\
**Post date:** [March 15, 2021, 3:11pm UTC](https://forums.pega.com/t/calling-collection-from-a-function/1230/1 "2021-03-15T15:11:04Z")

</div>

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

```auto
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

---

<div class="post-metadata">

**Author:** ![GlebC108](https://avatars.discourse-cdn.com/v4/letter/g/b782af/32.png) [@GlebC108](https://forums.pega.com/u/GlebC108)\
**Post date:** [April 1, 2021, 7:59am UTC](https://forums.pega.com/t/calling-collection-from-a-function/1230/2 "2021-04-01T07:59:58Z")

</div>

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)
