Advanced Development Techniques
Multi Value Reference Fields
[PRO] In scenarios where you may want to reduce the number of columns shown to reduce horizontal scrolling, using a "ReferenceField" may provide value. A ReferenceField is a derived field the refers to other fields to get it's value and field descriptor attributes. A ReferenceField would allow a single field to have different associations as well. Consider a scenario where a Shipment record had a 2 columns, one that held the UPS tracking number and another that help the FEDEX tracking number. Using a ReferenceField would allow you to condense both columns into 1 and also handle the scenario where the WOW http reference association is different for FEDEX versus UPS.
Using the ReferenceField
Create the initial SQL operation such as:
"SELECT SHIPMENT_ID, FEDEX#, UPS#, CASE WHEN FEDEX# IS NULL THEN 'UPS#' ELSE 'FEDEX#' END AS D_TrackingLink "
Notice that if FEDEX# column is NULL then we return a String that represents the column name to use to show the actual value and FD attributes otherwise we return the column 'UPS#'. The result returned is used to find ANOTHER field in that same row to use for the actual value.
Create a derived FD (field descriptor) for "D_TrackingLink". In this field set the FieldClass to "planetj.database.field.ReferenceField".
3. Run your operation and test.
Here is an example screen where the last column is a reference field. For this example, the operations SQL is:
SELECT LASTNAME, JOB, BONUS, COMM, CASE WHEN BONUS > COMM THEN 'Bonus' ELSE 'COMM' END AS d_actual_pay FROM PJDATA.EMPLOYEE WHERE comm > 0 AND bonus > 0
Considerations
1) The ReferenceField class takes the column heading of the 1st column that was produced.
2) All column names returned to ReferenceField must exist in the Row instance.
3) You can "hide" the source fields by setting their FD to hide or by not including them in the operations columns to display.