How to use template_any_ID() into Ui Layout? I found this in the Blender API, and I'm curious to try it out:
template_any_ID(data, property, type_property, text='', text_ctxt='', translate=True)

I am intrigued by this Template, but I don't really understand what it is for and how it works.
Can anyone explain?
I was trying something like this:
mat = C.object.active_material
layout.template_any_ID(mat.preview, 'icon_id', 'id_type', text='', text_ctxt='', translate=True)

But I get error:
uiTemplateAnyID: pointer property not found: ImagePreview.icon_id

I also tried with the 'name' property but not even this function.
Another question I don't really understand, what is required to actually use in type_property?
What's going on here? What is missing? Where am I wrong?
The documentation is partially cofused for me, and I can't find any examples on google.
Look at the code
With any blender layout, try grepping the bl_ui code to see if it has been used
and will see this has been used in the scene properties panel.
 bl_ui/properties_scene.py
class SCENE_PT_keying_set_paths(SceneButtonsPanel, SceneKeyingSetsPanel, Panel):
    bl_label = &quot;Active Keying Set&quot;
    bl_parent_id = &quot;SCENE_PT_keying_sets&quot;
    ...

    scene = context.scene
    ks = scene.keying_sets.active

    ...


    ksp = ks.paths.active
    if ksp:
        col = flow.column(align=True)
        col.alignment = 'RIGHT'

        col.template_any_ID(ksp, &quot;id&quot;, &quot;id_type&quot;, text=&quot;Target ID-Block&quot;)


Target ID Block: where I've selected camera
and will see that this is not unlike a driver variable target, in that it lets us set the ID type of object, before selecting an object of that id_type
&gt;&gt;&gt; ks = C.scene.keying_sets.active
&gt;&gt;&gt; ksp = ks.paths.active
&gt;&gt;&gt; ksp.id
bpy.data.objects['Camera']

&gt;&gt;&gt; ksp.id_type
'OBJECT'

or alternatively to the camera data part
&gt;&gt;&gt; ksp.id
bpy.data.cameras['Camera']

&gt;&gt;&gt; ksp.id_type
'CAMERA'

ie we are setting a pointer to object  ksp.id to &quot;any type&quot; based on the id_type.