Fill in the field value on form according to the value condition of the other two fields

We need fill value for some field (text value in read only)

There is a list of values for a text tield (let the field name be class) on the form.

What value to substitute in this field depends on the value of the other two fields (the name for them is type and cost).

For each value in the type field, there are value ranges for the cost field that give the value in the class field.

List of type value stored in personal table. All 3 fields will stored in one table (device)

Example to understand the question:

 

For type="type 1" and cost in range 0-10 class = "class1.1"

For type="type 1" and cost in range 11-100 class = "class1.2"

For type="type 1" and cost in range 101-1000 class = "class1.3"

For type="type 2" and cost in range 0-10 class = "class2.1"

For type="type 1" and cost in range 11-100 class = "class2.2"

For type="type 1" and cost in range 101-1000 class = "class2.3"

The range may be different for each type

  • As I see the solution to this may be next:

    1) create new table (classlist) where set next columns: type, class,  first digit of diapason(FDD), last digit of diapason (LDD)

    2) Use triggers or FormatControl - for Add/Update (table device)

    3) use script to get value from class field of table (classlist) by condition classlist.type=device.type and "cost" > FDD and "cost" < LDD

     

    maybe there is a better solution ?

  • Your solution is good, you may just need to add your script to DO. If users can alter the source fields, you may want to set an event to update the class value.

    Another option would be have a generic table, its useful if you have more situations like these one. The table could have as many fields as you want but the mandatory is key and value, the values would be something like:
    key: xxxtype 1;0 / value:class1.1
    key: xxxtype 1;1 / value:class1.1
    The benefit of this generic table is that you can use the same table for other situations.. the problem is that you may have more lines... it's up to you choose :)
  • Thnx for answer.

    - Yes i made in this my new table the id field and set autonumbering for this field in number table.

    - In DO you mean in PreJavaScript ?

    - How about link from device to this new table (i mean without JS) ?