Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Running Macro in script based on Input

I have the following script. I have an inout field but what I am finding is the input field does not clear after each reload, so the categories get all mixed up. So I wrote a Macro to clear the input boxes which works fine. I however want the user to choose if they would like to not clear the categories or to clear them and start again.

I created a input in the script and this works fine, I included the sub routine in the script but this doesn't work, doesn't clear anything. I then tried to create a macro with two actions, one to reset and the other to reload as normal. I then tried to pass variable of "A" to the Marco and had a IF statement to determine if it should clear the inputfields or not. I sort of got this to work, what it seemed to me is at reload time the variable wasn't set correctly.

My goal is to just give the user the option to clear the inputfields or not when they reload data.

Any suggestions please fire away.

LET

activedocument.fields("Category").ResetInputFieldValues 0;

End

inputfield

Actual:

Category;

LOAD

Type,Category,Description,Amount,Date,Week(Date) as HistoryWeek ;

SQL

END IF

SELECT * FROM Bank.dbo.Transactions; IF A = 'Yes' THEN

Sub



reset

activedocument.fields("Category").ResetInputFieldValues 0;

End

inputfield

Actual:

Category;

LOAD

Type,Category,Description,Amount,Date,Week(Date) as HistoryWeek ;

SQL

END IF

SELECT * FROM Bank.dbo.Transactions; IF A = 'Yes' THEN

Sub



reset

activedocument.fields("Category").ResetInputFieldValues 0;

End

inputfield

Actual:

Category;

LOAD

Type,Category,Description,Amount,Date,Week(Date) as HistoryWeek ;

SQL

END IF

SELECT * FROM Bank.dbo.Transactions; IF A = 'Yes' THEN

Sub



reset

1 Reply
Not applicable
Author

Anyone got an idea?

I tried to set two actions OnPostReload trigger. I created a Set Variable and then the Macro. The variable is definately being set correctly but for some reason the sub routine ignores my IF clause. It just seems it doesn't read the sub routine at all. If I leave the IF clauses out it runs fine but i need to have a IF statement to determine if the sub routine should run or not.

Is there a way to clear inputfields from the script, I created a sub routine in the script but it can't run vbscript code "ActiveSheet.Fields" etc...

I also tried calling the Macro from script but the program just bombs out.

Here is my Macro

Function ResetCategory

set v1 = ActiveDocument.Variables("CCategory")

msgbox v1.GetContent.String

if v1.GetContent.String = "Yes" then

ActiveDocument.fields("Category").ResetInputFieldValues 0

end if

msgbox v1.GetContent.String

End Function