Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Calling a Subroutine in Trigger Action

Hi,

I am using QV 11 Personal Edition

I have written a sub routine to calculate dates based on a selection.

I have kept a slider control and when the value of the slider changes, it should call this subroutine and inturn calculate the dates.

My sub routine is like this

SUB SubName

     SET var1 = some date conversion

     SET var2 = other conversion

ENDSUB

I will be using these variables in other controls

I went to the Field Event Trigger (the field is linked to the slider control) and added an External -> Run Macro action for OnSelect event

I tried to call the subroutine using

SubName

as well as

CALL SubName

Both didn't work out. Can anyone help please..

7 Replies
Not applicable
Author

Oops..

How to use the variables already defined in the script editor inside a macro.

Now only I am checking my macro. It is throwing error.

Please help, I am new to QV & macro. How to use the functions of QV inside a macro and set & get variables

Is writing macro different from writing a subroutine in the script editor? I am confused.

Can we write a subroutine in Edit Script area instead of macro? If so how to call that in an event trigger action?

jagan
Luminary Alumni
Luminary Alumni

Hi,

In macro you can get variable like this

Get and set variable value in macro

Set value = ActiveDocument.Variables("VariableName")

I am not sure writing a subroutin in the script editor.  It is good practice to write macros in Macro Editor.

Regards,

jagan.

Not applicable
Author

Writing script is to load data inside application.

Writing macros (CNTR+M). You can write Sub routine as well as function inside MAcros.

Subroutine can be directly called by name and function you have to write Call FunctionName.

Not applicable
Author

Also you can get  variable and set values as follow

set varValNonVol = ActiveDocument.GetVariable("Vol-NonVol")
varValNonVol.SetContent "Non voluntary",true

Not applicable
Author

Thanks Jagan & Swapnil. Will try these out.

May I know how to create a function?

Is it

Function

End Function

?

It is throwing error.

I don't know what I did, I am unable to open the macro window itself.

When I press Ctlr+M or from the menu, QV is getting minimized. Anybody faced this issue?

Not applicable
Author

May be there is limitation in personnnel edition.

Try function as

Function funName

End Function

Not applicable
Author

Thanks swapnil.

Now the function is not throwing any error and i tried with msgbox and it shows correct value

I wrote like this

Function funName (var)

     blah blah blah

     funName = blah blah blah

End Function

But how to use this function in a trigger action? I want to pass a date as the param value and it will return another date

I am using a trigger action for a field value change and setting the return value to another variable

I tried calling the function, but it is not giving any output

I tried

=funName(var1)

as well as

=funName($(var1))

Both didnt work. Any help please?