Skip to main content
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: 
Not applicable

How to get a field value into a variable through macro

Hi

I want to assign a field value to a variable through macro , on document open.

Field contain only one value,

How to assign it to a variable

4 Replies
Not applicable
Author

Try this

ActiveDocument.Variables("vVarA").SETCONTENT ActiveDocument.Fields("SomeField").GetSelectedValues.item(0).text,TRUE

Not applicable
Author

Actually field contain only one value which is not selected

So we can't use GetSelectedValues

pls give alternative ,

if we want to get all the values of a field (selected / not selected)

and want to assign it to a variable



Not applicable
Author

Actually Field that i am using contain only one value

I don't want to select it ,

I want values of field(both selected and non selected) by default through macro

so



Getselectedvalues can't work

Not applicable
Author

Try this:

IF ActiveDocument.Fields("SOMEFIELD").GetPossibleValues.COUNT=1 THEN

ActiveDocument.Variables("vVarA").SETCONTENT ActiveDocument.Fields("SOMEFIELD").GetPossibleValues.item(0).text,TRUE

end if