Using PickList to display one value but record another
I have a simple form with a self-reference to a parent field, used to manage distribution areas. A distribution area may be a part of a larger parent area. Each area has a unique numeric identifier, as well as a more user-friendly string identifier.
I'd like the parentArea to be a drop down, and have got it to auto-load the fields into the list just fine. However, I'd like the end-user to see the identifier field in the drop down, but the underlying data to store the Id field instead. How can I achieve this? Normally it's possible to use a Lookup field and use something like "displayformat = [ identifier ]", but as this is self-referencing it won't allow it (you can't have a lookup on the same form as the form it's in).
Many thanks
Toby
The code follows:
- form DistributionArea
- {
- field alignment = left
-
- must have id1
- (
- displayname = "Id"
- type = number
- tooltip = "Unique numeric identifier"
- width = 100px
- )
- must have identifier
- (
- displayname = "Identifier"
- type = text
- tooltip = "The area identifier to use in reports e.g. A, C3 etc"
- width = 200px
- )
- description
- (
- displayname = "Description"
- type = text
- tooltip = "Area description e.g. Farmoor"
- width = 200px
- )
- parentArea
- (
- displayname = "Parent Area"
- type = picklist
- values = {""}
- width = 206px
- )
- actions
- {
- on add
- {
- on load
- {
- if (count(DistributionArea) < 1)
- {
- clear parentArea;
- }
- for each area in DistributionArea
- {
- parentArea:ui.add(area.id1);
- }
- }
- Submit
- (
- type = submit
- displayname = "Submit"
- )
- Reset
- (
- type = reset
- displayname = "Reset"
- )
- }
- on edit
- {
- on load
- {
- if (count(DistributionArea) < 1)
- {
- clear parentArea;
- }
- for each area in DistributionArea
- {
- parentArea:ui.add(area.id1);
- }
- }
- Update
- (
- type = submit
- displayname = "Update"
- )
- Cancel
- (
- type = cancel
- displayname = "Cancel"
- )
- }
- }
- }