| 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 OnPublic 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 BooleanDim Logs As finLogs' Assume SuccessMain = True' InitialiseLogs = DirectCast(source,finLogs)Select Case UCase(eventId)Case "LOADPOST": Main = LoadPost(logs)End SelectEnd FunctionPrivate Function LoadPost(logs As finLogs) As BooleanDim DaysOD As IntegerDim Log As finLogRODim i As IntegerDim strTemp As String' Assume SuccessLoadPost = True' User Defined Data Typeslogs.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' YearLog.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 ThenDaysOD = (Now.Date - Log.ActionDate).TotalDaysIf DaysOD = 0 ThenstrTemp = "Yellow"ElseIf DaysOD < 7 ThenstrTemp = "#FF8080"ElseIf DaysOD >= 7 ThenstrTemp = "#FF4040"ElseIf DaysOD >= 14 ThenstrTemp = "Red"End IfLog.User(1) = New finUserDataIconInfo("Flag[" & strTemp & "]", "Days Overdue: " & CStr(DaysOD))ElseLog.User(1) = NothingEnd IfNextEnd 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.