Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
You can set a action on a field at the triggers in documents settings for example by selecting.
When the field is lost after executing script by an error, the action is lost, too.
Is there a way to set the actions in the script?
Regards
In case this helps anyone -
This is what you can use to read/write the state name of the action:
actions.Item(i).StateName.v
Due to way that QlikView removes Field Event Triggers when field no longer exists I have started using a macro to add each Field Event Trigger instead.
I can then easily run the required macro to put the Field Event Triggers back on if it gets lost somehow.
My Field Event Trigger was used to make a selection in another field ("Field2") based on the first 3 characters of a field ("Field1") selection. Adjust the Parameters(1) line as necessary.
This was a combination of some scripts I found around the internet. Others may find this useful.
sub Trigger_1
set fld=ActiveDocument.GetField("Field1") | |
set prop = fld.GetProperties | |
set actions=prop.OnSelectActionItems | |
actions.Add | |
i = prop.OnSelectActionItems.count-1 | |
actions(i).Type = "32" | |
actions(i).Parameters.add | |
actions(i).Parameters(0).v = "Field2" | |
actions(i).Parameters.add | |
actions(i).Parameters(1).v = "=left(GetFieldSelections(Field1),3)" | |
fld.SetProperties prop |
end sub
I found out the action type by manually creating a Field Event Trigger and using the below script to see what it had created.
sub Trigger_Types
set fld=ActiveDocument.GetField("Field1") | |
set fp = fld.GetProperties | |
set actions=fp.OnSelectActionItems | |
for i=0 to actions.Count-1 | |
msgbox "ID: " & i & chr(10) & "Type: " & actions.item(i).Type & chr(10) & "Parameter 1: "& actions.item(i).Parameters(0).v & chr(10) & "Parameter 2: "& actions.item(i).Parameters(1).v | |
next | |
end sub