Skip to Content
Jul 21, 2017 at 04:38 PM

How do you create a Reuse Library function to return a collection of objects?


I frequently need to return all instances of a particular configuration object, so rather than define and execute the query everywhere I need to, I just want to write a reuse function that does it with one line of code in the client script.

When I define the reuse function, it forces me to include the "elementsof" option, which then causes problems getting the collection.

I define and execute QueryByElements to return all IDs, then retrieve each instance and try to add it to the results.

But I get a message like this when trying to activate -

Return fails: Assignment of the type 'collection of MyCustomObjectNodeElements' to the type 'collection of Node(MyCustomObject.Root)' is not possible

I can't even tell what "elementsof" is really useful for. Nearest I can figure from the documentation is that it creates an empty instance that is useful for creating a new instance of the object.

Any help is appreciated.