Adding custom Pick Lists (using v9.2's User-Defined Tables ) |
Top Previous Next |
(From Newsletter #46, Sept 10, 2018)
DISCLAIMER: This article involves Advanced Customizations, which can be technically challenging to get working and is not part of standard support. This is programming and must be done precisely or the results can be unpredictable. This information is provided as a service for those who have the technical skills to work through it -- we cannot help you solve any issues with getting it working. For more information about Advanced Customizations, see the full documentation:
https://campgroundmaster.com/help/overview32.html
One of the powerful new features added in version 9.2 was "User-defined Tables", along with "User-defined Relationships". Together, these allow you to add your own Pick Lists that you can easily use in any of the other tables / dialogs, and also modify the list whenever you want like regular Pick Lists without having to go back and modify all of your custom code.
The complete documentation or custom tables is here:
http://campgroundmaster.com/help/overview47.html
However, that's a lot to dig through to figure out how to just add a pick list. Here is a step-by-step guide for adding a pick list, in this case for adding a "Category" pick list to the Work Orders (which also makes use of the new ability to modify the Edit Work Order dialog).
Step 1 -- Adding the Table
First we need to add the table for the pick list. In this case we're going to call it "Work Category", but use whatever name you need.
1.1. Go to Maintenance / Advanced Customizations / User-defined Tables
1.2. Click Add table definition.
1.3. Enter "Work Category" in the Displayed Name field.
1.4. Enter "WorkCategory" (no spaces) in the Internal Name field.
1.5. Enter "WCat" (no spaces) in the Short Name field.
1.6. Check the Pick List checkbox.
1.7. Enter "100" for the ID (assuming this is the first table you're adding, else use the next number available).
1.8. Click Data Field Definitions. This will create the default fields needed for a Pick List. You probably don't need to add any more, so just click Close.
1.9. Drop down the Unique Identifier Field list and select "Selection Name".
1.10. Click Edit Raw Data if you want to add some entries now. As with any table or pick list, you'll need to check Allow editing of fields, and use New Record to add entries.
1.11. Click Save to save the new table.
Step 2 -- Adding the field to the Work Orders table
Before setting up the relationship, we need to add the field that relates to the pick list. Again, our example is "Work Category" in the Work Orders table, but use whatever fits your needs.
2.1. Go to Maintenance / Data Field Definitions / Work Order Fields.
2.2. Click Add New Field.
2.3. Enter "Category" for the Field Identifier.
2.4. Select "Pick List Item (Enum)" for the Field Type.
2.5. Enter "Category" for the Field Name, Short Label, and Report Heading. Make sure Enabled is checked.
2.6. Click Save to save the new field, and Close to exit the Data Field Definitions.
Step 3 -- Adding the Relationship
Now we're ready to tell it that the new field is linked to the new pick list table.
3.1. Go to Maintenance / Advanced Customizations / User-defined Relationships
3.2. Click Add relationship.
3.3. Select "Work Orders" for the From Table.
3.4. Select "Category" for the From Field.
3.5. Select your new table, "Work Category", for the To Table.
3.6. Select "Selection Name" for the Display Field. In case you're wondering about the relational technical aspects, the "Record ID" (the Field_Index field) is always the "To Field" for relationships, so there's no need to select it here.
3.7. Click Save.
That's it as far as setting up the pick list. BTW, it won't appear in the standard Pick Lists menu, so any time you need to ad or edit items in the list, you would go to Maintenance / Advanced Customizations / User-defined Tables, select your table, and click Edit Raw Data. But we'll also show you how to add a shortcut so you can edit the list right from the Work Order dialog.
Step 4 -- Adding the list to Edit Work Order
Now we need a way to set the category for the work orders.
4.1. Go to Maintenance / Advanced Customizations / Dialogs
4.2. Click Add dialog definition.
4.3. Enter "Work order" for the Dialog name.
4.4. Check Add-on, and select "Edit Work Order".
4.5. Click Quick-add fields. Enter 150 for the Starting top position, 180 for the Label left position, 240 for the Entry field left position. (These are arbitrary just to get it in a usable position, you can modify as needed later).
4.6. Click "Category" in the Data Field list, and click the --> button to add it to the Fields Selected list. Click Done.
Now for the button to edit categories:
4.7. Click Add element.
4.8. Select "Add New Control" for the Element Type.
4.9. Enter "Edit Cat" for the Control Name.
4.10. Select "Button" for the Control Type.
4.11. Enter 400 for the Left position, 150 for Top, 60 Width, 20 Height.
4.12. Enter "Edit" for the Control Text.
4.13. Click Edit Action Expr..., and then enter the following expression:
ShowRawData("WorkCategory")
4.14. Click Save twice to get back to Edit Dialog Definition.
4.15. Now you can use Save & Test Dialog to try it out.
4.16. Save & Close all the way out. That's it!
Note that when you View Work Orders, your custom fields are automatically added to the list, in front of the Notes. However this is pretty unique -- adding a Customer or Reservation field does not automatically add it to the associated reports, for instance (that could get out of hand), so it would be up to you do create Queries to use custom fields in reporting (covered elsewhere).