Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Macro syntax to edit a variable's OnChange properties (trigger)

Hello folks,

Could anyone please provide the correct macro syntax to edit the properties for a variable's OnChange action trigger?  I am trying to create the correct macro syntax to disable, and later re-enable a variable's OnChange action under Document Properties.

Problem background:

A customer has a macro to automate some actions, and during macro execution, a variable OnChange trigger is being executed between each step, resulting in long macro execution time.

And yes the customer realizes they should be using built-in actions rather than a macro, but at this point in time, the customer has a macro and it needs to be optimized.

The attached QVW shows a rough approximation of the customer's QVW, with a variable OnChange trigger being executed multiple times over the course of macro execution.

So far, I was able to modify the macro code to successfully delete the variable's OnChange action on the first step of the script, and later recreate the action at the end of the script.  However, when this task gets executed, the OnChange properties for the variable event trigger gets cleared.  I've tried looking at the QlikView API Guide for the correct syntax, but I was unable to locate anything to edit the properties for an OnChange action.  If anyone could please send along the macro command to modify the properties for an event trigger, it would be much appreciated!

Thanks,

Sean

Macro code:

sub ClearFields

set v = ActiveDocument.Variables("vBadVariable")
prop = v.GetProperties
' msgbox prop.OnChangeActionItems.Item(0).type


set actionsvar=prop.OnChangeActionItems
actionsvar.RemoveAt(0)

v.SetProperties prop


ActiveDocument.Fields("Dim2").Clear
ActiveDocument.Fields("Dim3").Clear
ActiveDocument.Fields("Expression1").Clear


actionsvar.Add
actionsvar.Item(0).Type = 31
' Missing: How to edit the OnChange properties for the variable event trigger

v.SetProperties prop

end sub


1 Solution

Accepted Solutions
whiteline
Master II
Master II

Hi.

actionsvar.Item(0).Parameters.Add

actionsvar.Item(0).Parameters.Item(0).v = "Variable"

actionsvar.Item(0).Parameters.Add

actionsvar.Item(0).Parameters.Item(1).v = "Value"

View solution in original post

4 Replies
whiteline
Master II
Master II

Hi.

actionsvar.Item(0).Parameters.Add

actionsvar.Item(0).Parameters.Item(0).v = "Variable"

actionsvar.Item(0).Parameters.Add

actionsvar.Item(0).Parameters.Item(1).v = "Value"

Anonymous
Not applicable
Author

Perfect!  Thank you.

Not applicable
Author

This is wonderful.

How would I modify it to specify an Alternate State?

Anonymous
Not applicable
Author

Hi Charissa,

Try adding the name of the Alternate State with double quotes as a second parameter in the macro code.

Example:

sub ClearFields

  ActiveDocument.Fields("Dim2","AltState1").Clear

end sub