Skip to main content
Announcements
Introducing a new Enhanced File Management feature in Qlik Cloud! GET THE DETAILS!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I get ObjectID?

Hi,

I want manage objects on sheet (detach/clone/remove). But I don't know how to get ObjectID of active object.

I can save ObjectID for existing objects (I save it with trigger onActivate). But if I clone object, I will not know ObjectID of new object.

Can somebody help me?

Thank you beforehand

9 Replies
sparur
Specialist II
Specialist II

Hi, Irina, ObjectID assigned in order for each object. if there is an object CH10, then your new (cloned) object will CH11

Not applicable
Author

It's true only if cloned object was last object. If there is no object CH11.

In case I have objects CH10, CH11, CH12 then I clone CH10, new object will CH13. But I can't know what ObjectID in a sheet last

sparur
Specialist II
Specialist II

Irina I can't find function which can calculate Max Object ID, but I created small example, I hope it can help you. 🙂

Not applicable
Author

Your example is very useful, but not in my case... I need clone different charts. Even if I would create new objects with your method, I must know properties of active object, what I clone...

Any way thank you, Anatoly.

sparur
Specialist II
Specialist II

Or you can use GetSheetObjects function and calculate this value:


Objects = ActiveDocument.ActiveSheet.GetSheetObjects
For i = lBound(Objects) To uBound(Objects)
If Objects(i).GetObjectType = 10 Then 'pivot tables
set Pivot = Objects(i)
msgbox(Pivot.GetObjectId)

end if
next

sparur
Specialist II
Specialist II

Can you post your qvw example ? I can't understand what you need.

Not applicable
Author

I attach my example. I can clone active old objects and detach/attach it. But I can't remove new cloned objects because I don't know it's IDs

sparur
Specialist II
Specialist II

see in attached file.

the first chart in cycle - is your new object. "Pivot" it's your new sheet object. and you can manage it.

Not applicable
Author

select object_id('schemaname.objectname') as 'Object Id'

Default schema is dbo

Object Name may be table name,trigger name,view name etc..

Best of Luck