Display Field using values from different tables

Display fields can be a powerful tool, when displaying custom information on a form or a report. But there are times when a form has information from multiple tables being returned as part of the form query that is needed within a display field calculation.

To maximize the performance of the system you need to cache display fields, but this means you need to write your display methods efficiently to maximize system performance.

When writing display methods you have two options, write them on the form, or the database. Where possible I recommend you write them on the the database, but there are times when this is not possible.

When you write a display method on a form you have the option to include one parameter, a table. So for example if you have a display field on an InventSum table, you would pass the InventSum _InventSum parameter into the display field.

Within the code of the display field you can get to the other tables contained within the query, using joinchild and joinparent.

In the example below I have two tables, InventSum and InventDim, where InventSum is passed into the display field, but I also want access to information from InventDim.

display xyz displaymethod(InventSum _InventSum)
{
InventDim  locaInventDim;
localInventDim = _InventSum.joinchild();
<do some code here>
return result;
}

The above will allow you to navigate down the query to the necessary table you are interested in extracting the information from.

If you wanted to traverse down more tables then you can simple use the joinchild from the return joinchild previously. So in the above case you would use <table> = localInventDim.joinChild();

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s