Article Details
Id:12501
Product:finPOWER Connect
Type:NEW
Version:2.02.04
Opened:12/12/2014
Closed:12/12/2014
Released:13/02/2015
Job: J014641

Scripts; Action Scripts; Can now update the Icon that is displayed on the form

Action Scripts can now update the Icon that is displayed on the form.

The following Script sample shows how to toggle an Action's Icons between two different states. It uses the Client's "Tag" property purely for the sake of example:

Public Function Main(ByVal userInterface As ISUserInterfaceBL, ByVal reports As ISfinReports, ByVal eventId As String, ByVal targetObject As Object, ByVal parameters As ISParameters, ByRef requiresRefresh As Boolean) As Boolean

  Dim Client As finClient

  ' Assume Success
  Main = True

  ' Initialise
  Client = DirectCast(targetObject, finClient)

  ' Handle Events
  Select Case eventId
    Case "Execute"
      ' Use Tag to determine 'Pinned' state (just for example's sake) and toggle it
      If Client.Tag Is Nothing OrElse CStr(Client.Tag) = "Pinned" Then
        Client.Tag = "Unpinned"
      Else
        Client.Tag = "Pinned"
      End If
      
      ' Refresh
      requiresRefresh = True
      
    Case "GetState"
      ' Determine Icon and Caption
      If Client.Tag Is Nothing OrElse CStr(Client.Tag) = "Pinned" Then
        Parameters.SetString("caption", "Pin")
        parameters.Setstring("icon", "Pin_Green")
      Else
        Parameters.SetString("caption", "Unpin")
        parameters.Setstring("icon", "Pin_Green_Clear")  
      End If
      Parameters.SetBoolean("enabled", ScriptInfo.FormRecordMode = iseFormRecordMode.Loaded)
  End Select

End Function

NOTE: In this case, the "Execute" event is being used to toggle the icon. This event must set requiresRefresh to True to force the Clients form to refresh itself otherwise the icon will not be updated.