Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi
Is it possible to mark a variable as read-only, either via macro or in script?
I have about 10'000 variables in Document properties -> Variables, and do not like to scroll throuth all of them to set the attribute manually.
See as well https://community.qlik.com/thread/24463
Thx - Marcel
See this adjusted example from APIGuide.qvw for read only:
set v = ActiveDocument.Variables("Variable1")
prop = v.GetProperties
prop.ConstraintsFlag = 4 'read only
v.SetProperties prop
and this here is an example how to loop through the variables:
set vars = ActiveDocument.GetVariableDescriptions
for i = 0 to vars.Count - 1
set v = vars.Item(i)
msgbox(v.IsConfig)
next
- Marcus
See this adjusted example from APIGuide.qvw for read only:
set v = ActiveDocument.Variables("Variable1")
prop = v.GetProperties
prop.ConstraintsFlag = 4 'read only
v.SetProperties prop
and this here is an example how to loop through the variables:
set vars = ActiveDocument.GetVariableDescriptions
for i = 0 to vars.Count - 1
set v = vars.Item(i)
msgbox(v.IsConfig)
next
- Marcus
Hi ,
like this,
alternatively add this to your macro code,
set macroVariable = ActiveDocument.GetVariable("yourVariableName")
then use marcroVariable.GetContent.String to retrieve the variable's contents
HTH,
Hirish
Great! Thank you!