The Dynamic Association Field is a Field Class added in version 7.7 which enables the Field it's set on to have multiple different association operations attached to it, based on the value in that field. A good example of a use case for this field class happens in a situation like shipping. Lets say we have a table that contains order information, along with their preferred shipping carrier (FedEx, UPS, USPS, DHL, etc...) and tracking number from that carrier. Obviously we won't be able to use the same Association operation to send the end user to their tracking information on the carrier's website due to differing standards between carriers and their own proprietary tracking setups. In this case, we want the ability to set up a single field that will have different association operations based on which carrier the order is shipped on. This is where the Dynamic Association Field comes in.
The Dynamic Association Field utilizes the WOW Possible Values Key to dynamically determine the ID of the Association to run. To set up the field to be a Dynamic Association Field it is recommended to get your Association operations set up first. Once they are set up, note the ID of each of these Association operations. We will be using these IDs in the next step.
Next we will need to go to the WOW Utilities, which can be found in the Development Tools menu in the WOW Builder:
Once the WOW Utilities window loads, we will need to go to the Keyed Possible Values:
We then want to create a new set of Possible Values with the same Key. The following image shows an example set of Possible Value Keys set up to work with Dynamic Association Field:
In the above image take note of the following fields:
Key - This field should contain a unique identifier for this PV Key. This can be named anything you want, just be sure the Key value remains the same for each different value you need to have a different association for. In the case above, we have dynamic associations for 4 different values, all in the same PV Key (DynamicAssocFieldShipping).
Value - This field should contain the value that will determine which Association ID to use; in the case above, it's the Carrier for our shipping information which will contain values like FedEx, USPS, UPS, DHL.
Display Value - This field should contain the ID of the Association Operation that needs to run when the Dynamic Association Field link is clicked.
The following image is the list of operations that were set up for the demo:
Notice the Operation ID for each of the HTML Code Association and compare those values to the Display Values set up in the PV Key.
Once we have the PV Key set up, it then needs to be set on the Field Descriptor:
Notice the Possible Values Key has been set to the Key which was created above (DynamicAssocFieldShipping). Please also notice the Field Class has been modified. The free-form entry field has been selected and the Dynamic Association Field class has been entered into that field:
planetj.database.field.DynamicAssociationField
Now, when we run our operation we have a link that shows up in the Carrier field:
When the link is clicked, the association that is run is chosen based on the value in that field. In our example if FedEx is clicked the operation with ID 2556 will run. If USPS is clicked, operation with ID 2557 will run. If UPS is clicked, operation with ID 2558 will run. If DHL is clicked, operation with ID 2559 will run.
To view a small sample operation, please click HERE.