What does `filter` parameter of Template_id do? and How to use it?
Linked to current scene, or any.

Have used this for setting the active object, or pointer properties to bpy.types.Object instances.

'AVAILABLE' for objects linked to context scene
'ALL' for all objects in the blend file.

Setting an object not linked to a scene to the active object of that scene is going to cause issues.
GIF shows following  draw method used in  (Used in gif above with Templates &gt; Python &gt; UI Panel Simple)
    def draw(self, context):
        layout = self.layout

        obj = context.object

        col = layout.column()
        col.template_ID(context.view_layer.objects, &quot;active&quot;, filter='AVAILABLE')
        col.template_ID(context.view_layer.objects, &quot;active&quot;, filter='ALL')

See Limit &quot;prop_search&quot; to Specific Types of Objects  re using poll to narrow down selection options for pointers.