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. Add the associated form. This tells the plugin when to run. In this case it should execute when the Sales Order form is loaded.
Enter the text/code as denoted in the screenshot below.
- Code: Select all
Public Property SalesOrderForm As JiwaSalesUI.SalesOrder.SalesOrderEntryForm
- Code: Select all
SalesOrderForm = JiwaForm
AddHandler SalesOrderForm.SalesOrder.ProcessingStart, AddressOf ProcessingStart
- Code: Select all
Public Sub ProcessingStart
For Each existingNote As JiwaApplication.Notes.Note In SalesOrderForm.SalesOrder.Notes
If existingNote.NoteType.Description = "Reminder" Then
If Msgbox(existingNote.NoteText + System.Environment.NewLine + System.Environment.NewLine + "Do you wish to continue?" ,vbYesNo, "Continue?") = vbNo Then
Throw New JiwaApplication.Exceptions.ClientCancelledException
End If
End If
Next
End Sub
The first code fragment declares a sales order form object.
The second code fragment is executed whenever the sales order form in Jiwa is loaded. It puts the loaded sales order form into a local property (called SalesOrderForm), and also creates what is known as a *handler*. The AddHandler line is saying, "whenever the sales order business logic object that is attached to our form is told to process, run the code in the sub called "ProcessingStart" first.
The third code fragment is a sub that looks for any "Reminder" type notes that should be displayed to the user.
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, create a new Sales Order, add a part, and enter a note with a note type of "Reminder". Save and then process the Sales Order. You should now see the plugin at work.