Document toolboxDocument toolbox

Custom Fields (Smart Fields)


Introduction

Each field in any object can be extended by Smart field configuration. Smart fields calculate values based on related objects - in most cases ancestor objects (higher in the tree structure).

Below is a list of available build in Smart field revolvers:

  • Text Compounder - a resolver that will create a field value based on selected values from one or more ancestor objects.

  • Auto Sum - a resolver that will calculate a sum of values present in child objects.

  • Math Basic operation - a resolver that will perform operation on given field and result will be put into main field.

  • Rule Based field - a resolver that will put desired value into a chosen field if given HQL condition is met.


"Smart fields" updates fields without checking for Security Schemes or Field Level Security.

 

Adding plugins configuration

Smart fields can be added in an Administrative panel. Please use the Add button to add new field or Delete to remove selected one.

On the new field form, select the following:

  • Class: Object class that should contain the custom field

  • Field: an existing field that will be affected (keep in mind that not all field types are compatible with custom fields)

  • Resolver: select from list o available custom field resolvers

Text Compounder

For this field to work correctly, we have to provide a set of information as show on this example:

  • Perspective - in most cases this will be the main perspective set used in Tree View to display basic object structure

  • Field formatter - this is a text string that can contain resolved values from objects indicated in grid below. 

    • First, start with defining objecs

    • Secondly, when the object list is ready, use their sequence numbers to build custom string.

    • To enter value from given object, use it's sequence number in brackets, like so: {1}

  • Text Compounder Objects - Starting from source object (the one that contains custom field - in this case Rum), provide a list of linked objects going upwards in the structure.

    • In this example, we would like to access data in Rum object, hence it is first on the sequence

    • Second obnject will be its parent object of class Plan (Plan must have a direct link to Rum)

    • The third object will be of class Building (Building must have a direct link to Plan)

 You do not have to use all objects, but there cannot be a gap between linking. For example, if we would like to create a field that contains only Building name, 

we would still use the same sequence to find the correct building, but in the formatter field use only the building sequence number {2}


The field value will be automatically calculated in specific situations:

  • When a new obejct is added and contains a smart field

  • When another object that is part of the smart field is updated (chanage of field value, change of location/link)


Supported field types

  • Text fields

  • Number Fields

  • Special fields (GUID, Serial)

 

Auto Sum

For this field to work correctly, we have to provide a set of information as show on this example:

This is a sample configuration for a Building object, that will have a smart field showing area from all child floor objects.

For the calculation to be correct, a simple structure without cross linking should be used. Otherwise the same object will be included in several summaries. 

  • Child class - provide a class name that will be selected from child objects.

  • Field - select a field that will be used to calculate sum.

  • Perspective - in most cases this will be the main perspective set used in Tree View to display basic object structure.

  • HQL - If this field is filled with HQL condition then operation of auto-sum will be done only if this condition is met (condition must must apply to objects of selected child class).

 

Supported field types

  • All numeric fields - the value is used "as is"

  • Text fields for both source and target of the calculation.

    • If the selected field contains a number represented as text, it will be parsed into number and used

    • If the field contains text value, 0.0 will be used as a value for this field for the sum operation

 

Field dependencies

One field can sum up values from child objects of one selected class. It might be desirable to create cascading dependency between objects that must be calculated in a specific order to be correct. 

The system will automatically determine what is the correct order if there are more then one Auto Sum fields defined.  In this example, if we have an Auto Sum field for Building (All floors area) and another Auto Sum field for Floor (All spaces area), then the Floor area will be calculated first, followed by Building.

This order is based on the following rule:


Example 1:

If a Space update is triggered, a system will determine that it's value must be used to calculate Floor field.

Floor is a child object for Building so it will be calculated first as it sums other dependent objects.

Since the Floor has been updated, system will now update Building area. 


Example 2:

If an update for Building object is requested, system will determine that it must use Floor objects. Since Floor is also a parent object for Space it will first calculate sum for all Floors, and then Building.

This is a generic mechanism based on parent - child dependency and not on specific class.

 

Basic Math operation

It's a resolver that will put the result of math operation into desired field of chosen object class (main field is defined on left side of plugin definition). Math operation can be done either using one field's value and given value or two values taken from two objects fields.
It means that there is a possibility to set value for a chosen field by performing math operation on two other fields of same object as selected or their ancestors in given Perspective.

 

Operation that will be done is defined on Basic operation field settings (right panel). 

First, choose a perspective in which objects taken for Math operation will be used.

  • Class #1 - choose class of object that's field value will be used as first argument of math operation (it can be same object as main class object or it's ancestor based on chosen perspective).

  • Field #1 - choose metadata field that's value will be used as as first argument of math operation.

  • Operation - choose math operation that will be performed.


    Then select whether second argument will be a strict chosen number of it will be taken from another field.

  • Class #2 - choose class of object that's field value will be used as second argument of math operation (it can be same object as main class object or it's ancestor based on chosen perspective).

  • Field #2- choose metadata field that's value will be used as as second argument of math operation.

    Result of math operation will be put into chosen Object Class Field from main configuration (left panel). 

 

Rule Based field

When configured, chosen class field will be given desired value if a HQL condition is met.

First add in Custom Fields panel new entry and choose ResolverRule based field.

Then in a panel for Rule based field settings add HQL condition and a value that will be added to selected field when condition is met.

Please note that there is no validation of value given with destination field type - if data is mismatched (ex. text put into numeric fields) than nothing will happen.



Of course there can be more than one rule per field:


Rule based fields can be set to be triggered on object modified and Import Finished events. 


Running plugin on demand can be done in single object or subtree mode, same as other custom fields.

Triggering plugins

Manual start of Smart Fields revolvers

In case a manual triggering of Smart Field is needed, it can be done through context menu on the Tree View:


Run of resolver is triggered for the selected object, but might affect objects lower in the structure, as described for specific resolvers.

Example: Running Auto Sum on properly configured Building fields, will trigger update of Floors and then calculate area for entire building. 

 

Automatic trigger of Smart Fields resolvers

Automatic trigger can be turned on for Smart fields in Administrator panel\Data Processing\Custom fields - Fields availability tab.


Event column informs on which action specific resolver will be triggered if Run on events column is checked.

AutoSum and MathBasicOperation plugins will automatically be run only on editing of object that have fields present in plugin configuration.
TextCompunder and Rule based field plugin in addition to manual Edition, can trigger after object is added or edited in import process (will be part of import process).



Sequence of automatic run of plugins is hard-coded as for now and is as follows:

  • TextCompunder

  • MathBasicOperation 

  • AutoSum 






Related topics: 

Save area from spot to linked hierarchy object