Using PickList to display one value but record another

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:


  1. form  DistributionArea
  2. {
  3.     field alignment = left
  4.    
  5.     must  have  id1
  6.     (
  7.         displayname  =  "Id"
  8.         type  =  number
  9.         tooltip  =  "Unique numeric identifier"
  10.         width  =  100px
  11.     )
  12.     must  have  identifier
  13.     (
  14.         displayname  =  "Identifier"
  15.         type  =  text
  16.         tooltip  =  "The area identifier to use in reports e.g. A, C3 etc"
  17.         width  =  200px
  18.     )
  19.     description
  20.     (
  21.         displayname  =  "Description"
  22.         type  =  text
  23.         tooltip  =  "Area description e.g. Farmoor"
  24.         width  =  200px
  25.     )
  26.     parentArea
  27.     (
  28.         displayname  =  "Parent Area"
  29.         type  =  picklist
  30.         values  =  {""}
  31.         width  =  206px
  32.     )
  33.     actions
  34.     {
  35.         on add
  36.         {
  37.             on load
  38.             {
  39.                 if (count(DistributionArea)  <  1)
  40.                 {
  41.                     clear parentArea;
  42.                 }
  43.                 for each area in DistributionArea
  44.                 {
  45.                     parentArea:ui.add(area.id1);
  46.                 }
  47.             }
  48.             Submit
  49.             (
  50.                 type  =  submit
  51.                 displayname  =  "Submit"
  52.             )
  53.             Reset
  54.             (
  55.                 type  =  reset
  56.                 displayname  =  "Reset"
  57.             )
  58.         }
  59.         on edit
  60.         {
  61.             on load
  62.             {
  63.                 if (count(DistributionArea)  <  1)
  64.                 {
  65.                     clear parentArea;
  66.                 }
  67.                 for each area in DistributionArea
  68.                 {
  69.                     parentArea:ui.add(area.id1);
  70.                 }
  71.             }
  72.             Update
  73.             (
  74.                 type  =  submit
  75.                 displayname  =  "Update"
  76.             )
  77.             Cancel
  78.             (
  79.                 type  =  cancel
  80.                 displayname  =  "Cancel"
  81.             )
  82.         }
  83.     }
  84. }