Plugin Sample - Sales Order Processing Reminder Notes

Samples and Examples of using the Jiwa 7 framework - including plugins, stand-alone applications and scripts.

Plugin Sample - Sales Order Processing Reminder Notes

Postby Scott.Pearce » Mon Feb 03, 2014 12:04 pm

Here is a nice plugin sample that illustrates the display of a dialog from a Jiwa 7 form. Specifically, when processing a Sales Order, if any notes exist of type "Reminder" they will be displayed to the user, and the user has the option to continue or cancel the processing. 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.

1.PNG
System Settings->Plugins->Plugin Maintenance
1.PNG (54.14 KiB) Viewed 1341 times



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.

3.PNG
Add a form
3.PNG (28.94 KiB) Viewed 1341 times



Enter the text/code as denoted in the screenshot below.

2.PNG
Create a new plugin
2.PNG (78.09 KiB) Viewed 1341 times


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.

4.PNG
Compile
4.PNG (78.01 KiB) Viewed 1341 times



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.

5.PNG
Enable the plugin
5.PNG (47.98 KiB) Viewed 1341 times



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.

6.PNG
The plugin working
6.PNG (50.47 KiB) Viewed 1341 times
Attachments
Sales Order Processing Reminder Notes.rar
(3.06 KiB) Downloaded 216 times
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 743
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Return to Samples and Examples

Who is online

Users browsing this forum: No registered users and 1 guest