Page 1 of 2
Custom fields

Posted:
Fri Jul 04, 2014 2:19 am
by DannyC
Can you provide a demo plugin to demonstrate how to add custom fields to say, Sales Order Entry screen?
And for the combobox option, can you also give some demo code on how to provide an interface for the user to adjust the values?
Cheers
Danny
Re: Custom fields

Posted:
Fri Jul 04, 2014 1:07 pm
by Scott.Pearce
I've attached a plugin and a sql script (inside a .rar file).
Installation
-------------
1. Run the sql script
2. Import the plugin
3. Open "System Configuration->Forms", and add a new entry:
Type = Plugin
Assembly Full Name = "Sales Order Custom Fields with UI"
Class Name = "SalesOrderComboBoxConfiguration"
Description = "Sales Orders ComboBox Custom Field Configuration"
4. Open "System Configuration->Menu Configuration->Menu Maintenance", and add a new form entry to your menu:
Description = "Sales Orders ComboBox Custom Field Configuration"
5. Restart Jiwa.
6. To create some values for the combobox, load the configuration form "System Settings->Sales Orders ComboBox Custom Field Configuration", and enter some values.
7. Now load sales orders ("Sales->Order Entry"). On the "Custom" tab you should see a ComboBox custom field, and the ComboBox will allow selection of the values as defined in step 6. Note that if you change the possible ComboBox values on the configuration form, you will have to restart Jiwa before they appear in the ComboBox custom field.
Explanation
--------------
First, I created a custom table in the database called "SO_ComboBoxValues" to hold the values to be used in the ComboBox . Then I created a new plugin. On the plugin, I added the sales order custom field via the "Custom Fields" tab.
In the code section of the plugin, I created some business logic classes to read and write the combobox configuration values. These classes are "SalesOrderComboBoxValue" and "SalesOrderComboBoxValueCollection". They inherit from the Jiwa "ListMaintenance" classes - which means much of the work is already done for me in the base class.
Next, I created a form class called "SalesOrderComboBoxConfiguration", that actually inherits from the Jiwa "ListMaintenance.UserInterface" form. Once again, this means most of the work is done for me. I just had to handle a couple of events and define the grid columns.
Feel free to ask any questions you may have.
Re: Custom fields

Posted:
Fri Jul 04, 2014 7:54 pm
by Mike.Sheen
Scott.Pearce wrote:Note that if you change the possible ComboBox values on the configuration form, you will have to restart Jiwa before they appear in the ComboBox custom field.
If that behaviour isn't desired - that is, if you want the current list of values to be used without restarting Jiwa, just replace these lines in the plugin:
- Code: Select all
Static comboBoxItemList As New List(Of String)
Static comboBoxItemDataList As New List(Of String)
with:
- Code: Select all
Dim comboBoxItemList As New List(Of String)
Dim comboBoxItemDataList As New List(Of String)
Scott was just being super efficient in his implementation and only reading the list of values if it had never been read before. The above change will allow the list to be re-read each and every time the host form (in this case sales orders) attempts to render the custom fields. If it's a small list, there won't be a significant performance impact reading the list every time a sales order is read or created.
Re: Custom fields

Posted:
Tue Aug 19, 2014 3:11 pm
by DannyC
Something isn't working.
When I open the sales order form I don't get any custom fields.
Is there supposed to be custom fields on the plugin? If so then I suspect the XML export for Plugins doesn't include the custom fields as I have nothing in custom fields on this plugin.
[EDIT:] I created my own custom field with CellType = combo in the plugin. Logged out & in. I now get the combobox on sales order custom fields tab, and values display from the entered list. That is awesome!
What is the association between the the plugin code and the tables XX_CustomSettng and XX_CustomSettingValues from 6.5.13?
Also the original question asked if we could have an example not just of a combo box but all types such as tickbox, string, integer, Jiwa lookup, decimal, etc.
Is this just a matter of a plugin with entries in the Custom Fields tab? If so, where does the data land? Still in the XX_CustomSettingValues tables?
Re: Custom fields

Posted:
Tue Aug 19, 2014 3:17 pm
by Mike.Sheen
DannyC wrote:Something isn't working.
When I open the sales order form I don't get any custom fields.
Is there supposed to be custom fields on the plugin? If so then I suspect the XML export for Plugins doesn't include the custom fields as I have nothing in custom fields on this plugin.
Also the original question asked if we could have an example not just of a combo box but all types such as tickbox, string, integer, Jiwa lookup, decimal, etc.
What is the association between the the plugin code and the tables XX_CustomSettng and XX_CustomSettingValues from 6.5.13?
I have got the dialog to enter values into the new table. That's awesome!
Bug 10886 relates to custom fields not being imported for plugins. It seems this problem was introduced by
another recent change relating to importing plugins which have custom fields - which was introduced after Scott posted his reply, but before you had tested it.
Re: Custom fields

Posted:
Tue Aug 19, 2014 3:23 pm
by DannyC
Too quick Mike! I just edited my question above as you were answering. Found the solution for the combobox, but wondering about other custom fields too?
[EDIT:] Ok, after reviewing the SO_CustomSetting and SO_CustomSettingValues tables I now get the association. All sweet.
One further question re the combobox custom table. There are two columns Item and ItemData. It is only Item which displays in Jiwa when the combo is selected. In addition the SO_CustomSettingValues table stores the Item value, not ItemData value. Is that your intention? Seems to be no point in the ItemData column.
2nd question. How do I get old/existing custom fields to display in Jiwa? If I add them into a plugin with the identical names, I get an error "Cannot insert duplicate key row in object".
[EDIT:] Found answer. They're in the Legacy Pre-Version 7 Plugin. I am moving them one by one to another plugin so I don't need to enable the Legacy Pre-Version 7 Plugin as I doubt it would compile successfully.
Re: Custom fields 

Posted:
Tue Aug 19, 2014 5:37 pm
by Scott.Pearce
the SO_CustomSettingValues table stores the Item value
Logged as bug
10894Also the original question asked if we could have an example not just of a combo box but all types such as tickbox, string, integer, Jiwa lookup, decimal, etc.
Is this just a matter of a plugin with entries in the Custom Fields tab?
Yes.
If so, where does the data land? Still in the XX_CustomSettingValues tables?
Yes.
Re: Custom fields

Posted:
Thu Oct 02, 2014 5:20 pm
by Atronics
Hi Scott,
I followed the installation step by step, was able to edit the values etc. However, there is nothing in the custom tab on the sales order. What am I missing?
John I.
Re: Custom fields

Posted:
Thu Oct 16, 2014 5:36 pm
by DannyC
John,
The missing step might be to create the custom field in the plugin. See the Custom Fields tab.
Re: Custom fields

Posted:
Fri Oct 17, 2014 8:10 am
by Scott.Pearce