Add Calculated Fields hook

Use this hook to add additional fields to the UserArea. Examples:

  • A concatenation of table fields
  • Table fields that are not part of the table(s) which is/are linked to the component
  • A result that is returned by calling a DLL function
  • An XML tree built up with data from any source

The lines of code in this hook are included in the function that the runtime BOD or BDE processor calls to fill the UserArea. The structure of this generated function is:

function extern long get.additional.elements(
                const   stringi.component,
                ref     long        o.xml)
{
        ...
        on case i.component
        case "component1":
             |* Generated code for selected fields for component1  
             |* Hook code for Add Calculated Fields for component1
             break
        case "component2":
             |* Generated code for selected fields for component2  
             |* Hook code for Add Calculated Fields for component2
             break
        default:
             break
        endcase
        ...
        return(0)
}

In the Add Calculated Fields hook you can use these macros to add fields to the UserArea:

  • addValue
  • addAmountValue
  • addCodeValue
  • addMasterDataReferenceValue
  • addQuantityValue
  • addDescription
  • addEffectiveTimePeriod
  • addXML
Note: Those macros only work in the hook itself. You cannot use them in a function you call from the hook.

In the Add Calculated Fields hook you cannot use directly the table fields of the linked table(s) of the Component. The actual values of the table fields are undefined. With some additional macros, you have access to the identifying attributes of the current Component and with those attributes you can query the database to get additional values. These macros are available:

  • getTableIdentifiers.<Component> (for each component with a UserArea)
  • getIdentifierValueFromIdentifierStructure
  • getIdentifierDataTypeFromIdentifierStructure