Article Details
Id:12443
Product:finPOWER Connect
Type:NEW
Version:2.02.03
Opened:13/02/2013
Closed:25/11/2014
Released:04/12/2014
Job: J011106

Logs; Script can now set "User" properties that are included in grids and can be used for filtering and grouping

Logs now support 10 "User" properties that can be set by a Script once the Logs collection (a read-only collection of logs) has been loaded. This is identical to the way that Tasks in the Task Manager work.

The following forms now support this functionality:

  • Accounts form, Logs page
  • Clients form, Logs page
  • External Parties form, Logs page
  • Security Statements form, Logs page
  • Task Manager form, Logs page
  • Workflows form, Logs page

A new "LogsLoadPost" Script can be defined under User Preferences, Tasks & Workflows, Scripts.

This Script must be an "Object Events" type Script with a Target Object type of "Logs".

The Script will be passed a finLogsRO collection and can then update the User(0) - User(9) properties (unrelated to User Data on objects such as finClient and finAccount).

The Script can also define the data type of each of the 10 User properties and a column heading to display in Logs grids.

The following sample Script uses User(0) to record the "Year" or the Log. It also uses the new Initialise() helper method in finUserDataHeader to configure how the User properties should be displayed (previously you had to set Caption and DataType separately).

Ituses the new finUserDataIconInfo type to display a flag icon in User(1) depending on how overdue the Log is:

Option Explicit On

Public Function Main(eventId As String, ByRef eventHandled As Boolean, source As Object, sourceIndex As Integer, contextData1 As Object, contextData2 As Object, parameters As Object) As Boolean

  Dim Logs As finLogs

  ' Assume Success
  Main = True

  ' Initialise
  Logs = DirectCast(source,finLogs)

  Select Case UCase(eventId)
    Case "LOADPOST": Main = LoadPost(logs)
  End Select

End Function

Private Function LoadPost(logs As finLogs) As Boolean

  Dim DaysOD As Integer
  Dim Log As finLogRO
  Dim i As Integer
  Dim strTemp As String

  ' Assume Success
  LoadPost = True

  ' User Defined Data Types
  logs.UserDataHeader(0).Initialise("Year", GetType(Integer))
  logs.UserDataHeader(1).Initialise("Overdue Flag", GetType(finUserDataIconInfo))

  ' Set User Data (only if visible for performance reasons)
  For Each Log In logs
    ' If logs.UserDataHeader(0).Visible Then ' Check whether a column is visible before populating if performance is an issue

    ' Year
    Log.User(0) = Log.Date.Year

    ' Overdue Flag Icon (various shades of red)
    If Log.ActionDate <> Nothing AndAlso Log.ActionCompleteDate = Nothing AndAlso Log.ActionDate <= Now.Date Then
      DaysOD = (Now.Date - Log.ActionDate).TotalDays

      If DaysOD = 0 Then
        strTemp = "Yellow"
      ElseIf DaysOD < 7 Then
        strTemp = "#FF8080"
      ElseIf DaysOD >= 7 Then
        strTemp = "#FF4040"
      ElseIf DaysOD >= 14 Then
        strTemp = "Red"
      End If

      Log.User(1) = New finUserDataIconInfo("Flag[" & strTemp & "]", "Days Overdue: " & CStr(DaysOD))
    Else
      Log.User(1) = Nothing
    End If
  Next

End Function

NOTE: The Logs collection will generally contain only Logs or a particular type and for a particular record, e.g., Client Logs for Client C10000. However, Security Statements may contain Security Item Logs and Workflows can be linked to any type of Log and therefore, if the Logs collection has been loaded for Workflows, a mix of Logs can be expected.