Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
jduenyas
Specialist
Specialist

Triggers

Hello gurus

In Document settings and triggers one can create a trigger for OnAnySelect. Meaning any object selected/touched will trigger an event/action.

Is it possible to send the Object's ID (or name) to a macro if a macro is set to run on the trigger?

For instance, if a table's ID is TB01 and a user selects a record in the table, I would like the trigger to send to a macro that TB01 was activated.

Is that possible?

Thanks

Josh

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

This script should return the object id of the active object on the active sheet:

set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
     if objs(i).IsActive then
          id = obj(i).GetObjectId
          msgbox("ID = " & id)
     end if
next

View solution in original post

5 Replies
m_woolf
Master II
Master II

I don't believe that OnAnySelect will trigger when an object is selected. I think it is triggered when a selection is made in any field.

jduenyas
Specialist
Specialist
Author

Thanks.

That is what I meant. If a field is selected -- say Name of a SalesPerson in the table, a trigger is fired. I know that for a fact as I have created such an event/action.

However, I would like to send to the macro the name of the table from which the event was triggered.

Is that possible?

Like ActiveDocument.ActiveObject(name)  Is there such a thing as "ActiveObject(name)" or any way to pass the object's name.

Thanks

m_woolf
Master II
Master II

This script should return the object id of the active object on the active sheet:

set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
     if objs(i).IsActive then
          id = obj(i).GetObjectId
          msgbox("ID = " & id)
     end if
next

jduenyas
Specialist
Specialist
Author

Wonderful!

Exactly what I was looking for!

You are it!!

Much obliged.

 

jduenyas
Specialist
Specialist
Author

 

DID NOT WORK UNTIL...

It took me some long moments of frustration to find the error in your code  😆

set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
     if objs(i).IsActive then
          id = obj(i).GetObjectId
          msgbox("ID = " & id)
     end if
next

 

SHOULD BE

 

set s=ActiveDocument.ActiveSheet
objs=s.GetSheetObjects
for i=lbound(objs) to ubound(objs)
     if objs(i).IsActive then
          id = objS(i).GetObjectId
          msgbox("ID = " & id)
     end if
next

And then it works.

Once again thank you