Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Below works beautifully to create the field triggers I need in a macro. I did this due to Qlikview deleting the triggers I had created in their UI if the supporting data structure should change, if only temporarily. My next step is to create these triggers and only have them applicable to a specific Alternate State. Does anyone know what else I need to do
set fld = ActiveDocument.Fields("GroupingLocationNN")
fldProp = fld.GetProperties
set fldActions=fldProp.OnChangeActionItems
for i=fldActions.Count-1 to 0 step -1
if fldActions.Count > 0 then
fldActions.RemoveAt i
end if
next
fldActions.Add
fldActions.Item(0).Type = 32 'Field Select=32
fldActions.Item(0).Parameters.Add
fldActions.Item(0).Parameters.Item(0).v = "LocationNM"
fldActions.Item(0).Parameters.Add
fldActions.Item(0).Parameters.Item(1).v = "='(' & '""' & GetFieldSelections(GroupingLocationNN, '""|""') & '""' & ')'"
fldActions.Add
fldActions.Item(1).Type = 32 'Field Select=32
fldActions.Item(1).Parameters.Add
fldActions.Item(1).Parameters.Item(0).v = "iTooGroupingLocationNM"
fldActions.Item(1).Parameters.Add
fldActions.Item(1).Parameters.Item(1).v = "='(' & '""' & GetFieldSelections(GroupingLocationNN, '""|""') & '""' & ')'"
fld.SetProperties fldProp
/* I need to modify this code so that it will also populate the Alternate State box with my alternate state, "PreviousYear" */
/* I tried this, but it still does not work... Note I am running the macro under my "PreviousYear" Alternate State */
set fld = ActiveDocument.Fields("GroupingLocationNN", "PreviousYear")
fldProp = fld.GetProperties
set fldActions=fldProp.OnChangeActionItems
for i=fldActions.Count-1 to 0 step -1
if fldActions.Count > 0 then
fldActions.RemoveAt i
end if
next
fldActions.Add
fldActions.Item(2).Type = 32 'Set Value=31
' fldActions.Item(2).Action = "PreviousYear" 'Set Value=31
fldActions.Item(2).Parameters.Add
fldActions.Item(2).Parameters.Item(0).v = "{PreviousYear}LocationNM"
fldActions.Item(2).Parameters.Add
fldActions.Item(2).Parameters.Item(1).v = "='(' & '""' & GetFieldSelections(GroupingLocationNN, '""|""') & '""' & ')'"
fldActions.Add
fldActions.Item(3).Type = 32 'Set Value=31
fldActions.Item(3).Parameters.Add
fldActions.Item(3).Parameters.Item(0).v = "{PreviousYear}iTooGroupingLocationNM"
fldActions.Item(3).Parameters.Add
fldActions.Item(3).Parameters.Item(1).v = "='(' & '""' & GetFieldSelections(GroupingLocationNN, '""|""') & '""' & ')'"
fld.SetProperties fldProp
Looks like it can't be done in VBS: I've tried the script below to print all variable's action parameters -- there was nothing resembling the Alternate State set up.
sub PrintVariablesTriggers
set variable = ActiveDocument.Variables("Variable1")
set actions = variable.GetProperties.OnChangeActionItems
set objFSO = CreateObject("Scripting.FileSystemObject")
outFile = "c:\out.txt"
set objFile = objFSO.CreateTextFile(outFile,True)
for i=0 to actions.Count-1
objFile.Write "Action type: " & actions.item(i).Type & vbCrLf
set parameters = actions.item(i).Parameters
for j=0 to parameters.Count-1
objFile.Write "-Parameter value: " & parameters.item(j).v & vbCrLf
next
next
objFile.Close
end sub