Specifically, when performing an search for email (from the Email Maintenance screen, for example) a new search option is added with a title of "Date Sent". The "Date Sent" search option includes the date sent field in the search results. Below are the step by step instructions to create such a plugin. I've also attached an XML export of the plugin so that you can import it into your own databases rather than typing. Let's begin.
1. Log in to Jiwa and go to System Settings->Plugins->Plugin Maintenance.
2. Create a new plugin and provide a plugin name, the author, and a brief description as to what the plugin does.
3. Enter the text/code as denoted in the screenshot below.
- Code: Select all
AddHandler JiwaApplication.Manager.Instance.Search.Showing, AddressOf Search_Showing
- Code: Select all
Private Sub Search_Showing(sender As Object, e As System.EventArgs)
With JiwaApplication.Manager.Instance.Search
If .CurrentSearchMode = JiwaApplication.JiwaSearch.clsSearch.SearchModes.jswEmailMessages Then
' Add DateSent to display
Dim AOption As New JiwaApplication.JiwaSearch.SearchOption
With AOption
.Title = "Date Sent"
.SQLStr = "SELECT RecID, EMailNo, DateSent, EmailFrom, EmailTo, EmailSubject FROM EM_Main "
.OrderBy = "ORDER BY EMailNo"
.AddColumn ("RecID", vbString, "", 0, 1)
.AddColumn ("Email No.", vbstring, "", 5, 2)
.AddColumn ("Date Sent", vbDate, "", 15,3)
.AddColumn ("From", vbString, "", 20, 4)
.AddColumn ("To", vbString, "", 25, 5)
.AddColumn ("Subject", vbString, "", 35, 6)
End With
.Options.Add(AOption)
End If
End With
End Sub
The first code fragment hooks in to the "show" event of the search screen. It tells the system to call a function titled "Search_Showing" whenever the search screen is displayed.
The second code fragment is the "Search_Showing" function itself. This function first looks at the type of search, and if it is an Email search, it defines and adds a new search option called "Date Sent" to the search object.
4. Click the compile button to make sure there are no errors in our code.
5. If compilation was OK, you should now enable the plugin by ticking the "Enabled" checkbox at the top right of the Plugin Maintenance screen.
6. You must now exit Jiwa and re-login so that our new plugin will be active (all plugins are loaded by Jiwa at login time).
7. To test our plugin, go to "System Settings->Email->Email Maintenance". Click on "Search". In the "Select a Query" pull-down you should see a new search option titled "Date Sent" - select this and ensure the search executes without error, and that a search result can be selected, resulting in the appropriate Email Maintenance record being read.